[PATCH] D78853: [Analysis] Fix null pointer dereference warnings [1/n]

Mandeep Singh Grang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 27 19:24:55 PDT 2020


mgrang updated this revision to Diff 260517.
mgrang retitled this revision from "[Sema] Fix null pointer dereference warnings [1/n]" to "[Analysis] Fix null pointer dereference warnings [1/n]".

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

https://reviews.llvm.org/D78853

Files:
  clang/lib/Analysis/ThreadSafety.cpp


Index: clang/lib/Analysis/ThreadSafety.cpp
===================================================================
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1935,6 +1935,10 @@
                       CapDiagKind);
 
   if (isScopedVar) {
+    // 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");
+
     // Add the managing object as a dummy mutex, mapped to the underlying mutex.
     SourceLocation MLoc = VD->getLocation();
     DeclRefExpr DRE(VD->getASTContext(), VD, false, VD->getType(), VK_LValue,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78853.260517.patch
Type: text/x-patch
Size: 659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200428/84518b81/attachment-0001.bin>


More information about the cfe-commits mailing list