From: Steve Naroff Date: Wed, 17 Dec 2008 14:13:49 +0000 (+0000) Subject: Fix clang on xcode: Assertion failed: (RecordForDecl &&... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d1117d93cb6cc57db6157478f02ebc0f0a1060c;p=clang Fix clang on xcode: Assertion failed: (RecordForDecl && "lookupFieldDeclForIvar no storage for class"). This was a recent regression caused by r61043 (related to code gen. for ivar references). Fariborz, please review. I have some other concerns related to code generation for ivars that we can discuss later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61134 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 9e803b71e1..12c224501c 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -369,6 +369,8 @@ void ObjCInterfaceDecl::addInstanceVariablesToClass(ObjCIvarDecl **ivars, /// FieldDecl *ObjCInterfaceDecl::lookupFieldDeclForIvar(ASTContext &Context, const ObjCIvarDecl *ivar) { + if (!RecordForDecl) + addRecordToClass(Context); assert(RecordForDecl && "lookupFieldDeclForIvar no storage for class"); DeclarationName Member = ivar->getDeclName(); DeclContext::lookup_result Lookup = RecordForDecl->lookup(Context, Member); diff --git a/test/SemaObjC/interface-layout-2.m b/test/SemaObjC/interface-layout-2.m new file mode 100644 index 0000000000..50dd2f9545 --- /dev/null +++ b/test/SemaObjC/interface-layout-2.m @@ -0,0 +1,16 @@ +// RUN: clang %s -fsyntax-only -verify +@interface A +{ + int ivar; +} +@end + +@interface B : A +- (int)ivar; +@end + +@implementation B +- (int)ivar { + return ivar; +} +@end