aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-05-08 07:28:25 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-05-08 07:28:25 +0000
commit2572eda55285cd61e7e8523d4404ed33f4d33d9b (patch)
treea71b5043785d902ba0c82eac1c8cee13768d6d33
parent5caa370ea6f70bd3e7e4a9cc3b69ac1a849c8534 (diff)
Region store: when casting VarRegions, if the cast-to pointee type is
incomplete, do not compute its size and return the original region. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71213 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/RegionStore.cpp8
-rw-r--r--test/Analysis/rdar-6541136-region.c1
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 32226af98f..7f103dfab2 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -668,6 +668,14 @@ RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R,
// VarRegion.
if (isa<VarRegion>(R) || isa<ElementRegion>(R) || isa<FieldRegion>(R)
|| isa<ObjCIvarRegion>(R) || isa<CompoundLiteralRegion>(R)) {
+ // If the pointee type is incomplete, do not compute its size, and return
+ // the original region.
+ if (const RecordType *RT = dyn_cast<RecordType>(PointeeTy.getTypePtr())) {
+ const RecordDecl *D = RT->getDecl();
+ if (!D->getDefinition(getContext()))
+ return CastResult(state, R);
+ }
+
QualType ObjTy = cast<TypedRegion>(R)->getRValueType(getContext());
uint64_t PointeeTySize = getContext().getTypeSize(PointeeTy);
uint64_t ObjTySize = getContext().getTypeSize(ObjTy);
diff --git a/test/Analysis/rdar-6541136-region.c b/test/Analysis/rdar-6541136-region.c
index 58ec8e8bbf..1e7a2d974b 100644
--- a/test/Analysis/rdar-6541136-region.c
+++ b/test/Analysis/rdar-6541136-region.c
@@ -1,5 +1,4 @@
// RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s
-// XFAIL
struct tea_cheese { unsigned magic; };
typedef struct tea_cheese kernel_tea_cheese_t;