[clang] 0c3e24f - [analyzer] Allow egraph rewriter not to open the generated HTML directly (#85515)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 26 10:57:00 PDT 2024
Author: Ella Ma
Date: 2024-03-27T01:56:56+08:00
New Revision: 0c3e24f7c90243040fedcdfbbb417505f7cc0102
URL: https://github.com/llvm/llvm-project/commit/0c3e24f7c90243040fedcdfbbb417505f7cc0102
DIFF: https://github.com/llvm/llvm-project/commit/0c3e24f7c90243040fedcdfbbb417505f7cc0102.diff
LOG: [analyzer] Allow egraph rewriter not to open the generated HTML directly (#85515)
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.
Added:
Modified:
clang/utils/analyzer/exploded-graph-rewriter.py
Removed:
################################################################################
diff --git a/clang/utils/analyzer/exploded-graph-rewriter.py b/clang/utils/analyzer/exploded-graph-rewriter.py
index c7c6315a0a27d1..5eaa7738103f79 100755
--- a/clang/utils/analyzer/exploded-graph-rewriter.py
+++ b/clang/utils/analyzer/exploded-graph-rewriter.py
@@ -479,11 +479,19 @@ 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_
diff s, dark_mode, gray_mode, topo_mode, dump_dot_only):
+ def __init__(
+ self, do_
diff s, dark_mode, gray_mode, topo_mode, dump_html_only, dump_dot_only
+ ):
+ assert not (dump_html_only and dump_dot_only), (
+ "Option dump_html_only and dump_dot_only are conflict, "
+ "they cannot be true at the same time."
+ )
+
self._do_
diff s = do_
diff s
self._dark_mode = dark_mode
self._gray_mode = gray_mode
self._topo_mode = topo_mode
+ self._dump_html_only = dump_html_only
self._dump_dot_only = dump_dot_only
self._output = []
@@ -998,6 +1006,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 +1186,17 @@ def main():
default=False,
help="black-and-white mode",
)
- parser.add_argument(
+ dump_conflict = parser.add_mutually_exclusive_group()
+ dump_conflict.add_argument(
+ "--dump-html-only",
+ action="store_const",
+ dest="dump_html_only",
+ const=True,
+ default=False,
+ help="dump the rewritten egraph to a temporary HTML file, "
+ "but do not open it immediately as by default",
+ )
+ dump_conflict.add_argument(
"--dump-dot-only",
action="store_const",
dest="dump_dot_only",
@@ -1206,7 +1226,12 @@ 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_html_only,
+ args.dump_dot_only,
)
for trimmer in trimmers:
More information about the cfe-commits
mailing list