[analyzer] LocalizationChecker: Fix a crash on synthesized accessor stubs.

The checker was trying to analyze the body of every method in Objective-C
@implementation clause but the sythesized accessor stubs that were introduced
into it by 2073dd2d have no bodies.
This commit is contained in:
Artem Dergachev 2019-12-11 11:03:38 -08:00
parent 2b3f2071ec
commit b01012b7c8
2 changed files with 12 additions and 1 deletions

View File

@ -1077,7 +1077,10 @@ void EmptyLocalizationContextChecker::checkASTDecl(
AnalysisDeclContext *DCtx = Mgr.getAnalysisDeclContext(M); AnalysisDeclContext *DCtx = Mgr.getAnalysisDeclContext(M);
const Stmt *Body = M->getBody(); const Stmt *Body = M->getBody();
assert(Body); if (!Body) {
assert(M->isSynthesizedAccessorStub());
continue;
}
MethodCrawler MC(M->getCanonicalDecl(), BR, this, Mgr, DCtx); MethodCrawler MC(M->getCanonicalDecl(), BR, this, Mgr, DCtx);
MC.VisitStmt(Body); MC.VisitStmt(Body);

View File

@ -293,3 +293,11 @@ NSString *ForceLocalized(NSString *str) { return str; }
takesLocalizedString(@"not localized"); // expected-warning {{User-facing text should use localized string macro}} takesLocalizedString(@"not localized"); // expected-warning {{User-facing text should use localized string macro}}
} }
@end @end
@interface SynthesizedAccessors : NSObject
@property (assign) NSObject *obj;
@end
@implementation SynthesizedAccessors
// no-crash
@end