diff options
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 25 | ||||
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 6 | ||||
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 35 | ||||
-rw-r--r-- | clang/lib/AST/DeclPrinter.cpp | 6 | ||||
-rw-r--r-- | clang/lib/AST/DumpXML.cpp | 3 |
5 files changed, 26 insertions, 49 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 8b8308a0f4b..b6e3e621d56 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -3529,25 +3529,14 @@ Decl *ASTNodeImporter::VisitObjCClassDecl(ObjCClassDecl *D) { // Import the location of this declaration. SourceLocation Loc = Importer.Import(D->getLocation()); - - SmallVector<ObjCInterfaceDecl *, 4> Interfaces; - SmallVector<SourceLocation, 4> Locations; - for (ObjCClassDecl::iterator From = D->begin(), FromEnd = D->end(); - From != FromEnd; ++From) { - ObjCInterfaceDecl *ToIface - = cast_or_null<ObjCInterfaceDecl>(Importer.Import(From->getInterface())); - if (!ToIface) - continue; - - Interfaces.push_back(ToIface); - Locations.push_back(Importer.Import(From->getLocation())); - } - + ObjCClassDecl::ObjCClassRef *From = D->getForwardDecl(); + ObjCInterfaceDecl *ToIface + = cast_or_null<ObjCInterfaceDecl>(Importer.Import(From->getInterface())); ObjCClassDecl *ToClass = ObjCClassDecl::Create(Importer.getToContext(), DC, - Loc, - Interfaces.data(), - Locations.data(), - Interfaces.size()); + Loc, + ToIface, + Importer.Import(From->getLocation())); + ToClass->setLexicalDeclContext(LexicalDC); LexicalDC->addDecl(ToClass); Importer.Imported(D, ToClass); diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index cb5846fc838..27e437c4a3e 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1030,12 +1030,10 @@ void DeclContext::buildLookup(DeclContext *DCtx) { if (D->getDeclContext() == DCtx) makeDeclVisibleInContextImpl(ND); - // Insert any forward-declared Objective-C interfaces into the lookup + // Insert any forward-declared Objective-C interface into the lookup // data structure. if (ObjCClassDecl *Class = dyn_cast<ObjCClassDecl>(*D)) - for (ObjCClassDecl::iterator I = Class->begin(), IEnd = Class->end(); - I != IEnd; ++I) - makeDeclVisibleInContextImpl(I->getInterface()); + makeDeclVisibleInContextImpl(Class->getForwardInterfaceDecl()); // If this declaration is itself a transparent declaration context or // inline namespace, add its members (recursively). diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 813501f1ac9..367e6a66a43 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -851,36 +851,31 @@ ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel, //===----------------------------------------------------------------------===// ObjCClassDecl::ObjCClassDecl(DeclContext *DC, SourceLocation L, - ObjCInterfaceDecl *const *Elts, - const SourceLocation *Locs, - unsigned nElts, + ObjCInterfaceDecl *const Elt, + const SourceLocation Loc, ASTContext &C) : Decl(ObjCClass, DC, L) { - setClassList(C, Elts, Locs, nElts); -} - -void ObjCClassDecl::setClassList(ASTContext &C, ObjCInterfaceDecl*const*List, - const SourceLocation *Locs, unsigned Num) { - ForwardDecls = (ObjCClassRef*) C.Allocate(sizeof(ObjCClassRef)*Num, - llvm::alignOf<ObjCClassRef>()); - for (unsigned i = 0; i < Num; ++i) - new (&ForwardDecls[i]) ObjCClassRef(List[i], Locs[i]); - - NumDecls = Num; + setClass(C, Elt, Loc); } ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, - ObjCInterfaceDecl *const *Elts, - const SourceLocation *Locs, - unsigned nElts) { - return new (C) ObjCClassDecl(DC, L, Elts, Locs, nElts, C); + ObjCInterfaceDecl *const Elt, + const SourceLocation Loc) { + return new (C) ObjCClassDecl(DC, L, Elt, Loc, C); } +void ObjCClassDecl::setClass(ASTContext &C, ObjCInterfaceDecl*const Cls, + const SourceLocation Loc) { + + ForwardDecl = (ObjCClassRef*) C.Allocate(sizeof(ObjCClassRef), + llvm::alignOf<ObjCClassRef>()); + new (ForwardDecl) ObjCClassRef(Cls, Loc); +} + SourceRange ObjCClassDecl::getSourceRange() const { // FIXME: We should include the semicolon - assert(NumDecls); - return SourceRange(getLocation(), ForwardDecls[NumDecls-1].getLocation()); + return SourceRange(getLocation(), ForwardDecl->getLocation()); } //===----------------------------------------------------------------------===// diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index a1aff5d411c..3a95d1342f7 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -812,11 +812,7 @@ void DeclPrinter::VisitClassTemplateDecl(ClassTemplateDecl *D) { void DeclPrinter::VisitObjCClassDecl(ObjCClassDecl *D) { Out << "@class "; - for (ObjCClassDecl::iterator I = D->begin(), E = D->end(); - I != E; ++I) { - if (I != D->begin()) Out << ", "; - Out << I->getInterface(); - } + Out << D->getForwardInterfaceDecl(); } void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) { diff --git a/clang/lib/AST/DumpXML.cpp b/clang/lib/AST/DumpXML.cpp index dd0147c5a34..2568adaa5a4 100644 --- a/clang/lib/AST/DumpXML.cpp +++ b/clang/lib/AST/DumpXML.cpp @@ -742,8 +742,7 @@ struct XMLDumper : public XMLDeclVisitor<XMLDumper>, // ObjCClassDecl void visitObjCClassDeclChildren(ObjCClassDecl *D) { - for (ObjCClassDecl::iterator I = D->begin(), E = D->end(); I != E; ++I) - visitDeclRef(I->getInterface()); + visitDeclRef(D->getForwardInterfaceDecl()); } // ObjCInterfaceDecl |