Skip to content

[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

Merged
merged 3 commits into from
Mar 26, 2024
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
31 changes: 28 additions & 3 deletions clang/utils/analyzer/exploded-graph-rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_diffs, dark_mode, gray_mode, topo_mode, dump_dot_only):
def __init__(
self, do_diffs, 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_diffs = do_diffs
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 = []

Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down