-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[analyzer] Allow egraph rewriter not to open the generated HTML directly #85515
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
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-static-analyzer-1 Author: Ella Ma (Snape3058) ChangesWhen developing on a headless device through SSH, we do not have a browser or even an X environment. Hence, it would be more convenient if the rewriter could stop before attempting to open the generated HTML file. Then, it can be opened remotely through an HTML server. This patch adds a new option Full diff: https://github.com/llvm/llvm-project/pull/85515.diff 1 Files Affected:
diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py
index c7c6315a0a27d1..ffec964d8ef09a 100755
--- a/clang/utils/analyzer/exploded-graph-rewriter.py
+++ b/clang/utils/analyzer/exploded-graph-rewriter.py
@@ -479,12 +479,14 @@ def add_raw_line(self, raw_line):
# A visitor that dumps the ExplodedGraph into a DOT file with fancy HTML-based
# syntax highlighing.
class DotDumpVisitor:
- def __init__(self, do_diffs, dark_mode, gray_mode, topo_mode, dump_dot_only):
+ def __init__(self, do_diffs, dark_mode, gray_mode, topo_mode, dump_dot_only,
+ dump_html_only):
self._do_diffs = do_diffs
self._dark_mode = dark_mode
self._gray_mode = gray_mode
self._topo_mode = topo_mode
self._dump_dot_only = dump_dot_only
+ self._dump_html_only = dump_html_only
self._output = []
def _dump_raw(self, s):
@@ -998,6 +1000,8 @@ def write_temp_file(suffix, prefix, data):
'<html><body bgcolor="%s">%s</body></html>'
% ("#1a1a1a" if self._dark_mode else "white", svg),
)
+ if self._dump_html_only:
+ return
if sys.platform == "win32":
os.startfile(filename)
elif sys.platform == "darwin":
@@ -1176,7 +1180,8 @@ def main():
default=False,
help="black-and-white mode",
)
- parser.add_argument(
+ dump_conflict = parser.add_mutually_exclusive_group()
+ dump_conflict.add_argument(
"--dump-dot-only",
action="store_const",
dest="dump_dot_only",
@@ -1186,6 +1191,14 @@ def main():
"displaying it, dump the rewritten dot file "
"to stdout",
)
+ dump_conflict.add_argument(
+ "--dump-html-only",
+ action="store_const",
+ dest="dump_html_only",
+ const=True,
+ default=False,
+ help="do not open the generated HTML immediately",
+ )
args = parser.parse_args()
logging.basicConfig(level=args.loglevel)
@@ -1206,7 +1219,8 @@ def main():
explorer = BasicExplorer()
visitor = DotDumpVisitor(
- args.diff, args.dark, args.gray, args.topology, args.dump_dot_only
+ args.diff, args.dark, args.gray, args.topology, args.dump_dot_only,
+ args.dump_html_only
)
for trimmer in trimmers:
|
✅ With the latest revision this PR passed the Python code formatter. |
…earance dot and html
Updated as suggested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
When developing on a headless device through SSH, we do not have a browser or even an X environment. Hence, it would be more convenient if the rewriter could stop before attempting to open the generated HTML file. Then, it can be opened remotely through an HTML server.
This patch adds a new option
--dump-html-only
to make the rewriter stop before opening the generated HTML in a browser. The new option is marked in conflict with the existing--dump-dot-only
option to prevent unexpected behaviors.