From e7aa27a826f0b353713df6bfa0715818db8cde74 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 20 Dec 2011 15:50:13 +0000 Subject: [PATCH] When performing layout for an Objective-C class, make sure to dig out the definition of that class. Fixes PR11613 / . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146976 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/RecordLayoutBuilder.cpp | 4 +++- test/CodeGenObjC/forward-class-impl-metadata.m | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index a47bd4afb4..43dee104ba 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -2161,7 +2161,9 @@ const CXXMethodDecl *ASTContext::getKeyFunction(const CXXRecordDecl *RD) { const ASTRecordLayout & ASTContext::getObjCLayout(const ObjCInterfaceDecl *D, const ObjCImplementationDecl *Impl) const { - assert(D->isThisDeclarationADefinition() && "Invalid interface decl!"); + // Retrieve the definition + D = D->getDefinition(); + assert(D && D->isThisDeclarationADefinition() && "Invalid interface decl!"); // Look up this layout, if already laid out, return what we have. ObjCContainerDecl *Key = diff --git a/test/CodeGenObjC/forward-class-impl-metadata.m b/test/CodeGenObjC/forward-class-impl-metadata.m index e9e08589d1..371abf2ade 100644 --- a/test/CodeGenObjC/forward-class-impl-metadata.m +++ b/test/CodeGenObjC/forward-class-impl-metadata.m @@ -39,3 +39,9 @@ int f0(A *a) { @implementation A @synthesize p0 = _p0; @end + +@interface B +@end +@class B; +@implementation B +@end -- 2.40.0