@@ -30,7 +30,7 @@ namespace {
30
30
31
31
class ForwardDeclChecker : public Checker <check::ASTDecl<TranslationUnitDecl>> {
32
32
BugType Bug;
33
- mutable BugReporter *BR;
33
+ mutable BugReporter *BR = nullptr ;
34
34
mutable RetainTypeChecker RTC;
35
35
mutable llvm::DenseSet<const Type *> SystemTypes;
36
36
@@ -107,6 +107,7 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
107
107
void visitTypedef (const TypedefDecl *TD) const {
108
108
RTC.visitTypedef (TD);
109
109
auto QT = TD->getUnderlyingType ().getCanonicalType ();
110
+ assert (BR && " expected nonnull BugReporter" );
110
111
if (BR->getSourceManager ().isInSystemHeader (TD->getBeginLoc ())) {
111
112
if (auto *Type = QT.getTypePtrOrNull ())
112
113
SystemTypes.insert (Type);
@@ -146,6 +147,7 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
146
147
if (Kind != TagTypeKind::Struct && Kind != TagTypeKind::Class)
147
148
return ;
148
149
150
+ assert (BR && " expected nonnull BugReporter" );
149
151
if (BR->getSourceManager ().isInSystemHeader (RDLocation))
150
152
return ;
151
153
@@ -177,6 +179,7 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
177
179
}
178
180
179
181
void visitVarDecl (const VarDecl *V, const Decl *DeclWithIssue) const {
182
+ assert (BR && " expected nonnull BugReporter" );
180
183
if (BR->getSourceManager ().isInSystemHeader (V->getBeginLoc ()))
181
184
return ;
182
185
@@ -194,6 +197,7 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
194
197
}
195
198
196
199
void visitCallExpr (const CallExpr *CE, const Decl *DeclWithIssue) const {
200
+ assert (BR && " expected nonnull BugReporter" );
197
201
if (BR->getSourceManager ().isInSystemHeader (CE->getExprLoc ()))
198
202
return ;
199
203
@@ -211,6 +215,7 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
211
215
212
216
void visitConstructExpr (const CXXConstructExpr *CE,
213
217
const Decl *DeclWithIssue) const {
218
+ assert (BR && " expected nonnull BugReporter" );
214
219
if (BR->getSourceManager ().isInSystemHeader (CE->getExprLoc ()))
215
220
return ;
216
221
@@ -228,6 +233,7 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
228
233
229
234
void visitObjCMessageExpr (const ObjCMessageExpr *E,
230
235
const Decl *DeclWithIssue) const {
236
+ assert (BR && " expected nonnull BugReporter" );
231
237
if (BR->getSourceManager ().isInSystemHeader (E->getExprLoc ()))
232
238
return ;
233
239
@@ -309,6 +315,7 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
309
315
const std::string TypeName = Type.getAsString ();
310
316
Os << Description << " uses a forward declared type '" << TypeName << " '" ;
311
317
318
+ assert (BR && " expected nonnull BugReporter" );
312
319
PathDiagnosticLocation BSLoc (SrcLoc, BR->getSourceManager ());
313
320
auto Report = std::make_unique<BasicBugReport>(Bug, Os.str (), BSLoc);
314
321
Report->addRange (SrcRange);
0 commit comments