[PATCH] D78853: [Analysis] Fix null pointer dereference warnings [1/n]
David Blaikie via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 19:57:02 PDT 2020
dblaikie added inline comments.
================
Comment at: clang/lib/Analysis/ThreadSafety.cpp:1938-1940
+ // The default value for the argument VD to the current function is
+ // nullptr. So we assert that VD is non null because we deref VD here.
+ assert(VD && "!VD");
----------------
Doesn't seem like the most informative comment or assertion string - the invariant "isScopedVar implies VD is non-null" is established earlier in the function, where isScopedVar only becomes true under the "VD is non-null" condition at 1809.
Would it be better to improve whatever static analysis you're using to be able to track that correlation, rather than adding lots of extra assertions to LLVM? (can the Clang Static Analyzer understand this code and avoid warning on it, for instance - that'd be a good existence proof for such "smarts" being reasonably possible for static analysis)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78853/new/
https://reviews.llvm.org/D78853
More information about the cfe-commits
mailing list