summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-12-11 11:03:38 -0800
committerArtem Dergachev <artem.dergachev@gmail.com>2019-12-11 11:22:36 -0800
commitb01012b7c8a547c0c4f34734a432ee9ba780a6c8 (patch)
tree2295bebd44919d3fc366c85e08c63bd9adaf41ab
parent2b3f2071ec6561c3f10e5291289c47bb3629e354 (diff)
downloadbcm5719-llvm-b01012b7c8a547c0c4f34734a432ee9ba780a6c8.tar.gz
bcm5719-llvm-b01012b7c8a547c0c4f34734a432ee9ba780a6c8.zip
[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.
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp5
-rw-r--r--clang/test/Analysis/localization-aggressive.m8
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
index a81015b6e52..79de1844e74 100644
--- a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -1077,7 +1077,10 @@ void EmptyLocalizationContextChecker::checkASTDecl(
AnalysisDeclContext *DCtx = Mgr.getAnalysisDeclContext(M);
const Stmt *Body = M->getBody();
- assert(Body);
+ if (!Body) {
+ assert(M->isSynthesizedAccessorStub());
+ continue;
+ }
MethodCrawler MC(M->getCanonicalDecl(), BR, this, Mgr, DCtx);
MC.VisitStmt(Body);
diff --git a/clang/test/Analysis/localization-aggressive.m b/clang/test/Analysis/localization-aggressive.m
index 2e273e0c482..145d5e1a531 100644
--- a/clang/test/Analysis/localization-aggressive.m
+++ b/clang/test/Analysis/localization-aggressive.m
@@ -293,3 +293,11 @@ NSString *ForceLocalized(NSString *str) { return str; }
takesLocalizedString(@"not localized"); // expected-warning {{User-facing text should use localized string macro}}
}
@end
+
+@interface SynthesizedAccessors : NSObject
+@property (assign) NSObject *obj;
+@end
+
+@implementation SynthesizedAccessors
+// no-crash
+@end
OpenPOWER on IntegriCloud