Skip to content

Commit

Permalink
Merge pull request #439 from apple/eng/PR-57764169-direct-method-cras…
Browse files Browse the repository at this point in the history
…h-20191106

Also synthesize _cmd and self for properties
  • Loading branch information
MadCoder authored Dec 9, 2019
2 parents 7710e21 + c48855f commit 73634fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions clang/lib/Sema/SemaObjCProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2500,6 +2500,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
// A user declared getter will be synthesize when @synthesize of
// the property with the same name is seen in the @implementation
GetterMethod->setPropertyAccessor(true);

GetterMethod->createImplicitParams(Context,
GetterMethod->getClassInterface());
property->setGetterMethodDecl(GetterMethod);

// Skip setter if property is read-only.
Expand Down Expand Up @@ -2574,6 +2577,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
// A user declared setter will be synthesize when @synthesize of
// the property with the same name is seen in the @implementation
SetterMethod->setPropertyAccessor(true);

SetterMethod->createImplicitParams(Context,
SetterMethod->getClassInterface());
property->setSetterMethodDecl(SetterMethod);
}
// Add any synthesized methods to the global pool. This allows us to
Expand Down
11 changes: 11 additions & 0 deletions clang/test/CodeGenObjC/direct-method.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,14 @@ int useRoot(Root *r) {
// CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[Root intProperty2]"
return [r getInt] + [r intProperty] + [r intProperty2];
}

__attribute__((objc_root_class))
@interface RootDeclOnly
@property(direct, readonly) int intProperty;
@end

int useRootDeclOnly(RootDeclOnly *r) {
// CHECK-LABEL: define i32 @useRootDeclOnly
// CHECK: %{{[^ ]*}} = call i32 bitcast {{.*}} @"\01-[RootDeclOnly intProperty]"
return [r intProperty];
}

0 comments on commit 73634fe

Please sign in to comment.