File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
lib/StaticAnalyzer/Checkers Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ class NonnullGlobalConstantsChecker : public Checker<check::Location> {
3636 mutable IdentifierInfo *NSStringII = nullptr ;
3737 mutable IdentifierInfo *CFStringRefII = nullptr ;
3838 mutable IdentifierInfo *CFBooleanRefII = nullptr ;
39+ mutable IdentifierInfo *CFNullRefII = nullptr ;
3940
4041public:
4142 NonnullGlobalConstantsChecker () {}
@@ -61,6 +62,7 @@ void NonnullGlobalConstantsChecker::initIdentifierInfo(ASTContext &Ctx) const {
6162 NSStringII = &Ctx.Idents .get (" NSString" );
6263 CFStringRefII = &Ctx.Idents .get (" CFStringRef" );
6364 CFBooleanRefII = &Ctx.Idents .get (" CFBooleanRef" );
65+ CFNullRefII = &Ctx.Idents .get (" CFNullRef" );
6466}
6567
6668// / Add an assumption that const string-like globals are non-null.
@@ -136,7 +138,7 @@ bool NonnullGlobalConstantsChecker::isNonnullType(QualType Ty) const {
136138 T->getInterfaceDecl ()->getIdentifier () == NSStringII;
137139 } else if (auto *T = dyn_cast<TypedefType>(Ty)) {
138140 IdentifierInfo* II = T->getDecl ()->getIdentifier ();
139- return II == CFStringRefII || II == CFBooleanRefII;
141+ return II == CFStringRefII || II == CFBooleanRefII || II == CFNullRefII ;
140142 }
141143 return false ;
142144}
Original file line number Diff line number Diff line change 77
88@class NSString ;
99typedef const struct __CFString *CFStringRef;
10- typedef const struct __CFBoolean * CFBooleanRef;
10+ typedef const struct __CFBoolean *CFBooleanRef;
11+
12+ #define CF_BRIDGED_TYPE (T ) __attribute__((objc_bridge(T)))
13+ typedef const struct CF_BRIDGED_TYPE (NSNull ) __CFNull *CFNullRef;
14+ extern const CFNullRef kCFNull ;
1115
1216// Global NSString* is non-null.
1317extern NSString *const StringConstGlobal;
@@ -113,3 +117,7 @@ void testNonnullNonconstCFString() {
113117void testNonnullNonnullCFString () {
114118 clang_analyzer_eval (str4); // expected-warning{{TRUE}}
115119}
120+
121+ void test_kCFNull () {
122+ clang_analyzer_eval (kCFNull ); // expected-warning{{TRUE}}
123+ }
You can’t perform that action at this time.
0 commit comments