diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-12-21 02:16:23 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-12-21 02:16:23 +0000 |
commit | f50853262723504f681595586b489cf4f7c48816 (patch) | |
tree | ff06e5eaa2974a3a222fd958cd0122f9b43fe78f /clang/test/Analysis/osobject-retain-release.cpp | |
parent | 79d8105fc80b866358c7175aab9bcd4a3e7ac974 (diff) | |
download | bcm5719-llvm-f50853262723504f681595586b489cf4f7c48816.tar.gz bcm5719-llvm-f50853262723504f681595586b489cf4f7c48816.zip |
[analyzer] Fix a bug in RetainCountDiagnostics while printing a note on mismatched summary in inlined functions
Previously, we were not printing a note at all if at least one of the parameters was not annotated.
rdar://46888422
Differential Revision: https://reviews.llvm.org/D55972
llvm-svn: 349875
Diffstat (limited to 'clang/test/Analysis/osobject-retain-release.cpp')
-rw-r--r-- | clang/test/Analysis/osobject-retain-release.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/Analysis/osobject-retain-release.cpp b/clang/test/Analysis/osobject-retain-release.cpp index c8bc4aeaa0a..2efd20709bb 100644 --- a/clang/test/Analysis/osobject-retain-release.cpp +++ b/clang/test/Analysis/osobject-retain-release.cpp @@ -93,6 +93,15 @@ struct OSMetaClassBase { void escape(void *); bool coin(); +bool os_consume_violation_two_args(OS_CONSUME OSObject *obj, bool extra) { + if (coin()) { // expected-note{{Assuming the condition is false}} + // expected-note@-1{{Taking false branch}} + escape(obj); + return true; + } + return false; // expected-note{{Parameter 'obj' is marked as consuming, but the function does not consume the reference}} +} + bool os_consume_violation(OS_CONSUME OSObject *obj) { if (coin()) { // expected-note{{Assuming the condition is false}} // expected-note@-1{{Taking false branch}} @@ -113,6 +122,13 @@ void use_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}} + 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}} + // expected-warning@-1{{Potential leak of an object stored into 'obj'}} + void use_os_consume_ok() { OSObject *obj = new OSObject; os_consume_ok(obj); |