[PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state.

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 03:14:13 PDT 2020


Szelethus added a comment.

In D82845#2121940 <https://reviews.llvm.org/D82845#2121940>, @balazske wrote:

> Why does this not work?
>  I get only warning for the first resource leak (in the test `f_leak_2`). How to fix this?


First off, are two errors detected by the checker? You could check this with `debug.ViewExplodedGraph` + `clang/tools/analyzer/exploded-graph-rewriter.py`.

I do suspect though that this is a uniqueing issue. Just out of curiosity, what would happen is you dump the leaked stream symbol into the warning message? (or whatever, just so that two distinct warning messages are emitted)



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:969
+  // Do not warn for non-closed stream at program exit.
+  if (Pred && Pred->getCFGBlock() && Pred->getCFGBlock()->hasNoReturnElement())
+    return Pred;
----------------
It is a realistic worry that either the predecessor exploded node or the CFGBlock is null? Could we assert this instead?


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:971
-
-    ExplodedNode *N = C.generateErrorNode();
-    if (!N)
----------------
Ah, I see, we made it fatal accidentally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82845





More information about the cfe-commits mailing list