[cfe-commits] r126025 - in /cfe/trunk: lib/StaticAnalyzer/Core/SValBuilder.cpp lib/StaticAnalyzer/Core/Store.cpp test/Analysis/cxx-crashes.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Sat Feb 19 00:03:18 PST 2011


Author: akirtzidis
Date: Sat Feb 19 02:03:18 2011
New Revision: 126025

URL: http://llvm.org/viewvc/llvm-project?rev=126025&view=rev
Log:
[analyzer] Fix crash when analyzing C++ code.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
    cfe/trunk/test/Analysis/cxx-crashes.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=126025&r1=126024&r2=126025&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Sat Feb 19 02:03:18 2011
@@ -292,7 +292,7 @@
     //  }
 
     assert(Loc::isLocType(originalTy) || originalTy->isFunctionType() ||
-           originalTy->isBlockPointerType());
+           originalTy->isBlockPointerType() || castTy->isReferenceType());
 
     StoreManager &storeMgr = StateMgr.getStoreManager();
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp?rev=126025&r1=126024&r2=126025&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp Sat Feb 19 02:03:18 2011
@@ -78,7 +78,7 @@
 
   // Now assume we are casting from pointer to pointer. Other cases should
   // already be handled.
-  QualType PointeeTy = CastToTy->getAs<PointerType>()->getPointeeType();
+  QualType PointeeTy = CastToTy->getPointeeType();
   QualType CanonPointeeTy = Ctx.getCanonicalType(PointeeTy);
 
   // Handle casts to void*.  We just pass the region through.

Modified: cfe/trunk/test/Analysis/cxx-crashes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-crashes.cpp?rev=126025&r1=126024&r2=126025&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/cxx-crashes.cpp (original)
+++ cfe/trunk/test/Analysis/cxx-crashes.cpp Sat Feb 19 02:03:18 2011
@@ -14,6 +14,10 @@
   return !false;
 }
 
+void *f4(int* w) {
+  return reinterpret_cast<void*&>(w);
+}
+
 namespace {
 
 struct A { };
@@ -27,3 +31,15 @@
 }
 
 }
+
+namespace {
+
+struct S {
+    void *p;
+};
+
+void *f(S* w) {
+    return &reinterpret_cast<void*&>(*w);
+}
+
+}





More information about the cfe-commits mailing list