diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-08 02:12:59 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-08 02:12:59 +0000 |
commit | afc875c7667983c18778cf60a32f49a1e2cbe292 (patch) | |
tree | f55689a94e7504acc1cdb2ccb1a9e8fd706100ce | |
parent | c0c074655de8f6f5719a116017db660051f98646 (diff) | |
download | bcm5719-llvm-afc875c7667983c18778cf60a32f49a1e2cbe292.tar.gz bcm5719-llvm-afc875c7667983c18778cf60a32f49a1e2cbe292.zip |
Replace the heuristic isSmallerThan with ASTContext::getTypeSize().
llvm-svn: 71206
-rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 14 | ||||
-rw-r--r-- | clang/test/Analysis/casts.c | 1 | ||||
-rw-r--r-- | clang/test/Analysis/rdar-6541136-region.c | 1 |
3 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index ea42c465aa5..32226af98f0 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -616,13 +616,6 @@ SVal RegionStoreManager::ArrayToPointer(Loc Array) { return loc::MemRegionVal(ER); } -static bool isSmallerThan(QualType T1, QualType T2) { - if (T1->isCharType()) - return true; - else - return false; -} - RegionStoreManager::CastResult RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R, QualType CastToTy) { @@ -675,8 +668,11 @@ 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 (isSmallerThan(PointeeTy, - cast<TypedRegion>(R)->getRValueType(getContext()))) { + QualType ObjTy = cast<TypedRegion>(R)->getRValueType(getContext()); + uint64_t PointeeTySize = getContext().getTypeSize(PointeeTy); + uint64_t ObjTySize = getContext().getTypeSize(ObjTy); + + if (PointeeTySize > 0 && PointeeTySize < ObjTySize) { // Record the cast type of the region. state = setCastType(state, R, ToTy); diff --git a/clang/test/Analysis/casts.c b/clang/test/Analysis/casts.c index fa41961a459..94a1eac0a31 100644 --- a/clang/test/Analysis/casts.c +++ b/clang/test/Analysis/casts.c @@ -2,7 +2,6 @@ // Test if the 'storage' region gets properly initialized after it is cast to // 'struct sockaddr *'. -// XFAIL #include <sys/socket.h> void f(int sock) { diff --git a/clang/test/Analysis/rdar-6541136-region.c b/clang/test/Analysis/rdar-6541136-region.c index 1e7a2d974bc..58ec8e8bbf8 100644 --- a/clang/test/Analysis/rdar-6541136-region.c +++ b/clang/test/Analysis/rdar-6541136-region.c @@ -1,4 +1,5 @@ // 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; |