]> granicus.if.org Git - clang/commitdiff
Fix analyzer crash on analyzing 'catch' with no condition variable.
authorTed Kremenek <kremenek@apple.com>
Fri, 16 Mar 2012 05:58:15 +0000 (05:58 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 16 Mar 2012 05:58:15 +0000 (05:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152900 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
test/Analysis/misc-ps-region-store.cpp

index 245f587bac206f1cdfbdc23a58c06bce13e47945..a14a491333f20d9c9f16451be9ae9e225dc1c1d5 100644 (file)
@@ -268,6 +268,11 @@ void ExprEngine::VisitCXXCatchStmt(const CXXCatchStmt *CS,
                                    ExplodedNode *Pred,
                                    ExplodedNodeSet &Dst) {
   const VarDecl *VD = CS->getExceptionDecl();
+  if (!VD) {
+    Dst.Add(Pred);
+    return;
+  }
+
   const LocationContext *LCtx = Pred->getLocationContext();
   SVal V = svalBuilder.getConjuredSymbolVal(CS, LCtx, VD->getType(),
                                  currentBuilderContext->getCurrentBlockCount());
index 9fa0b860f2a52d9102dd0656eae1dd0a736b1408..00dff70480ea2429b36d7c6f19567652736c8410 100644 (file)
@@ -529,3 +529,26 @@ MyEnum rdar10892489_positive() {
   return MyEnumValue;
 }
 
+// Test handling of catch with no condition variable.
+void PR11545() {
+  try
+  {
+      throw;
+  }
+  catch (...)
+  {
+  }
+}
+
+void PR11545_positive() {
+  try
+  {
+      throw;
+  }
+  catch (...)
+  {
+    int *p = 0;
+    *p = 0xDEADBEEF; // expected-warning {{null}}
+  }
+}
+