[all-commits] [llvm/llvm-project] 5e876c: [analyzer] exploded-graph-rewriter: Fix python3 st...

Balazs Benics via All-commits all-commits at lists.llvm.org
Thu Aug 11 07:09:08 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5e876c54f2d70195dd1bde827e908825aab2f4fb
      https://github.com/llvm/llvm-project/commit/5e876c54f2d70195dd1bde827e908825aab2f4fb
  Author: Balazs Benics <benicsbalazs at gmail.com>
  Date:   2022-08-11 (Thu, 11 Aug 2022)

  Changed paths:
    M clang/utils/analyzer/exploded-graph-rewriter.py

  Log Message:
  -----------
  [analyzer] exploded-graph-rewriter: Fix python3 string encoding issues

This encapsulates 3 changes:
 - `DotDumpVisitor` now aggregates strings instead of *bytes* for both
   `python2` and `python3`. This difference caused crashes when it tried
    to write out the content as *strings*, similarly described at D71746.
 - `graphviz.pipe()` expects the input in *bytes* instead of unicode
   strings. And it results in *bytes*. Due to string concatenations and
   similar operations, I'm using unicode string as the default, and
   converting to *bytes* on demand.
 - `write_temp_file()` now appends the `egraph-` prefix and more
   importantly, it will create the temp file in the **current working
   directory** instead of in the *temp*. This change makes `Firefox` be
   able to open the file even if the `security.sandbox.content.level` is
   set to the (default) most restricting `4`.
   See https://support.mozilla.org/si/questions/1259285

An artifact of the bad byte handling was previously in the `HTML`
produced by the script that it displayed the `b'` string at the top left
corner. Now it won't anymore :)

I've tested that the following command works on `Ubuntu 22.04`:
```
exploded-graph-rewriter my-egraph.dot
```
Both `python2` and `python3` works as expected.

PS: I'm not adding tests, as the current test infra does not support
testing HTML outputs for this script.
Check the `clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg`.
We always pass the `--dump-dot-only` flag to the script.
Along with that, the default invocation will not only create this HTML
report but also try to open it. In addition to this, I'm not sure if the
buildbots have `graphviz` installed and also if this package is installed
on `pip`.
Unless we change some of these, we cannot test this change.
Given that D71746 had no tests, I'm not too worried about this either.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D131553




More information about the All-commits mailing list