r296562 - [Analyzer] Fix crash in ObjCPropertyChecker on protocol property
Devin Coughlin via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 28 17:47:37 PST 2017
Author: dcoughlin
Date: Tue Feb 28 19:47:37 2017
New Revision: 296562
URL: http://llvm.org/viewvc/llvm-project?rev=296562&view=rev
Log:
[Analyzer] Fix crash in ObjCPropertyChecker on protocol property
Fix a crash in the ObjCPropertyChecker when analyzing a 'copy' property of an
NSMutable* type in a protocol.
rdar://problem/30766684
Differential Revision: https://reviews.llvm.org/D30482
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp?rev=296562&r1=296561&r2=296562&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp Tue Feb 28 19:47:37 2017
@@ -58,8 +58,7 @@ void ObjCPropertyChecker::checkCopyMutab
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();
}
Modified: cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m?rev=296562&r1=296561&r2=296562&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m (original)
+++ cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m Tue Feb 28 19:47:37 2017
@@ -59,3 +59,10 @@
@interface IWithoutImpl : NSObject {}
@property(copy) NSMutableString *mutableStr; // no-warning
@end
+
+ at 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.
+ at property (copy) NSMutableString *myProp; // no-crash // no-warning
+ at end
More information about the cfe-commits
mailing list