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

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 7 15:19:23 PDT 2019


NoQ 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!
----------------
Szelethus wrote:
> 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!");`?
Mmm, could you elaborate? >.<


================
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__));
----------------
Szelethus wrote:
> NoQ wrote:
> > I'm pretty sure you can define this function only once.
> Note that it is in a namespace!
I mean, why is it in a namespace? Why not just define it once for the whole file? It's not like you're gonna be trying out different variants of `__assert_fail`.


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

https://reviews.llvm.org/D65287





More information about the cfe-commits mailing list