[PATCH] D65287: [analyzer][CFG] Don't track the condition of asserts

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 07:08:22 PDT 2019

Szelethus marked an inline comment as done.
Szelethus added inline comments.

Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1753-1755
+  // It so happens that CFGBlock::getTerminatorCondition returns 'A' for block
+  // B1, 'A && B' for B2, and 'A && B || C' for B3. Let's check whether we
+  // reached the end of the condition!
NoQ wrote:
> Clever trick, but why not match for logical operators directly? Something like this:
> ```lang=c++
> if (auto B = dyn_cast<BinaryOperator>(OuterCond))
>   if (B->isLogicalOp())
>     return isAssertlikeBlock(Else, Context);
> ```
What about `assert(a + b && "Shouldn't be zero!");`?

Comment at: clang/test/Analysis/track-control-dependency-conditions.cpp:469-471
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+                           unsigned int __line, __const char *__function)
+__attribute__ ((__noreturn__));
NoQ wrote:
> I'm pretty sure you can define this function only once.
Note that it is in a namespace!



More information about the cfe-commits mailing list