[analyzer] Fix crash when analyzing C++ code.

llvm-svn: 126025
This commit is contained in:
Argyrios Kyrtzidis 2011-02-19 08:03:18 +00:00
parent ecdd68d760
commit eb8357c1d8
3 changed files with 18 additions and 2 deletions

View 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();

View 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.

View 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);
}
}