From: Ted Kremenek Date: Mon, 6 Jul 2009 21:01:16 +0000 (+0000) Subject: NewCastRegion: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=145918ca119904b6abe8b41aae0cbbf9a7247905;p=clang NewCastRegion: - Have test for 'CodeTextRegion' dominate other region tests. - Use 'getAsRecordType' instead of isa git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74853 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp index 4f0e4a62e9..cd123995fa 100644 --- a/lib/Analysis/Store.cpp +++ b/lib/Analysis/Store.cpp @@ -30,13 +30,7 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R, // We need to know the real type of CastToTy. QualType ToTy = Ctx.getCanonicalType(CastToTy); - - // Check cast to ObjCQualifiedID type. - if (ToTy->isObjCQualifiedIdType()) { - // FIXME: Record the type information aside. - return CastResult(state, R); - } - + // CodeTextRegion should be cast to only function pointer type. if (isa(R)) { assert(CastToTy->isFunctionPointerType() || CastToTy->isBlockPointerType() @@ -45,6 +39,12 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R, return CastResult(state, R); } + // Check cast to ObjCQualifiedID type. + if (ToTy->isObjCQualifiedIdType()) { + // FIXME: Record the type information aside. + return CastResult(state, R); + } + // Now assume we are casting from pointer to pointer. Other cases should // already be handled. QualType PointeeTy = cast(ToTy.getTypePtr())->getPointeeType(); @@ -65,7 +65,7 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R, || isa(R) || isa(R)) { // If the pointee type is incomplete, do not compute its size, and return // the original region. - if (const RecordType *RT = dyn_cast(PointeeTy.getTypePtr())) { + if (const RecordType *RT = PointeeTy->getAsRecordType()) { const RecordDecl *D = RT->getDecl(); if (!D->getDefinition(Ctx)) return CastResult(state, R); @@ -121,7 +121,6 @@ StoreManager::OldCastRegion(const GRState* state, const MemRegion* R, // FIXME: Handle arbitrary upcasts. QualType Pointee = PTy->getPointeeType(); if (Pointee->isVoidType()) { - while (true) { if (const TypedViewRegion *TR = dyn_cast(R)) { // Casts to void* removes TypedViewRegion. This happens when: @@ -149,8 +148,8 @@ StoreManager::OldCastRegion(const GRState* state, const MemRegion* R, R = ER->getSuperRegion(); continue; } - else - break; + + break; } return CastResult(state, R); @@ -178,7 +177,6 @@ StoreManager::OldCastRegion(const GRState* state, const MemRegion* R, // FIXME: Handle the case where a TypedViewRegion (layering a SymbolicRegion // or an AllocaRegion is cast to another view, thus causing the memory // to be re-used for a different purpose. - if (isa(R) || isa(R)) { const MemRegion* ViewR = MRMgr.getTypedViewRegion(CastToTy, R); return CastResult(AddRegionView(state, ViewR, R), ViewR);