Skip to content

Commit f96a116

Browse files
committed
Merge pull request #808 from modocache/viewcfg
[viewcfg] Add Python code header, prevent execution when importing
2 parents 5bdab96 + ddfecda commit f96a116

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

utils/viewcfg

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
#!/usr/bin/env python
2-
3-
# A script for viewing the CFG of SIL and llvm IR.
4-
5-
# For vim users: use the following lines in .vimrc
2+
# viewcfg - A script for viewing the CFG of SIL and LLVM IR -*- python -*-
3+
#
4+
# This source file is part of the Swift.org open source project
5+
#
6+
# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
7+
# Licensed under Apache License v2.0 with Runtime Library Exception
8+
#
9+
# See http://swift.org/LICENSE.txt for license information
10+
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11+
#
12+
# ----------------------------------------------------------------------------
13+
#
14+
# For vim users: use the following lines in .vimrc...
615
#
716
# com! -nargs=? Funccfg silent ?{$?,/^}/w !viewcfg <args>
817
# com! -range -nargs=? Viewcfg silent <line1>,<line2>w !viewcfg <args>
918
#
10-
# to add these commands:
19+
# ...to add these commands:
1120
#
12-
# :Funccfg displays the CFG of the current SIL/llvm function.
21+
# :Funccfg displays the CFG of the current SIL/LLVM function.
1322
# :<range>Viewcfg displays the sub-CFG of the selected range.
1423
#
1524
# Note: viewcfg should be in the $PATH and .dot files should be associated
1625
# with the Graphviz app.
26+
#
27+
# ----------------------------------------------------------------------------
1728

1829
from __future__ import print_function
1930

@@ -159,5 +170,5 @@ def main():
159170

160171
subprocess.call(["open", fileName])
161172

162-
main()
163-
173+
if __name__ == '__main__':
174+
main()

0 commit comments

Comments
 (0)