From 29a3ca1e0e2e5b62c18b662e407399312ec3abce Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Thu, 15 Dec 2016 22:55:03 +0000 Subject: [PATCH] [analyzer] Include type name in Retain Count Checker diagnostics The more detailed diagnostic will make identifying which object the diagnostics refer to easier. Differential Revision: https://reviews.llvm.org/D27740 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289883 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Checkers/RetainCountChecker.cpp | 16 +++- test/Analysis/edges-new.mm | 12 +-- test/Analysis/inlining/path-notes.m | 6 +- test/Analysis/objc-arc.m | 24 ++--- test/Analysis/plist-output-alternate.m | 4 +- test/Analysis/retain-release-arc.m | 2 +- test/Analysis/retain-release-path-notes-gc.m | 30 +++--- test/Analysis/retain-release-path-notes.m | 96 +++++++++---------- 8 files changed, 101 insertions(+), 89 deletions(-) diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index b7d1670999..204b0a6c46 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -1990,11 +1990,23 @@ PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N, } if (CurrV.getObjKind() == RetEffect::CF) { - os << " returns a Core Foundation object with a "; + if (Sym->getType().isNull()) { + os << " returns a Core Foundation object with a "; + } else { + os << " returns a Core Foundation object of type " + << Sym->getType().getAsString() << " with a "; + } } else { assert (CurrV.getObjKind() == RetEffect::ObjC); - os << " returns an Objective-C object with a "; + QualType T = Sym->getType(); + if (T.isNull() || !isa(T)) { + os << " returns an Objective-C object with a "; + } else { + const ObjCObjectPointerType *PT = cast(T); + os << " returns an instance of " + << PT->getPointeeType().getAsString() << " with a "; + } } if (CurrV.isOwned()) { diff --git a/test/Analysis/edges-new.mm b/test/Analysis/edges-new.mm index 775b1ced5f..5cc21e04ec 100644 --- a/test/Analysis/edges-new.mm +++ b/test/Analysis/edges-new.mm @@ -2438,9 +2438,9 @@ namespace rdar14960554 { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object of type CFNumberRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object of type CFNumberRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -11355,9 +11355,9 @@ namespace rdar14960554 { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of RDar10797980 with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of RDar10797980 with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -20325,9 +20325,9 @@ namespace rdar14960554 { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol diff --git a/test/Analysis/inlining/path-notes.m b/test/Analysis/inlining/path-notes.m index 264f0db056..d9b5a5820f 100644 --- a/test/Analysis/inlining/path-notes.m +++ b/test/Analysis/inlining/path-notes.m @@ -160,7 +160,7 @@ id testAutoreleaseTakesEffectInDispatch() { dispatch_once(&token, ^{}); id x = [[[[NSObject alloc] init] autorelease] autorelease]; - // expected-note@-1 {{Method returns an Objective-C object with a +1 retain count}} + // expected-note@-1 {{Method returns an instance of NSObject with a +1 retain count}} // expected-note@-2 {{Object autoreleased}} // expected-note@-3 {{Object autoreleased}} @@ -1840,9 +1840,9 @@ void testNullDereferenceInDispatch() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol diff --git a/test/Analysis/objc-arc.m b/test/Analysis/objc-arc.m index e9ef459036..2d47c18ba4 100644 --- a/test/Analysis/objc-arc.m +++ b/test/Analysis/objc-arc.m @@ -441,9 +441,9 @@ id rdar14061675() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object of type CFDateRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object of type CFDateRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -911,9 +911,9 @@ id rdar14061675() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1091,9 +1091,9 @@ id rdar14061675() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object of type CFStringRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object of type CFStringRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1466,9 +1466,9 @@ id rdar14061675() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object of type CFDateRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFDateCreate' returns a Core Foundation object of type CFDateRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1782,9 +1782,9 @@ id rdar14061675() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object of type CFStringRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateString' returns a Core Foundation object of type CFStringRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1879,9 +1879,9 @@ id rdar14061675() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +0 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +0 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +0 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +0 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m index 164f1c5991..7c8e513857 100644 --- a/test/Analysis/plist-output-alternate.m +++ b/test/Analysis/plist-output-alternate.m @@ -1191,9 +1191,9 @@ void rdar8331641(int x) { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object of type CFNumberRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFNumberCreate' returns a Core Foundation object of type CFNumberRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol diff --git a/test/Analysis/retain-release-arc.m b/test/Analysis/retain-release-arc.m index 616e00917f..6f3cbfbe5a 100644 --- a/test/Analysis/retain-release-arc.m +++ b/test/Analysis/retain-release-arc.m @@ -90,7 +90,7 @@ void _dispatch_object_validate(dispatch_object_t object); CFErrorRef error; CFDictionaryRef testDict = CFPropertyListCreateWithData(kCFAllocatorDefault, (__bridge CFDataRef)plistData, 0, 0, &error); #if HAS_ARC - // expected-note@-2 {{Call to function 'CFPropertyListCreateWithData' returns a Core Foundation object with a +1 retain count}} + // expected-note@-2 {{Call to function 'CFPropertyListCreateWithData' returns a Core Foundation object of type CFPropertyListRef with a +1 retain count}} #endif return (__bridge NSDictionary *)testDict; #if HAS_ARC diff --git a/test/Analysis/retain-release-path-notes-gc.m b/test/Analysis/retain-release-path-notes-gc.m index 08e4151a71..5b55582150 100644 --- a/test/Analysis/retain-release-path-notes-gc.m +++ b/test/Analysis/retain-release-path-notes-gc.m @@ -40,12 +40,12 @@ CFTypeRef CFGetSomething(); void creationViaCFCreate () { - CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}} + CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} } void makeCollectable () { - CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}} + CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +2 retain count}} CFMakeCollectable(leaked); // expected-note{{In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1}} NSMakeCollectable(leaked); // expected-note{{In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector}} @@ -54,7 +54,7 @@ void makeCollectable () { } void retainReleaseIgnored () { - id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +0 retain count}} + id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +0 retain count}} [object retain]; // expected-note{{In GC mode the 'retain' message has no effect}} [object release]; // expected-note{{In GC mode the 'release' message has no effect}} [object autorelease]; // expected-note{{In GC mode an 'autorelease' has no effect}} @@ -63,12 +63,12 @@ void retainReleaseIgnored () { @implementation Foo (FundamentalRuleUnderGC) - (id)getViolation { - id object = (id) CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}} + id object = (id) CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} return object; // expected-warning{{leak}} expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}} } - (id)copyViolation { - id object = (id) CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}} + id object = (id) CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected}} return object; // expected-warning{{leak}} expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}} } @end @@ -137,9 +137,9 @@ void retainReleaseIgnored () { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -283,9 +283,9 @@ void retainReleaseIgnored () { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -729,9 +729,9 @@ void retainReleaseIgnored () { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +0 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +0 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +0 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +0 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1100,9 +1100,9 @@ void retainReleaseIgnored () { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1287,9 +1287,9 @@ void retainReleaseIgnored () { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count. Core Foundation objects are not automatically garbage collected // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol diff --git a/test/Analysis/retain-release-path-notes.m b/test/Analysis/retain-release-path-notes.m index 51104fb814..23347bc3aa 100644 --- a/test/Analysis/retain-release-path-notes.m +++ b/test/Analysis/retain-release-path-notes.m @@ -44,12 +44,12 @@ CFTypeRef CFGetSomething(); void creationViaAlloc () { - id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}} + id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}} return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} } void creationViaCFCreate () { - CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}} + CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}} return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} } @@ -68,25 +68,25 @@ void acquisitionViaProperty (Foo *foo) { } void acquisitionViaCFFunction () { - CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}} + CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}} CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count}} return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} } void explicitDealloc () { - id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}} + id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}} [object dealloc]; // expected-note{{Object released by directly sending the '-dealloc' message}} [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}} } void implicitDealloc () { - id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}} + id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}} [object release]; // expected-note{{Object released}} [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}} } void overAutorelease () { - id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}} + id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}} [object autorelease]; // expected-note{{Object autoreleased}} [object autorelease]; // expected-note{{Object autoreleased}} return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased 2 times but the object has a +1 retain count}} @@ -99,19 +99,19 @@ void autoreleaseUnowned (Foo *foo) { } void makeCollectableIgnored () { - CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}} + CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}} CFMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument}} NSMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument}} return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}} } CFTypeRef CFCopyRuleViolation () { - CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}} + CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}} return object; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} } CFTypeRef CFGetRuleViolation () { - CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}} + CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}} return object; // expected-warning{{leak}} expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation}} } @@ -132,12 +132,12 @@ CFTypeRef CFGetRuleViolation () { } - (id)getViolation { - id result = [[Foo alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}} + id result = [[Foo alloc] init]; // expected-note{{Method returns an instance of Foo with a +1 retain count}} return result; // expected-warning{{leak}} expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa}} } - (id)copyAutorelease { - id result = [[Foo alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}} + id result = [[Foo alloc] init]; // expected-note{{Method returns an instance of Foo with a +1 retain count}} [result autorelease]; // expected-note{{Object autoreleased}} return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} } @@ -212,7 +212,7 @@ static int Cond; } -(id)initY { - self = [super init]; //expected-note {{Method returns an Objective-C object with a +1 retain count}} + self = [super init]; //expected-note {{Method returns an instance of MyObj with a +1 retain count}} return self; } @@ -224,7 +224,7 @@ static int Cond; +(void)test { // initX is inlined since we explicitely mark it as interesting id x = [[MyObj alloc] initX]; // expected-warning {{Potential leak of an object}} - // expected-note@-1 {{Method returns an Objective-C object with a +1 retain count}} + // expected-note@-1 {{Method returns an instance of MyObj with a +1 retain count}} // expected-note@-2 {{Calling 'initX'}} // expected-note@-3 {{Returning from 'initX'}} // expected-note@-4 {{Object leaked: allocated object is not referenced later in this execution path and has a retain count of +1}} @@ -244,20 +244,20 @@ static int Cond; void CFOverAutorelease() { - CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}} + CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}} CFAutorelease(object); // expected-note{{Object autoreleased}} CFAutorelease(object); // expected-note{{Object autoreleased}} return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased 2 times but the object has a +1 retain count}} } void CFAutoreleaseUnowned() { - CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}} + CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}} CFAutorelease(object); // expected-note{{Object autoreleased}} return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased but has a +0 retain count}} } void CFAutoreleaseUnownedMixed() { - CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}} + CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}} CFAutorelease(object); // expected-note{{Object autoreleased}} [(id)object autorelease]; // expected-note{{Object autoreleased}} return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased 2 times but the object has a +0 retain count}} @@ -393,9 +393,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -539,9 +539,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1277,9 +1277,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1498,9 +1498,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1719,9 +1719,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -1940,9 +1940,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of NSObject with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -2457,9 +2457,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -2753,9 +2753,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -2940,9 +2940,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -3688,9 +3688,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of Foo with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of Foo with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -3875,9 +3875,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of Foo with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of Foo with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -4826,9 +4826,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of MyObj with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of MyObj with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -5354,9 +5354,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth1 // CHECK-NEXT: extended_message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of MyObj with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Method returns an Objective-C object with a +1 retain count +// CHECK-NEXT: Method returns an instance of MyObj with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent @@ -5563,9 +5563,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count +// CHECK-NEXT: Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -5859,9 +5859,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol @@ -6080,9 +6080,9 @@ void CFAutoreleaseUnownedMixed() { // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: message -// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count +// CHECK-NEXT: Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol -- 2.40.0