[PATCH] D116597: [analyzer] Don't track function calls as control dependencies

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 30 07:03:39 PDT 2022


Szelethus marked 2 inline comments as done.
Szelethus added inline comments.


================
Comment at: clang/lib/Analysis/CFG.cpp:5908-5909
 
+void CFG::dump(bool ShowColors) const { dump(LangOptions{}, ShowColors); }
+
 /// print - A simple pretty printer of a CFG that outputs to an ostream.
----------------
steakhal wrote:
> How are these `dump()` changes related?
I'll commit them in a separate patch.


================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1968
+static const Expr *peelOffOuterExpr(const Expr *Ex, const ExplodedNode *N) {
+
   Ex = Ex->IgnoreParenCasts();
----------------
steakhal wrote:
> extra blank line
That is intentional -- I think it makes the code more readable. Separates the function signature from the implementation.


================
Comment at: clang/test/Analysis/track-control-dependency-conditions.cpp:1036
+  x = nullptr;        // expected-note {{Null pointer value stored to 'x'}}
+  if (!alwaysFalse()) // expected-note {{Taking true branch}}
+    *x = 5;           // expected-warning {{Dereference of null pointer (loaded from variable 'x') [core.NullDereference]}}
----------------
steakhal wrote:
> What if this expression is enclosed by a logical operator such as `&&`?
For each of those operators, a different CFGBlock would be created:

```
if (A && B) 
  C;
D;

      C
    /   \
  B------->
 /         \
A---------> D
```

This means that operands of || and && is retrievable through `CFGBlock::getLastCondition()`, so I shouldn't need to tear the AST apart to that extent. Though, I admit, you likely don't need to go very far to fool my implementation for realizing whether the condition boils down to a function call.


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

https://reviews.llvm.org/D116597



More information about the cfe-commits mailing list