[PATCH] D71041: [analyzer][discussion] Talk about escapes

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 13:52:52 PST 2019


NoQ added inline comments.


================
Comment at: clang/test/Analysis/fuchsia_handle.cpp:301
+    // So the value in some sense escaped our analysis.
+    zx_handle_close(sa);
+  } else
----------------
xazax.hun wrote:
> This is also nasty.
Cf.:
```lang=c++
int *x = malloc(sizeof(int));
if (!x) {
  // leak???
}
```
Basically, you can suppress the leak warning if the symbol is constrained to a constant.

On the other hand, in your case you might instead want to track concrete handles. I.e., you could change your map from "SymbolRef => HandleState" to "SVal => HandleState", update it whenever a symbol collapses to a constant and as such becomes dead, and use linear lookup with `evalEq()` instead of map lookup. Or you could add a separate map for concrete ints if you're sure that other kinds of concrete values will never appear (you could insist to have some fun with statements like `x == y` where `x` is a handle symbol and `y` is a `LocAsInteger`, but loc-as-integers shouldn't have been introduced to begin with).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71041/new/

https://reviews.llvm.org/D71041





More information about the cfe-commits mailing list