[PATCH] D43925: [analyzer] Prevent crashing in NonNullParamChecker

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 1 17:00:04 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC326520: [analyzer] Prevent crashing in NonNullParamChecker (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D43925

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/nonnullparamchecker-crash.cpp


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===================================================================
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1405,6 +1405,8 @@
     assert(!T.isNull() && "Unable to auto-detect binding type!");
     assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
     MR = GetElementZeroRegion(cast<SubRegion>(MR), T);
+  } else {
+    T = cast<TypedValueRegion>(MR)->getValueType();
   }
 
   // FIXME: Perhaps this method should just take a 'const MemRegion*' argument
Index: test/Analysis/nonnullparamchecker-crash.cpp
===================================================================
--- test/Analysis/nonnullparamchecker-crash.cpp
+++ test/Analysis/nonnullparamchecker-crash.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+class C {};
+
+// expected-no-diagnostics
+void f(C i) {
+  auto lambda = [&] { f(i); };
+  typedef decltype(lambda) T;
+  T* blah = new T(lambda);
+  (*blah)();
+  delete blah;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43925.136647.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180302/2d94c78d/attachment.bin>


More information about the cfe-commits mailing list