Adds synthesize ivars to DeclContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73000 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 2500a8f..5d47516 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1996,10 +1996,15 @@
ObjCInterfaceDecl *ClassDeclared;
Ivar = IDecl->lookupInstanceVariable(Context, PropertyIvar, ClassDeclared);
if (!Ivar) {
- Ivar = ObjCIvarDecl::Create(Context, CurContext, PropertyLoc,
+ DeclContext *EnclosingContext = cast_or_null<DeclContext>(IDecl);
+ assert(EnclosingContext &&
+ "null DeclContext for synthesized ivar - ActOnPropertyImplDecl");
+ Ivar = ObjCIvarDecl::Create(Context, EnclosingContext, PropertyLoc,
PropertyIvar, PropType,
ObjCIvarDecl::Public,
(Expr *)0);
+ Ivar->setLexicalDeclContext(IDecl);
+ IDecl->addDecl(Context, Ivar);
property->setPropertyIvarDecl(Ivar);
if (!getLangOptions().ObjCNonFragileABI)
Diag(PropertyLoc, diag::error_missing_property_ivar_decl) << PropertyId;