Author: dcoughlin Date: Tue Jan 10 19:02:34 2017 New Revision: 291635 URL: http://llvm.org/viewvc/llvm-project?rev=291635&view=rev Log: [analyzer] Fix crash in body farm for getter without implicit self.
Fix a crash in body farm when synthesizing a getter for a property synthesized for a property declared in a protocol on a class extension that shadows a declaration of the property in a category. In this case, Sema doesn't fill in the implicit 'self' parameter for the getter in the category, which leads to a crash when trying to synthesize the getter for it. To avoid the crash, skip getter synthesis in body farm if the self parameter is not filled int. rdar://problem/29938138 Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp cfe/trunk/test/Analysis/properties.m Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=291635&r1=291634&r2=291635&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/BodyFarm.cpp (original) +++ cfe/trunk/lib/Analysis/BodyFarm.cpp Tue Jan 10 19:02:34 2017 @@ -467,6 +467,8 @@ static Stmt *createObjCPropertyGetter(AS ASTMaker M(Ctx); const VarDecl *selfVar = Prop->getGetterMethodDecl()->getSelfDecl(); + if (!selfVar) + return nullptr; Expr *loadedIVar = M.makeObjCIvarRef( Modified: cfe/trunk/test/Analysis/properties.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/properties.m?rev=291635&r1=291634&r2=291635&view=diff ============================================================================== --- cfe/trunk/test/Analysis/properties.m (original) +++ cfe/trunk/test/Analysis/properties.m Tue Jan 10 19:02:34 2017 @@ -315,6 +315,32 @@ void testConsistencyAssign(Person *p) { } @end +__attribute__((objc_root_class)) +@interface ClassWithPrivatePropertyInClassExtensionWithProtocolShadowingCategory +@end + +@protocol HasStuff +@property (nonatomic, readonly) int stuffProperty; +@end + +@interface ClassWithPrivatePropertyInClassExtensionWithProtocolShadowingCategory (Private) +@property (nonatomic, readonly) int stuffProperty; +@end + +@interface ClassWithPrivatePropertyInClassExtensionWithProtocolShadowingCategory (Internal) <HasStuff> +@end + +@interface ClassWithPrivatePropertyInClassExtensionWithProtocolShadowingCategory() <HasStuff> +@end + +@implementation ClassWithPrivatePropertyInClassExtensionWithProtocolShadowingCategory +@synthesize stuffProperty = _stuffProperty; + +-(void)foo { + (void)self.stuffProperty; +} +@end + //------ // Setter ivar invalidation. //------ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits