aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-21 18:24:45 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-21 18:24:45 +0000
commit083a821bbd02bbc521275a2f144abe39a6c2745c (patch)
tree53eff7740bde8df141a102aaa16c81f7aa4ced88
parent0cef483f3b9d6a7f9fdbc5910d0a3ed64130e8e1 (diff)
Collect the code that imports all of the members of a declaration context into a single function, ImportDeclContext. Use it rather than explicit loops. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96739 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ASTImporter.cpp41
1 files changed, 14 insertions, 27 deletions
diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
index 911f1b8d37..f16bf0138c 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -81,6 +81,7 @@ namespace {
bool ImportDeclParts(NamedDecl *D, DeclContext *&DC,
DeclContext *&LexicalDC, DeclarationName &Name,
SourceLocation &Loc);
+ void ImportDeclContext(DeclContext *FromDC);
bool IsStructuralMatch(RecordDecl *FromRecord, RecordDecl *ToRecord);
bool IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToRecord);
Decl *VisitDecl(Decl *D);
@@ -1373,6 +1374,14 @@ bool ASTNodeImporter::ImportDeclParts(NamedDecl *D, DeclContext *&DC,
return false;
}
+void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC) {
+ for (DeclContext::decl_iterator From = FromDC->decls_begin(),
+ FromEnd = FromDC->decls_end();
+ From != FromEnd;
+ ++From)
+ Importer.Import(*From);
+}
+
bool ASTNodeImporter::IsStructuralMatch(RecordDecl *FromRecord,
RecordDecl *ToRecord) {
StructuralEquivalenceContext Ctx(Importer.getFromContext(),
@@ -1523,12 +1532,7 @@ Decl *ASTNodeImporter::VisitEnumDecl(EnumDecl *D) {
return 0;
D2->startDefinition();
- for (DeclContext::decl_iterator FromMem = D->decls_begin(),
- FromMemEnd = D->decls_end();
- FromMem != FromMemEnd;
- ++FromMem)
- Importer.Import(*FromMem);
-
+ ImportDeclContext(D);
D2->completeDefinition(T, ToPromotionType);
}
@@ -1655,12 +1659,7 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
if (D->isDefinition()) {
D2->startDefinition();
- for (DeclContext::decl_iterator FromMem = D->decls_begin(),
- FromMemEnd = D->decls_end();
- FromMem != FromMemEnd;
- ++FromMem)
- Importer.Import(*FromMem);
-
+ ImportDeclContext(D);
D2->completeDefinition();
}
@@ -2228,11 +2227,7 @@ Decl *ASTNodeImporter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
}
// Import all of the members of this category.
- for (DeclContext::decl_iterator FromMem = D->decls_begin(),
- FromMemEnd = D->decls_end();
- FromMem != FromMemEnd;
- ++FromMem)
- Importer.Import(*FromMem);
+ ImportDeclContext(D);
// If we have an implementation, import it as well.
if (D->getImplementation()) {
@@ -2302,11 +2297,7 @@ Decl *ASTNodeImporter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
}
// Import all of the members of this protocol.
- for (DeclContext::decl_iterator FromMem = D->decls_begin(),
- FromMemEnd = D->decls_end();
- FromMem != FromMemEnd;
- ++FromMem)
- Importer.Import(*FromMem);
+ ImportDeclContext(D);
return ToProto;
}
@@ -2416,11 +2407,7 @@ Decl *ASTNodeImporter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
Importer.Import(FromCat);
// Import all of the members of this class.
- for (DeclContext::decl_iterator FromMem = D->decls_begin(),
- FromMemEnd = D->decls_end();
- FromMem != FromMemEnd;
- ++FromMem)
- Importer.Import(*FromMem);
+ ImportDeclContext(D);
// If we have an @implementation, import it as well.
if (D->getImplementation()) {