summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/osobject-retain-release.cpp
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-11-30 02:17:44 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-11-30 02:17:44 +0000
commitf893ea1592a4df9cba8e63d7fee1600eeda51a2a (patch)
tree0b6a666530d746424fed612b90a14c86d3229f6b /clang/test/Analysis/osobject-retain-release.cpp
parenta1c3bb88eeb83d5aa010827cae0408749d06a10d (diff)
downloadbcm5719-llvm-f893ea1592a4df9cba8e63d7fee1600eeda51a2a.tar.gz
bcm5719-llvm-f893ea1592a4df9cba8e63d7fee1600eeda51a2a.zip
[analyzer] Add the type of the leaked object to the diagnostic message
If the object is a temporary, and there is no variable it binds to, let's at least print out the object name in order to help differentiate it from other temporaries. rdar://45175098 Differential Revision: https://reviews.llvm.org/D55033 llvm-svn: 347943
Diffstat (limited to 'clang/test/Analysis/osobject-retain-release.cpp')
-rw-r--r--clang/test/Analysis/osobject-retain-release.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/test/Analysis/osobject-retain-release.cpp b/clang/test/Analysis/osobject-retain-release.cpp
index e02feef6fe4..d53ebbab5f0 100644
--- a/clang/test/Analysis/osobject-retain-release.cpp
+++ b/clang/test/Analysis/osobject-retain-release.cpp
@@ -61,13 +61,13 @@ void check_custom_iterator_rule(OSArray *arr) {
}
void check_no_invalidation() {
- OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to function 'withCapacity' returns an OSObject of type struct OSArray * with a +1 retain count}}
+ OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to function '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 function 'withCapacity' returns an OSObject of type struct OSArray * with a +1 retain count}}
+ OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to function 'withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
OtherStruct other(arr); // expected-warning{{Potential leak}}
// expected-note@-1{{Object leaked}}
}
@@ -94,7 +94,8 @@ struct ArrayOwner : public OSObject {
};
OSArray *generateArray() {
- return OSArray::withCapacity(10); // expected-note{{Call to function 'withCapacity' returns an OSObject of type struct OSArray * with a +1 retain count}}
+ return OSArray::withCapacity(10); // expected-note{{Call to function 'withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
+ // expected-note@-1{{Call to function 'withCapacity' returns an OSObject of type OSArray with a +1 retain count}}
}
unsigned int check_leak_good_error_message() {
@@ -109,7 +110,10 @@ unsigned int check_leak_good_error_message() {
}
unsigned int check_leak_msg_temporary() {
- return generateArray()->getCount();
+ 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}}
}
void check_confusing_getters() {
@@ -178,14 +182,14 @@ void check_dynamic_cast_null_check() {
}
void use_after_release() {
- OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to function 'withCapacity' returns an OSObject of type struct OSArray * with a +1 retain count}}
+ OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to function '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 function 'withCapacity' returns an OSObject of type struct OSArray * with a +1 retain count}}
+ OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to function '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();
@@ -236,7 +240,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{{function call returns an OSObject of type struct OSArray * with a +0 retain count}}
+ OSArray *arr = owner->getArraySourceUnknown(); // expected-note{{function call 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();
OpenPOWER on IntegriCloud