]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix crash when analyzing C++ code.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 19 Feb 2011 08:03:18 +0000 (08:03 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 19 Feb 2011 08:03:18 +0000 (08:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126025 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/SValBuilder.cpp
lib/StaticAnalyzer/Core/Store.cpp
test/Analysis/cxx-crashes.cpp

index 796613383bd3b91dabce585c8c2a017cc41b65eb..b0fd497e57190d7c0a860d94890396eece69dd65 100644 (file)
@@ -292,7 +292,7 @@ SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
     //  }
 
     assert(Loc::isLocType(originalTy) || originalTy->isFunctionType() ||
-           originalTy->isBlockPointerType());
+           originalTy->isBlockPointerType() || castTy->isReferenceType());
 
     StoreManager &storeMgr = StateMgr.getStoreManager();
 
index 379327fbb5913dcdb203994932496c748064d9ac..722517097c736db61831b433904180019739a9da 100644 (file)
@@ -78,7 +78,7 @@ const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy)
 
   // 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.
index ae2f3cb5ebe516191f1c64dc95477b62d6f3036c..c9775df7e2d06abfd026422b0f5b70019902b067 100644 (file)
@@ -14,6 +14,10 @@ bool f3() {
   return !false;
 }
 
+void *f4(int* w) {
+  return reinterpret_cast<void*&>(w);
+}
+
 namespace {
 
 struct A { };
@@ -27,3 +31,15 @@ A f(char *dst) {
 }
 
 }
+
+namespace {
+
+struct S {
+    void *p;
+};
+
+void *f(S* w) {
+    return &reinterpret_cast<void*&>(*w);
+}
+
+}