diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-17 00:59:30 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-17 00:59:30 +0000 | 
| commit | 18722981e2ae1a95426ea8da2db17254252b35e1 (patch) | |
| tree | 34e2a4214688b21ced8a68267bac8d87244122a8 /clang/lib/Sema/SemaExpr.cpp | |
| parent | 50bd94f9618fe5e1f8510ebb2539b6848a3fcacd (diff) | |
| download | bcm5719-llvm-18722981e2ae1a95426ea8da2db17254252b35e1.tar.gz bcm5719-llvm-18722981e2ae1a95426ea8da2db17254252b35e1.zip | |
Patch to synthesize property ivars on demand as
part of the new property synthesis by default.
wip.
llvm-svn: 108599
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 38 | 
1 files changed, 38 insertions, 0 deletions
| diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5f46a977b12..d798d9d0e5c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1005,6 +1005,38 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,    return true;  } +static ObjCIvarDecl *SynthesizeProvisionalIvar(Sema &SemaRef, +                                               ASTContext &Context, +                                               IdentifierInfo *II, +                                               SourceLocation NameLoc) { +  ObjCMethodDecl *CurMeth = SemaRef.getCurMethodDecl(); +  ObjCInterfaceDecl *IDecl = CurMeth->getClassInterface(); +  if (!IDecl) +    return 0; +  ObjCImplementationDecl *ClassImpDecl = IDecl->getImplementation(); +  assert(ClassImpDecl && "Method not inside @implementation"); +  bool DynamicImplSeen = false; +  ObjCPropertyDecl *property = SemaRef.LookupPropertyDecl(IDecl, II); +  if (!property) +    return 0; +  if (ObjCPropertyImplDecl *PIDecl = ClassImpDecl->FindPropertyImplDecl(II)) +    DynamicImplSeen =  +      (PIDecl->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic); +  if (!DynamicImplSeen) { +    QualType PropType = Context.getCanonicalType(property->getType()); +    ObjCIvarDecl *Ivar = ObjCIvarDecl::Create(Context, ClassImpDecl,  +                                              NameLoc, +                                              II, PropType, /*Dinfo=*/0, +                                              ObjCIvarDecl::Protected, +                                              (Expr *)0, true); +    ClassImpDecl->addDecl(Ivar); +    IDecl->makeDeclVisibleInContext(Ivar, false); +    property->setPropertyIvarDecl(Ivar); +    return Ivar; +  } +  return 0; +} +  Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,                                                 CXXScopeSpec &SS,                                                 UnqualifiedId &Id, @@ -1070,6 +1102,12 @@ Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,        Expr *Ex = E.takeAs<Expr>();        if (Ex) return Owned(Ex); +      // Synthesize ivars lazily +      if (getLangOptions().ObjCNonFragileABI2) { +        if (SynthesizeProvisionalIvar(*this, Context, II, NameLoc)) +          return ActOnIdExpression(S, SS, Id, HasTrailingLParen, +                                   isAddressOfOperand); +      }      }    } | 

