Simplify addRecordToClass, it is not legal to call it on a forward

declaration now.

llvm-svn: 69799
This commit is contained in:
Daniel Dunbar 2009-04-22 10:56:29 +00:00
parent ab4c600e8b
commit 24579842a5
1 changed files with 6 additions and 15 deletions

View File

@ -644,29 +644,20 @@ void ASTContext::CollectObjCIvars(const ObjCInterfaceDecl *OI,
/// ivars and all those inherited. /// ivars and all those inherited.
/// ///
const RecordDecl *ASTContext::addRecordToClass(const ObjCInterfaceDecl *D) { const RecordDecl *ASTContext::addRecordToClass(const ObjCInterfaceDecl *D) {
assert(!D->isForwardDecl() && "Invalid decl!");
// FIXME: The only client relying on this working in the presence of // FIXME: The only client relying on this working in the presence of
// forward declarations is IRgen, which should not need it. Fix // forward declarations is IRgen, which should not need it. Fix
// and simplify this code. // and simplify this code.
RecordDecl *&RD = ASTRecordForInterface[D]; RecordDecl *&RD = ASTRecordForInterface[D];
if (RD) { if (RD)
// If we have a record decl already and it is either a definition or if 'D' return RD;
// is still a forward declaration, return it.
if (RD->isDefinition() || D->isForwardDecl())
return RD;
}
// If D is a forward declaration, then just make a forward struct decl.
if (D->isForwardDecl())
return RD = RecordDecl::Create(*this, TagDecl::TK_struct, 0,
D->getLocation(),
D->getIdentifier());
llvm::SmallVector<FieldDecl*, 32> RecFields; llvm::SmallVector<FieldDecl*, 32> RecFields;
CollectObjCIvars(D, RecFields); CollectObjCIvars(D, RecFields);
if (RD == 0) RD = RecordDecl::Create(*this, TagDecl::TK_struct, 0, D->getLocation(),
RD = RecordDecl::Create(*this, TagDecl::TK_struct, 0, D->getLocation(), D->getIdentifier());
D->getIdentifier());
/// FIXME! Can do collection of ivars and adding to the record while /// FIXME! Can do collection of ivars and adding to the record while
/// doing it. /// doing it.
for (unsigned i = 0, e = RecFields.size(); i != e; ++i) { for (unsigned i = 0, e = RecFields.size(); i != e; ++i) {