]> granicus.if.org Git - clang/commitdiff
Fix: <rdar://problem/7034511> ValueManager::makeIntVal(uint64_t X, QualType T) should...
authorTed Kremenek <kremenek@apple.com>
Wed, 8 Jul 2009 22:42:46 +0000 (22:42 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 8 Jul 2009 22:42:46 +0000 (22:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75062 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/ValueManager.h
test/Analysis/misc-ps.m

index 36d1df2150df9cdfe3296d2c5c6b38fc940acd09..bbf77740c9bc38bf05b19db8bb69e2bb0563a137 100644 (file)
@@ -109,7 +109,10 @@ public:
     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));
   }
 
index 59578819f2f023d56077b416fed6456691b810cf..f82cf0b7f68efb4cb84855b5cadfbe21a9ba8e04 100644 (file)
@@ -10,7 +10,7 @@ typedef signed char BOOL;
 typedef int NSInteger;
 typedef unsigned int NSUInteger;
 typedef struct _NSZone NSZone;
-@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@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 @@ void test_cast_from_incomplete_struct() {
   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)) {}
+}
+