summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp3
-rw-r--r--clang/test/Analysis/ObjCPropertiesSyntaxChecks.m7
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
index b9857e51f3e..dfd2c9afe7f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
@@ -58,8 +58,7 @@ void ObjCPropertyChecker::checkCopyMutable(const ObjCPropertyDecl *D,
if (const ObjCInterfaceDecl *IntD =
dyn_cast<ObjCInterfaceDecl>(D->getDeclContext())) {
ImplD = IntD->getImplementation();
- } else {
- const ObjCCategoryDecl *CatD = cast<ObjCCategoryDecl>(D->getDeclContext());
+ } else if (auto *CatD = dyn_cast<ObjCCategoryDecl>(D->getDeclContext())) {
ImplD = CatD->getClassInterface()->getImplementation();
}
diff --git a/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m b/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m
index 5c642c58173..1c3ddbd1f6f 100644
--- a/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m
+++ b/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m
@@ -59,3 +59,10 @@
@interface IWithoutImpl : NSObject {}
@property(copy) NSMutableString *mutableStr; // no-warning
@end
+
+@protocol SomeProtocol
+// Don't warn on protocol properties because it is possible to
+// conform to them correctly; it is only synthesized setters that
+// that are definitely incorrect.
+@property (copy) NSMutableString *myProp; // no-crash // no-warning
+@end
OpenPOWER on IntegriCloud