aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-02-09 21:49:50 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-02-09 21:49:50 +0000
commit77e2dde750c271155f35949a6d3c22f8e7d287f8 (patch)
tree8e9985acea46b71687523c21c109d9482e1dc2a8 /lib
parentb9576d9623411946cad8b62f5b3c0f1502b75244 (diff)
Finish implementing property synthesis by default.
(radar 7381956). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/Sema.h3
-rw-r--r--lib/Sema/SemaDeclObjC.cpp22
-rw-r--r--lib/Sema/SemaExpr.cpp17
3 files changed, 27 insertions, 15 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index bf6888762f..8b3b465038 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1363,6 +1363,9 @@ public:
ObjCPropertyDecl *LookupPropertyDecl(const ObjCContainerDecl *CDecl,
IdentifierInfo *II);
+ ObjCIvarDecl *SynthesizeNewPropertyIvar(ObjCInterfaceDecl *IDecl,
+ IdentifierInfo *NameII);
+
/// AtomicPropertySetterGetterRules - This routine enforces the rule (via
/// warning) when atomic property has one but not the other user-declared
/// setter or getter.
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index c0e8219f67..13eeb6c761 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -2293,6 +2293,28 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
return DeclPtrTy::make(PDecl);
}
+ObjCIvarDecl*
+Sema::SynthesizeNewPropertyIvar(ObjCInterfaceDecl *IDecl,
+ IdentifierInfo *NameII) {
+ ObjCIvarDecl *Ivar = 0;
+ ObjCPropertyDecl *Prop = LookupPropertyDecl(IDecl, NameII);
+ if (Prop && !Prop->isInvalidDecl()) {
+ DeclContext *EnclosingContext = cast_or_null<DeclContext>(IDecl);
+ QualType PropType = Context.getCanonicalType(Prop->getType());
+ assert(EnclosingContext &&
+ "null DeclContext for synthesized ivar - SynthesizeNewPropertyIvar");
+ Ivar = ObjCIvarDecl::Create(Context, EnclosingContext,
+ Prop->getLocation(),
+ NameII, PropType, /*Dinfo=*/0,
+ ObjCIvarDecl::Public,
+ (Expr *)0);
+ Ivar->setLexicalDeclContext(IDecl);
+ IDecl->addDecl(Ivar);
+ Prop->setPropertyIvarDecl(Ivar);
+ }
+ return Ivar;
+}
+
/// ActOnPropertyImplDecl - This routine performs semantic checks and
/// builds the AST node for a property implementation declaration; declared
/// as @synthesize or @dynamic.
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 0da57330ee..044216381c 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1343,22 +1343,9 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
}
}
if (LangOpts.ObjCNonFragileABI2 && LookForIvars && Lookup.empty()) {
- // Find property name matching variable name.
- ObjCPropertyDecl *Prop = LookupPropertyDecl(IFace, II);
- if (Prop && !Prop->isInvalidDecl()) {
- DeclContext *EnclosingContext = cast_or_null<DeclContext>(IFace);
- QualType PropType = Context.getCanonicalType(Prop->getType());
- assert(EnclosingContext &&
- "null DeclContext for synthesized ivar - LookupInObjCMethod");
- ObjCIvarDecl *Ivar = ObjCIvarDecl::Create(Context, EnclosingContext,
- Prop->getLocation(),
- II, PropType, /*Dinfo=*/0,
- ObjCIvarDecl::Public,
- (Expr *)0);
- Ivar->setLexicalDeclContext(IFace);
- IFace->addDecl(Ivar);
+ ObjCIvarDecl *Ivar = SynthesizeNewPropertyIvar(IFace, II);
+ if (Ivar)
return LookupInObjCMethod(Lookup, S, II, AllowBuiltinCreation);
- }
}
// Sentinel value saying that we didn't do anything special.
return Owned((Expr*) 0);