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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to