[clang] [analyzer] Ignoring `T v=v; ` idiom for uninitialized variable checker and dead store checker (PR #187530)
Ella Ma via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 1 00:45:34 PDT 2026
================
@@ -431,6 +431,12 @@ class DeadStoreObs : public LiveVariables::Observer {
// bug.
if (isa<ParmVarDecl>(VD) && VD->getType()->isScalarType())
return;
+ // Special case: check for self-initializations.
+ //
+ // e.g. int x = x;
+ //
+ if (VD == V)
----------------
Snape3058 wrote:
This is not checked by the deadcode.DeadStores checker.
```
void DeadStoreObs::CheckVarDecl(const VarDecl *VD, ...) ...
```
For the uninitialized variable checker, this actually leads to a false negative now.
```
struct S { int x = x; };
int foo() {
S s;
return s.x;
}
```
The uninitialized read to `s.x` is not reported. But I think that this FN needs to be considered in another PR.
Besides, this case is currently warned by the frontend warnings.
https://github.com/llvm/llvm-project/pull/187530
More information about the cfe-commits
mailing list