[llvm-branch-commits] [cfe-branch] r71330 - in /cfe/branches/Apple/Dib: lib/Analysis/RegionStore.cpp test/Analysis/casts.c test/Analysis/rdar-6541136-region.c

Mike Stump mrs at apple.com
Fri May 8 23:17:58 PDT 2009


Author: mrs
Date: Sat May  9 01:17:58 2009
New Revision: 71330

URL: http://llvm.org/viewvc/llvm-project?rev=71330&view=rev
Log:
Merge in 71206:

Replace the heuristic isSmallerThan with ASTContext::getTypeSize().

Modified:
    cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp
    cfe/branches/Apple/Dib/test/Analysis/casts.c
    cfe/branches/Apple/Dib/test/Analysis/rdar-6541136-region.c

Modified: cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp?rev=71330&r1=71329&r2=71330&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp Sat May  9 01:17:58 2009
@@ -616,13 +616,6 @@
   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 @@
   // 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);
 

Modified: cfe/branches/Apple/Dib/test/Analysis/casts.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Analysis/casts.c?rev=71330&r1=71329&r2=71330&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Analysis/casts.c (original)
+++ cfe/branches/Apple/Dib/test/Analysis/casts.c Sat May  9 01:17:58 2009
@@ -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) {

Modified: cfe/branches/Apple/Dib/test/Analysis/rdar-6541136-region.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Analysis/rdar-6541136-region.c?rev=71330&r1=71329&r2=71330&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Analysis/rdar-6541136-region.c (original)
+++ cfe/branches/Apple/Dib/test/Analysis/rdar-6541136-region.c Sat May  9 01:17:58 2009
@@ -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;





More information about the llvm-branch-commits mailing list