[analyzer] Quote the type of the leaked/problematic object in diagnostics for readability

Differential Revision: https://reviews.llvm.org/D56344

llvm-svn: 350867
This commit is contained in:
George Karpenkov 2019-01-10 18:15:57 +00:00
parent 363dd8e4b8
commit 4f64b38f56
11 changed files with 1305 additions and 2542 deletions

View File

@ -157,14 +157,14 @@ static void generateDiagnosticsForCallLike(ProgramStateRef CurrSt,
}
if (CurrV.getObjKind() == ObjKind::CF) {
os << " returns a Core Foundation object of type "
<< Sym->getType().getAsString() << " with a ";
os << " a Core Foundation object of type '"
<< Sym->getType().getAsString() << "' with a ";
} else if (CurrV.getObjKind() == ObjKind::OS) {
os << " returns an OSObject of type " << getPrettyTypeName(Sym->getType())
<< " with a ";
os << " an OSObject of type '" << getPrettyTypeName(Sym->getType())
<< "' with a ";
} else if (CurrV.getObjKind() == ObjKind::Generalized) {
os << " returns an object of type " << Sym->getType().getAsString()
<< " with a ";
os << " an object of type '" << Sym->getType().getAsString()
<< "' with a ";
} else {
assert(CurrV.getObjKind() == ObjKind::ObjC);
QualType T = Sym->getType();
@ -587,7 +587,8 @@ CFRefLeakReportVisitor::getEndPath(BugReporterContext &BRC,
if (RegionDescription) {
os << "object allocated and stored into '" << *RegionDescription << '\'';
} else {
os << "allocated object of type " << getPrettyTypeName(Sym->getType());
os << "allocated object of type '" << getPrettyTypeName(Sym->getType())
<< "'";
}
// Get the retain count.
@ -724,7 +725,7 @@ void CFRefLeakReport::createDescription(CheckerContext &Ctx) {
} else {
// If we can't figure out the name, just supply the type information.
os << " of type " << getPrettyTypeName(Sym->getType());
os << " of type '" << getPrettyTypeName(Sym->getType()) << "'";
}
}

View File

@ -1933,9 +1933,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type CFNumberRef with a +1 retain count</string>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type &apos;CFNumberRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type CFNumberRef with a +1 retain count</string>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type &apos;CFNumberRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>

View File

@ -223,9 +223,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type CFDateRef with a +1 retain count</string>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type &apos;CFDateRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type CFDateRef with a +1 retain count</string>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type &apos;CFDateRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -739,9 +739,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -934,9 +934,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type CFStringRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type &apos;CFStringRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type CFStringRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type &apos;CFStringRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -1353,9 +1353,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type CFDateRef with a +1 retain count</string>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type &apos;CFDateRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type CFDateRef with a +1 retain count</string>
<string>Call to function &apos;CFDateCreate&apos; returns a Core Foundation object of type &apos;CFDateRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -1679,9 +1679,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type CFStringRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type &apos;CFStringRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type CFStringRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateString&apos; returns a Core Foundation object of type &apos;CFStringRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -1727,12 +1727,12 @@
</dict>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Object leaked: allocated object of type CFStringRef is not referenced later in this execution path and has a retain count of +1</string>
<string>Object leaked: allocated object of type &apos;CFStringRef&apos; is not referenced later in this execution path and has a retain count of +1</string>
<key>message</key>
<string>Object leaked: allocated object of type CFStringRef is not referenced later in this execution path and has a retain count of +1</string>
<string>Object leaked: allocated object of type &apos;CFStringRef&apos; is not referenced later in this execution path and has a retain count of +1</string>
</dict>
</array>
<key>description</key><string>Potential leak of an object of type CFStringRef</string>
<key>description</key><string>Potential leak of an object of type &apos;CFStringRef&apos;</string>
<key>category</key><string>Memory (Core Foundation/Objective-C)</string>
<key>type</key><string>Leak</string>
<key>check_name</key><string>osx.cocoa.RetainCount</string>

View File

@ -1299,9 +1299,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type CFNumberRef with a +1 retain count</string>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type &apos;CFNumberRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type CFNumberRef with a +1 retain count</string>
<string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object of type &apos;CFNumberRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>

View File

@ -155,9 +155,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -822,9 +822,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
<key>message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -1883,9 +1883,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -2006,9 +2006,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
<key>message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -2127,9 +2127,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -3834,12 +3834,12 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Object leaked: allocated object of type MyObj * is not referenced later in this execution path and has a retain count of +1</string>
<string>Object leaked: allocated object of type &apos;MyObj *&apos; is not referenced later in this execution path and has a retain count of +1</string>
<key>message</key>
<string>Object leaked: allocated object of type MyObj * is not referenced later in this execution path and has a retain count of +1</string>
<string>Object leaked: allocated object of type &apos;MyObj *&apos; is not referenced later in this execution path and has a retain count of +1</string>
</dict>
</array>
<key>description</key><string>Potential leak of an object of type MyObj *</string>
<key>description</key><string>Potential leak of an object of type &apos;MyObj *&apos;</string>
<key>category</key><string>Memory (Core Foundation/Objective-C)</string>
<key>type</key><string>Leak</string>
<key>check_name</key><string>osx.cocoa.RetainCount</string>
@ -4298,9 +4298,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
<key>message</key>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type CFTypeRef with a +1 retain count</string>
<string>Call to function &apos;CFCreateSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +1 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -4571,9 +4571,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
<key>message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>
@ -4768,9 +4768,9 @@
</array>
<key>depth</key><integer>0</integer>
<key>extended_message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
<key>message</key>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type CFTypeRef with a +0 retain count</string>
<string>Call to function &apos;CFGetSomething&apos; returns a Core Foundation object of type &apos;CFTypeRef&apos; with a +0 retain count</string>
</dict>
<dict>
<key>kind</key><string>control</string>

File diff suppressed because it is too large Load Diff

View File

@ -117,14 +117,14 @@ void os_consume_ok(OS_CONSUME OSObject *obj) {
}
void use_os_consume_violation() {
OSObject *obj = new OSObject; // expected-note{{Operator 'new' returns an OSObject of type OSObject with a +1 retain count}}
OSObject *obj = new OSObject; // expected-note{{Operator 'new' returns an OSObject of type 'OSObject' with a +1 retain count}}
os_consume_violation(obj); // expected-note{{Calling 'os_consume_violation'}}
// expected-note@-1{{Returning from 'os_consume_violation'}}
} // expected-note{{Object leaked: object allocated and stored into 'obj' is not referenced later in this execution path and has a retain count of +1}}
// expected-warning@-1{{Potential leak of an object stored into 'obj'}}
void use_os_consume_violation_two_args() {
OSObject *obj = new OSObject; // expected-note{{Operator 'new' returns an OSObject of type OSObject with a +1 retain count}}
OSObject *obj = new OSObject; // expected-note{{Operator 'new' returns an OSObject of type 'OSObject' with a +1 retain count}}
os_consume_violation_two_args(obj, coin()); // expected-note{{Calling 'os_consume_violation_two_args'}}
// expected-note@-1{{Returning from 'os_consume_violation_two_args'}}
} // expected-note{{Object leaked: object allocated and stored into 'obj' is not referenced later in this execution path and has a retain count of +1}}
@ -195,7 +195,7 @@ void check_free_no_error() {
}
void check_free_use_after_free() {
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
arr->retain(); // expected-note{{Reference count incremented. The object now has a +2 retain count}}
arr->free(); // expected-note{{Object released}}
arr->retain(); // expected-warning{{Reference-counted object is used after it is released}}
@ -203,13 +203,13 @@ void check_free_use_after_free() {
}
unsigned int check_leak_explicit_new() {
OSArray *arr = new OSArray; // expected-note{{Operator 'new' returns an OSObject of type OSArray with a +1 retain count}}
OSArray *arr = new OSArray; // expected-note{{Operator 'new' returns an OSObject of type 'OSArray' with a +1 retain count}}
return arr->getCount(); // expected-note{{Object leaked: object allocated and stored into 'arr' is not referenced later in this execution path and has a retain count of +1}}
// expected-warning@-1{{Potential leak of an object stored into 'arr'}}
}
unsigned int check_leak_factory() {
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
return arr->getCount(); // expected-note{{Object leaked: object allocated and stored into 'arr' is not referenced later in this execution path and has a retain count of +1}}
// expected-warning@-1{{Potential leak of an object stored into 'arr'}}
}
@ -228,18 +228,18 @@ void check_custom_iterator_rule(OSArray *arr) {
}
void check_iterator_leak(OSArray *arr) {
arr->getIterator(); // expected-note{{Call to method 'OSArray::getIterator' returns an OSObject of type OSIterator with a +1 retain count}}
} // expected-note{{Object leaked: allocated object of type OSIterator is not referenced later}}
// expected-warning@-1{{Potential leak of an object of type OSIterator}}
arr->getIterator(); // expected-note{{Call to method 'OSArray::getIterator' returns an OSObject of type 'OSIterator' with a +1 retain count}}
} // expected-note{{Object leaked: allocated object of type 'OSIterator' is not referenced later}}
// expected-warning@-1{{Potential leak of an object of type 'OSIterator}}'
void check_no_invalidation() {
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
OtherStruct::doNothingToArray(arr);
} // expected-warning{{Potential leak of an object stored into 'arr'}}
// expected-note@-1{{Object leaked}}
void check_no_invalidation_other_struct() {
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
OtherStruct other(arr); // expected-warning{{Potential leak}}
// expected-note@-1{{Object leaked}}
}
@ -266,8 +266,8 @@ struct ArrayOwner : public OSObject {
};
OSArray *generateArray() {
return OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
// expected-note@-1{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
return OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
// expected-note@-1{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
}
unsigned int check_leak_good_error_message() {
@ -285,7 +285,7 @@ unsigned int check_leak_msg_temporary() {
return generateArray()->getCount(); // expected-warning{{Potential leak of an object}}
// expected-note@-1{{Calling 'generateArray'}}
// expected-note@-2{{Returning from 'generateArray'}}
// expected-note@-3{{Object leaked: allocated object of type OSArray is not referenced later in this execution path and has a retain count of +1}}
// expected-note@-3{{Object leaked: allocated object of type 'OSArray' is not referenced later in this execution path and has a retain count of +1}}
}
void check_confusing_getters() {
@ -354,14 +354,14 @@ void check_dynamic_cast_null_check() {
}
void use_after_release() {
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
arr->release(); // expected-note{{Object released}}
arr->getCount(); // expected-warning{{Reference-counted object is used after it is released}}
// expected-note@-1{{Reference-counted object is used after it is released}}
}
void potential_leak() {
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to method 'OSArray::withCapacity' returns an OSObject of type 'OSArray' with a +1 retain count}}
arr->retain(); // expected-note{{Reference count incremented. The object now has a +2 retain count}}
arr->release(); // expected-note{{Reference count decremented. The object now has a +1 retain count}}
arr->getCount();
@ -412,7 +412,7 @@ unsigned int no_warn_ok_release(ArrayOwner *owner) {
}
unsigned int warn_on_overrelease_with_unknown_source(ArrayOwner *owner) {
OSArray *arr = owner->getArraySourceUnknown(); // expected-note{{Call to method 'ArrayOwner::getArraySourceUnknown' returns an OSObject of type OSArray with a +0 retain count}}
OSArray *arr = owner->getArraySourceUnknown(); // expected-note{{Call to method 'ArrayOwner::getArraySourceUnknown' returns an OSObject of type 'OSArray' with a +0 retain count}}
arr->release(); // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
// expected-note@-1{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
return arr->getCount();

View File

@ -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 of type CFPropertyListRef 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

View File

@ -49,7 +49,7 @@ void creationViaAlloc () {
}
void creationViaCFCreate () {
CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef 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,7 +68,7 @@ void acquisitionViaProperty (Foo *foo) {
}
void acquisitionViaCFFunction () {
CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef 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}}
}
@ -99,19 +99,19 @@ void autoreleaseUnowned (Foo *foo) {
}
void makeCollectableIgnored() {
CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef 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);
NSMakeCollectable(leaked);
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 of type CFTypeRef 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 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 of type CFTypeRef 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 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}}
}
@ -227,7 +227,7 @@ static int Cond;
// 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 of type MyObj * is not referenced later in this execution path and has a retain count of +1}}
// expected-note@-4 {{Object leaked: allocated object of type 'MyObj *' is not referenced later in this execution path and has a retain count of +1}}
// initI is inlined because the allocation happens within initY
id y = [[MyObj alloc] initY];
// expected-note@-1 {{Calling 'initY'}}
@ -244,20 +244,20 @@ static int Cond;
void CFOverAutorelease() {
CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef 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 of type CFTypeRef 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 of type CFTypeRef 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}}

View File

@ -19,7 +19,7 @@ void foo(CFAllocatorRef allocator) {
int width = 0;
int height = 0;
CFTypeRef* values = (CFTypeRef[]){
CFNumberCreate(allocator, kCFNumberSInt32Type, &width), //expected-warning{{Potential leak of an object of type CFNumberRef}}
CFNumberCreate(allocator, kCFNumberSInt32Type, &height), //expected-warning{{Potential leak of an object of type CFNumberRef}}
CFNumberCreate(allocator, kCFNumberSInt32Type, &width), //expected-warning{{Potential leak of an object of type 'CFNumberRef'}}
CFNumberCreate(allocator, kCFNumberSInt32Type, &height), //expected-warning{{Potential leak of an object of type 'CFNumberRef'}}
};
}