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

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 30 07:05:03 PDT 2021


martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:420-421
+              // We should also allow defensive initialization of structs.
+              if (const auto *ILE =
+                      dyn_cast<InitListExpr>(E->IgnoreParenCasts())) {
+                // We can use exactly the same logic here.
----------------
What about nested InitListExpr's?
```
std::array<int, 3> a1{ {1, 2, 3} };
```

```
VarDecl 0x561b200333a0 </home/egbomrt/tmp/aaa.cc:2:1, col:34> col:20 a1 'std::array<int, 3>':'std::array<int, 3>' listinit
`-InitListExpr 0x561b20036d78 <col:22, col:34> 'std::array<int, 3>':'std::array<int, 3>'
  `-InitListExpr 0x561b20036dc0 <col:24, col:32> 'typename _AT_Type::_Type':'int [3]'
    |-IntegerLiteral 0x561b20033408 <col:25> 'int' 1
    |-IntegerLiteral 0x561b20033428 <col:28> 'int' 2
    `-IntegerLiteral 0x561b20033448 <col:31> 'int' 3
```


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