]> granicus.if.org Git - clang/commitdiff
Collect the code that imports all of the members of a declaration context into a...
authorDouglas Gregor <dgregor@apple.com>
Sun, 21 Feb 2010 18:24:45 +0000 (18:24 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 21 Feb 2010 18:24:45 +0000 (18:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96739 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTImporter.cpp

index 911f1b8d370766e4bcd6f744d61bdbeb1350b62e..f16bf0138c736a5bb72d04858ae2d917e1181965 100644 (file)
@@ -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()) {