[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 20 13:21:44 PST 2019


NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I have no objections. George, this was your idea, does it look good to you?



================
Comment at: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:577-578
+
+    if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
+      return true;
+  }
----------------
That's quite unreliable, but in a good way. Like, in `if (x) foo(); else bar();`, in terms of source locations `bar()` goes after `foo()`, but in practice `bar()` never gets called after `foo()` (unless the whole thing is also in a loop). But when we're trying to heuristically suppress the specific false positive pattern in which statements definitely go in that order, it's not the end of the world when the heuristic suppresses a few other patterns.

So i think it's worth pointing out to the reader that this approach is a bit wonky, but not necessarily worth improving upon. That said, it should be possible to do this sort of stuff with a CFG-based analysis, probably even with one of the existing analyses in `lib/Analysis`.


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

https://reviews.llvm.org/D51866





More information about the cfe-commits mailing list