Commit Graph

35 Commits

Author SHA1 Message Date
Meghana Gupta 3804e49b91 Make viewcfg options hyphenated 2026-03-27 14:52:37 -07:00
Meghana Gupta 1ee0b77dee When loop header information is available, print such blocks with a red border in viewcfg 2026-03-27 14:52:31 -07:00
Daniel Duan 3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Meghana Gupta 37e9c7b75c Add a flag to only view the shape of the cfg and disable instruction printing in viewcfg 2021-08-25 14:24:21 -07:00
Andrew Trick dc275dc8c7 Fix viewcfg for python3 2021-04-25 20:19:04 -07:00
Andrew Trick fe41108a23 Tweak viewcfg regex to handle block IDs.
Some of our unit tests now have non-numeric block IDs, like
"bb1a". While that may not be ideal, it seems harmless to tweak this
regex to handle those cases.
2021-02-21 18:45:02 -08:00
Andrew Trick baeb6c04e6 Fix viewcfg to handle whitespace.
If any whitespace occurred between blocks, the script will not see the
"last_line" containing the branch and won't draw those CFG edges.
2021-01-12 19:16:09 -08:00
Andrew Trick a704fdb936 viewcfg: use the 'helvetica' font 2020-11-03 02:02:12 -08:00
Michael Gottesman c8385b901e [viewcfg] Add an argparse based argument parser and enable the user to select to use dot instead of graphviz. 2020-04-27 18:19:01 -07:00
Bob Wilson e4cc933f70 master-next: adjust test output for change in LLVM block syntax
LLVM r356789 changed the format of textual IR to print nameless
blocks with labels instead of comments with "; <label>". Adjust Swift
tests to match. I also updated the utils/viewcfg script to match.
2019-03-29 18:19:26 -07:00
Erik Eckstein 92e6c4b8cd utils: support quoted block names in the viewcfg script 2018-11-28 10:46:18 -08:00
Michael Gottesman 694f2488d4 [viewcfg] Explicitly tell open to use Graphviz instead of relying on system defaults.
Just eliminates a source of unnecessary error. We only support graphviz so
nothing is lost here.
2018-06-19 16:41:42 -07:00
Erik Eckstein 4d2128b8c4 Some improvements in the viewcfg script.
*) output the block list in the original order. This results in a better placement of graph nodes.
*) fix regexp for llvm block labels
2017-04-21 14:48:24 -07:00
Hugh Bellamy c6fcbf0510 Python lint a bunch of files not currently python linted 2017-03-17 14:11:00 +07:00
practicalswift 6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift 797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
practicalswift f83634ef7e [Python] Remove unused variable last_line_content in viewcfg
Prior to this commit:

```
$ git grep last_line_content | wc -l
1
```

After this commit:

```
$ git grep last_line_content | wc -l
0
```
2016-03-12 20:12:50 +01:00
practicalswift c69ffe4eb6 [Python] Use new style class definitions: "class A" → "class A(object)" 2016-03-09 09:42:42 +01:00
Brian Gesiak c9000af795 Merge pull request #1526 from practicalswift/fix-pep8-violations-ii
[Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
2016-03-08 23:55:46 -05:00
practicalswift 265835fdfc [Python] Use consistent import ordering for Python code
Ordering used:
1.) standard library imports
2.) third party imports
3.) local package imports

Each group is individually alphabetized.
2016-03-07 23:25:16 +01:00
practicalswift 183da818df [Python] Fix five classes of PEP-8 violations (E101/E111/E128/E302/W191)
* E101: indentation contains mixed spaces and tabs
* E111: indentation is not a multiple of four
* E128: continuation line under-indented for visual indent
* E302: expected 2 blank lines, found 1
* W191: indentation contains tabs
2016-03-07 22:36:23 +01:00
practicalswift e33f1747a9 [Python] Improve Python consistency: "variable in function should be lowercase" (N806)
The repo contains roughly 80 Python scripts. "snake_case" naming is used for
local variables in all those scripts. This is the form recommended by the PEP 8
naming recommendations (Python Software Foundation) and typically associated
with idiomatic Python code.

