[PATCH] D99262: [analyzer] Fix dead store checker false positive

Valeriy Savchenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 24 11:54:43 PDT 2021


vsavchenko added a comment.

In D99262#2648512 <https://reviews.llvm.org/D99262#2648512>, @steakhal wrote:

> I see your point.
>
> Would it report this issue?
>
>   int test() {
>     struct Foo foo = {0, 0}; // I would expect a warning here, that 'foo' was initialized but never read.
>     (void)foo;
>    return 0;
>   }
>
> Only nits besides this.

We got one big fat complaint about that, and I can see the point.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:25
 #include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
----------------
steakhal wrote:
> I don't see any new code that would depend on this header.
`llvm::all_of`?


================
Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:420-425
+              if (const auto *ILE =
+                      dyn_cast<InitListExpr>(E->IgnoreParenCasts()))
+                if (llvm::all_of(ILE->inits(), [this](const Expr *Init) {
+                      return Init->isEvaluatable(Ctx);
+                    }))
+                  return;
----------------
steakhal wrote:
> Eh, the indentation looks horrible.
> It would be probably better to use braces here.
Yeah, I agree. I'm not sure braces will help much.  I will try to do smith about it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99262



More information about the cfe-commits mailing list