[cfe-commits] r75062 - in /cfe/trunk: include/clang/Analysis/PathSensitive/ValueManager.h test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Wed Jul 8 15:43:17 PDT 2009


Author: kremenek
Date: Wed Jul  8 17:42:46 2009
New Revision: 75062

URL: http://llvm.org/viewvc/llvm-project?rev=75062&view=rev
Log:
Fix: <rdar://problem/7034511> ValueManager::makeIntVal(uint64_t X, QualType T) should return a 'Loc' when 'T' is a pointer

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h?rev=75062&r1=75061&r2=75062&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/ValueManager.h Wed Jul  8 17:42:46 2009
@@ -109,7 +109,10 @@
     return nonloc::ConcreteInt(BasicVals.getValue(V, isUnsigned));
   }
 
-  NonLoc makeIntVal(uint64_t X, QualType T) {
+  SVal makeIntVal(uint64_t X, QualType T) {
+    if (Loc::IsLocType(T))
+      return loc::ConcreteInt(BasicVals.getValue(X, T));
+
     return nonloc::ConcreteInt(BasicVals.getValue(X, T));
   }
 

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=75062&r1=75061&r2=75062&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed Jul  8 17:42:46 2009
@@ -10,7 +10,7 @@
 typedef int NSInteger;
 typedef unsigned int NSUInteger;
 typedef struct _NSZone NSZone;
- at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+ at class NSInvocation, NSArray, NSMethodSignature, NSCoder, NSString, NSEnumerator;
 @protocol NSObject  - (BOOL)isEqual:(id)object; @end
 @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone; @end
 @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone; @end
@@ -313,3 +313,14 @@
   test_cast_from_incomplete_struct_aux(&_cmd);
 }
 
+// Test for <rdar://problem/7034511> 
+//  "ValueManager::makeIntVal(uint64_t X, QualType T) should return a 'Loc' 
+//   when 'T' is a pointer"
+//
+// Previously this case would crash.
+void test_rdar_7034511(NSArray *y) {
+  NSObject *x;
+  for (x in y) {}
+  if (x == ((void*) 0)) {}
+}
+





More information about the cfe-commits mailing list