However, in nine of the 80 scripts there were at least one instance of
"camelCase" naming prior to this commit.

This commit improves consistency in the Python code base by making sure that
these nine remaining files follow the variable naming convention used for
Python code in the project.

References:
* PEP 8: https://www.python.org/dev/peps/pep-0008/
* pep8-naming: https://pypi.python.org/pypi/pep8-naming
2016-03-02 18:56:47 +01:00
practicalswift f6d6585ee0 [Python] Improve Python consistency: Use function_name(…) throughout (PEP8) 2016-02-29 22:49:19 +01:00
practicalswift d021aedbdc PEP8: Fix all violations of type "too many blank lines" (E303) 2016-01-24 10:10:50 +01:00
practicalswift 1cd4d4e9c9 [gardening] Fix violations of non-controversial PEP8 rules
Fixes:
* multiple statements on one line (colon) (E701)
* missing whitespace around arithmetic operator (E226)
* missing whitespace around operator (E225)
* closing bracket does not match visual indentation (E124)
* blank line contains whitespace (W293)
* continuation line missing indentation or outdented (E122)
* continuation line over-indented for hanging indent (E126)
* missing expected blank line (E301)
* trailing whitespace (W291)
* unexpected spaces around keyword / parameter equals (E251)
* whitespace after '(', '[' or '{' (E201)
* whitespace before ')', ']' or '}' (E202)
* whitespace before ',' or ':' (E203)
2016-01-23 09:23:33 +01:00
practicalswift 22d043fcc0 [gardening] Fix violations of non-controversial PEP8 rules.
Fixes:
* blank line at end of file
* closing bracket does not match indentation of opening bracket's line
* continuation line over-indented for hanging indent
* continuation line over-indented for visual indent
* continuation line unaligned for hanging indent
* inline comment should start with '# '
* missing whitespace around arithmetic operator
* missing whitespace around bitwise or shift operator
* multiple imports on one line
* multiple spaces after ':'
* multiple spaces after operator
2016-01-16 00:47:43 +01:00
Zach Panzarino e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Brian Gesiak ddfecda3c2 [viewcfg] Prevent execution when importing
In order to prevent the Python interpreter from running code that is
meant to be executed directly, the convention is to check the context
in which the code is being interpreted.

Add a check for the context stored in the `__name__` variable, and only
execute the viewcfg script if it is being run as a command-line
script (that is, `__main__`).
2015-12-28 21:47:41 -05:00
Brian Gesiak 209bc4138c [viewcfg] Add Python code header
Add code headers missing from utils/viewcfg, as per the template from #762.
2015-12-28 21:44:05 -05:00
practicalswift 5249e8e7fa Fix syntax error and double open introduced in #735 2015-12-23 21:52:45 +01:00
Alex Chan 1f2a39c5f3 Tidy up Python file handlers
Rather than using `f = open(path).read()`, which leaves the file open
for an indeterminate period of time, switch to the `with open(path) as f`
idiom, which ensures the file is always closed correctly.
2015-12-22 22:33:18 +00:00
practicalswift 694639120b Use "if x not in y" instead of discouraged "if not x in y". 2015-12-21 10:24:48 +01:00
practicalswift b75f2841ae Remove redundant backslashes. 2015-12-21 10:24:09 +01:00
Alex Chan ce7ce98a01 Update Python build scripts to use the print function
In Python 3, 'print' was changed from a statement to a function.  Using
the __future__ module allows scripts to use print function whether
running with Python 2.6+ or Python 3.x.  This commit changes as many
instances of print as I could find to use the print function and the
__future__ module.
2015-12-18 23:00:55 +00:00
Erik Eckstein b0bcad7887 Add a utility script for displaying the CFG of SIL or LLVM IR.
It is useful if you have the SIL already in a file (instead of calling viewCFG() while running the compiler in lldb).

Especially useful for vim users: see the comment in the script on how to add commands to view the CFG from inside vim.




Swift SVN r30186
2015-07-14 16:22:52 +00:00