File tree 2 files changed +12
-2
lines changed
lib/StaticAnalyzer/Checkers 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> {
36
36
mutable IdentifierInfo *NSStringII = nullptr ;
37
37
mutable IdentifierInfo *CFStringRefII = nullptr ;
38
38
mutable IdentifierInfo *CFBooleanRefII = nullptr ;
39
+ mutable IdentifierInfo *CFNullRefII = nullptr ;
39
40
40
41
public:
41
42
NonnullGlobalConstantsChecker () {}
@@ -61,6 +62,7 @@ void NonnullGlobalConstantsChecker::initIdentifierInfo(ASTContext &Ctx) const {
61
62
NSStringII = &Ctx.Idents .get (" NSString" );
62
63
CFStringRefII = &Ctx.Idents .get (" CFStringRef" );
63
64
CFBooleanRefII = &Ctx.Idents .get (" CFBooleanRef" );
65
+ CFNullRefII = &Ctx.Idents .get (" CFNullRef" );
64
66
}
65
67
66
68
// / Add an assumption that const string-like globals are non-null.
@@ -136,7 +138,7 @@ bool NonnullGlobalConstantsChecker::isNonnullType(QualType Ty) const {
136
138
T->getInterfaceDecl ()->getIdentifier () == NSStringII;
137
139
} else if (auto *T = dyn_cast<TypedefType>(Ty)) {
138
140
IdentifierInfo* II = T->getDecl ()->getIdentifier ();
139
- return II == CFStringRefII || II == CFBooleanRefII;
141
+ return II == CFStringRefII || II == CFBooleanRefII || II == CFNullRefII ;
140
142
}
141
143
return false ;
142
144
}
Original file line number Diff line number Diff line change 7
7
8
8
@class NSString ;
9
9
typedef 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 ;
11
15
12
16
// Global NSString* is non-null.
13
17
extern NSString *const StringConstGlobal;
@@ -113,3 +117,7 @@ void testNonnullNonconstCFString() {
113
117
void testNonnullNonnullCFString () {
114
118
clang_analyzer_eval (str4); // expected-warning{{TRUE}}
115
119
}
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