[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 19 23:06:10 PDT 2017


NoQ added inline comments.


================
Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:965
+
+    // Performing operator `&' on an lvalue expression is essentially a no-op.
+    // Then, if we are taking addresses of fields or elements, these are also
----------------
zaks.anna wrote:
> NoQ wrote:
> > alexshap wrote:
> > > "Address-of" operator can be overloaded, 
> > > just wondering - doest this code work correctly in that case ?
> > In this case we'd see a `CXXOperatorCallExpr` instead of `UnaryOperator` (all hail clang AST!).
> Adding a test case for that would be good.
Not sure. There are so many things that work differently in this scenario that i'm having troubles coming up with a test that tests exactly that and doesn't throw or not throw a warning for a dozen of other reasons. I'm even having troubles understanding what particular overload are we interested in. Did you have anything specific in mind?


================
Comment at: lib/StaticAnalyzer/Core/Store.cpp:440
   //  well, although in reality we should return the offset added to that
-  //  value.
+  //  value. See also the similar FIXME in getLValueFieldOrIvar().
   if (Base.isUnknownOrUndef() || Base.getAs<loc::ConcreteInt>())
----------------
Note that this code doesn't really trigger; we return `UnknownVal()` somewhere above, as shown on the newly added tests. I suspect we may be missing valid null dereferences because of that; will have a look.


https://reviews.llvm.org/D31982





More information about the cfe-commits mailing list