[cfe-commits] r96739 - /cfe/trunk/lib/AST/ASTImporter.cpp
Douglas Gregor
dgregor at apple.com
Sun Feb 21 10:24:45 PST 2010
Author: dgregor
Date: Sun Feb 21 12:24:45 2010
New Revision: 96739
URL: http://llvm.org/viewvc/llvm-project?rev=96739&view=rev
Log:
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.
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=96739&r1=96738&r2=96739&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Sun Feb 21 12:24:45 2010
@@ -81,6 +81,7 @@
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 @@
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 @@
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 @@
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 @@
}
// 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 @@
}
// 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 @@
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()) {
More information about the cfe-commits
mailing list