Skip to content

[viewcfg] Add Python code header, prevent execution when importing #808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions utils/viewcfg
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
#!/usr/bin/env python

# A script for viewing the CFG of SIL and llvm IR.

# For vim users: use the following lines in .vimrc
# viewcfg - A script for viewing the CFG of SIL and LLVM IR -*- python -*-
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ----------------------------------------------------------------------------
#
# For vim users: use the following lines in .vimrc...
#
# com! -nargs=? Funccfg silent ?{$?,/^}/w !viewcfg <args>
# com! -range -nargs=? Viewcfg silent <line1>,<line2>w !viewcfg <args>
#
# to add these commands:
# ...to add these commands:
#
# :Funccfg displays the CFG of the current SIL/llvm function.
# :Funccfg displays the CFG of the current SIL/LLVM function.
# :<range>Viewcfg displays the sub-CFG of the selected range.
#
# Note: viewcfg should be in the $PATH and .dot files should be associated
# with the Graphviz app.
#
# ----------------------------------------------------------------------------

from __future__ import print_function

Expand Down Expand Up @@ -159,5 +170,5 @@ def main():

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

main()

if __name__ == '__main__':
main()