File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -741,13 +741,17 @@ static Stmt *createObjCPropertyGetter(ASTContext &Ctx,
741
741
// First, find the backing ivar.
742
742
const ObjCIvarDecl *IVar = nullptr ;
743
743
744
- // Property accessor stubs sometimes do not correspond to any property.
744
+ // Property accessor stubs sometimes do not correspond to any property decl
745
+ // in the current interface (but in a superclass). They still have a
746
+ // corresponding property impl decl in this case.
745
747
if (MD->isSynthesizedAccessorStub ()) {
746
748
const ObjCInterfaceDecl *IntD = MD->getClassInterface ();
747
749
const ObjCImplementationDecl *ImpD = IntD->getImplementation ();
748
- for (const auto *V: ImpD->ivars ()) {
749
- if (V->getName () == MD->getSelector ().getNameForSlot (0 ))
750
- IVar = V;
750
+ for (const auto *PI: ImpD->property_impls ()) {
751
+ if (const ObjCPropertyDecl *P = PI->getPropertyDecl ()) {
752
+ if (P->getGetterName () == MD->getSelector ())
753
+ IVar = P->getPropertyIvarDecl ();
754
+ }
751
755
}
752
756
}
753
757
Original file line number Diff line number Diff line change @@ -1049,6 +1049,8 @@ - (NSObject *)getShadowedIvar;
1049
1049
- (void )clearShadowedIvar ;
1050
1050
- (NSObject *)getShadowedProp ;
1051
1051
- (void )clearShadowedProp ;
1052
+
1053
+ @property (assign ) NSObject *o2;
1052
1054
@end
1053
1055
1054
1056
@implementation Shadowed
@@ -1078,12 +1080,18 @@ @implementation Shadowing
1078
1080
@synthesize o;
1079
1081
1080
1082
-(void )testPropertyShadowing {
1081
- NSObject *oo = self.o ;
1083
+ NSObject *oo = self.o ; // no-crash
1082
1084
clang_analyzer_eval (self.o == oo); // expected-warning{{TRUE}}
1083
1085
clang_analyzer_eval ([self getShadowedIvar ] == oo); // expected-warning{{UNKNOWN}}
1084
1086
[self clearShadowedIvar ];
1085
1087
clang_analyzer_eval (self.o == oo); // expected-warning{{TRUE}}
1086
1088
clang_analyzer_eval ([self getShadowedIvar ] == oo); // expected-warning{{UNKNOWN}}
1087
1089
clang_analyzer_eval ([self getShadowedIvar ] == nil ); // expected-warning{{TRUE}}
1088
1090
}
1091
+
1092
+ @synthesize o2 = ooo2;
1093
+
1094
+ -(void )testPropertyShadowingWithExplicitIvar {
1095
+ NSObject *oo2 = self.o2 ; // no-crash
1096
+ }
1089
1097
@end
You can’t perform that action at this time.
0 commit comments