[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 8 02:41:54 PDT 2018
xazax.hun added inline comments.
================
Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:519
+
+ if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
+ return true;
----------------
I am not sure if this is a reliable way to check if the access is before the guard.
Consider:
```
switch(x): {
case 2: guard; access; break;
case 1: access break;
}
```
Here, we have no particular ordering between the access in case 1 and the guard in case 2 at runtime. But relying on the source locations we might come to the false conclusion that there is. Loops, gotos can cause similar problems.
I do understand that this might not be too easy to solve without traversing the cfg and we might not want to do that but I think we should at least add a test/todo.
https://reviews.llvm.org/D51866
More information about the cfe-commits
mailing list