]> granicus.if.org Git - clang/commitdiff
[analyzer] Make BlockDataRegions typed, so that they have DynamicTypeInfo.
authorJordan Rose <jordan_rose@apple.com>
Fri, 17 Aug 2012 20:16:34 +0000 (20:16 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 17 Aug 2012 20:16:34 +0000 (20:16 +0000)
Fixes <rdar://problem/12119814>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162123 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
test/Analysis/blocks.m

index 8044ed839a75e145b4a9c833ed34c6f187f1d7cf..df8fb43b00d4adfa8f7b5d58c09dcb3a65964ba7 100644 (file)
@@ -99,11 +99,11 @@ public:
     // Untyped regions.
     SymbolicRegionKind,
     AllocaRegionKind,
-    BlockDataRegionKind,
     // Typed regions.
     BEG_TYPED_REGIONS,
     FunctionTextRegionKind = BEG_TYPED_REGIONS,
     BlockTextRegionKind,
+    BlockDataRegionKind,
     BEG_TYPED_VALUE_REGIONS,
     CompoundLiteralRegionKind = BEG_TYPED_VALUE_REGIONS,
     CXXThisRegionKind,
@@ -603,7 +603,7 @@ public:
 ///  which correspond to "code+data".  The distinction is important, because
 ///  like a closure a block captures the values of externally referenced
 ///  variables.
-class BlockDataRegion : public SubRegion {
+class BlockDataRegion : public TypedRegion {
   friend class MemRegionManager;
   const BlockTextRegion *BC;
   const LocationContext *LC; // Can be null */
@@ -612,13 +612,15 @@ class BlockDataRegion : public SubRegion {
 
   BlockDataRegion(const BlockTextRegion *bc, const LocationContext *lc,
                   const MemRegion *sreg)
-  : SubRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
+  : TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
     ReferencedVars(0), OriginalVars(0) {}
 
 public:
   const BlockTextRegion *getCodeRegion() const { return BC; }
   
   const BlockDecl *getDecl() const { return BC->getDecl(); }
+
+  QualType getLocationType() const { return BC->getLocationType(); }
   
   class referenced_vars_iterator {
     const MemRegion * const *R;
index ff376d17a1a1cbd3ceeaab2821e7e96917955ade..54ff58c64f429b94f9e49f5f8d2873608ae40a95 100644 (file)
@@ -26,10 +26,12 @@ typedef struct _NSZone NSZone;
 @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder; @end
 @interface NSObject <NSObject> {}
 + (id)alloc;
+- (id)copy;
 @end
 extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
-@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>    - (NSUInteger)length;
-- ( const char *)UTF8String;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+- (const char *)UTF8String;
 - (id)initWithFormat:(NSString *)format arguments:(va_list)argList __attribute__((format(__NSString__, 1, 0)));
 @end
 @class NSString, NSData;
@@ -85,4 +87,10 @@ void test2_b() {
 void test2_c() {
   typedef void (^myblock)(void);
   myblock f = ^() { f(); }; // expected-warning{{Variable 'f' is uninitialized when captured by block}}
-}
\ No newline at end of file
+}
+
+
+void testMessaging() {
+  // <rdar://problem/12119814>
+  [[^(){} copy] release];
+}