diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2019-07-01 23:02:14 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2019-07-01 23:02:14 +0000 |
| commit | 512f4838c47c5bab13d8bb0eabc01d64222825ae (patch) | |
| tree | 254edeea96759e115a9e20b02bcae713b432567c /clang/test/Analysis | |
| parent | 35fdec1b54c6a8b1ca7bee542836abf29c75a85d (diff) | |
| download | bcm5719-llvm-512f4838c47c5bab13d8bb0eabc01d64222825ae.tar.gz bcm5719-llvm-512f4838c47c5bab13d8bb0eabc01d64222825ae.zip | |
[analyzer] NonnullGlobalConstants: Don't be confused by a _Nonnull attribute.
The NonnullGlobalConstants checker models the rule "it doesn't make sense
to make a constant global pointer and initialize it to null"; it makes sure
that whatever it's initialized with is known to be non-null.
Ironically, annotating the type of the pointer as _Nonnull breaks the checker.
Fix handling of the _Nonnull annotation so that it was instead one more reason
to believe that the value is non-null.
Differential Revision: https://reviews.llvm.org/D63956
llvm-svn: 364869
Diffstat (limited to 'clang/test/Analysis')
| -rw-r--r-- | clang/test/Analysis/nonnull-global-constants.mm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/Analysis/nonnull-global-constants.mm b/clang/test/Analysis/nonnull-global-constants.mm index 7900b9dd128..9e1a588ba47 100644 --- a/clang/test/Analysis/nonnull-global-constants.mm +++ b/clang/test/Analysis/nonnull-global-constants.mm @@ -101,3 +101,15 @@ extern CFBooleanRef kBoolMutable; void testNonnullNonconstBool() { clang_analyzer_eval(kBoolMutable); // expected-warning{{UNKNOWN}} } + +// If it's annotated as nonnull, it doesn't even need to be const. +extern CFStringRef _Nonnull str3; +void testNonnullNonconstCFString() { + clang_analyzer_eval(str3); // expected-warning{{TRUE}} +} + +// This one's nonnull for two reasons. +extern const CFStringRef _Nonnull str4; +void testNonnullNonnullCFString() { + clang_analyzer_eval(str4); // expected-warning{{TRUE}} +} |

