[cfe-commits] r130307 - /cfe/trunk/lib/AST/ASTImporter.cpp

Douglas Gregor dgregor at apple.com
Wed Apr 27 09:48:41 PDT 2011


Author: dgregor
Date: Wed Apr 27 11:48:40 2011
New Revision: 130307

URL: http://llvm.org/viewvc/llvm-project?rev=130307&view=rev
Log:
ASTImporter support for NestedNameSpecifier, from Olaf Krzikalla

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=130307&r1=130306&r2=130307&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Wed Apr 27 11:48:40 2011
@@ -4077,7 +4077,46 @@
   if (!FromNNS)
     return 0;
 
-  // FIXME: Implement!
+  NestedNameSpecifier *prefix = Import(FromNNS->getPrefix());
+
+  switch (FromNNS->getKind()) {
+  case NestedNameSpecifier::Identifier:
+    if (IdentifierInfo *II = Import(FromNNS->getAsIdentifier())) {
+      return NestedNameSpecifier::Create(ToContext, prefix, II);
+    }
+    return 0;
+
+  case NestedNameSpecifier::Namespace:
+    if (NamespaceDecl *NS = 
+          cast<NamespaceDecl>(Import(FromNNS->getAsNamespace()))) {
+      return NestedNameSpecifier::Create(ToContext, prefix, NS);
+    }
+    return 0;
+
+  case NestedNameSpecifier::NamespaceAlias:
+    if (NamespaceAliasDecl *NSAD = 
+          cast<NamespaceAliasDecl>(Import(FromNNS->getAsNamespaceAlias()))) {
+      return NestedNameSpecifier::Create(ToContext, prefix, NSAD);
+    }
+    return 0;
+
+  case NestedNameSpecifier::Global:
+    return NestedNameSpecifier::GlobalSpecifier(ToContext);
+
+  case NestedNameSpecifier::TypeSpec:
+  case NestedNameSpecifier::TypeSpecWithTemplate: {
+      QualType T = Import(QualType(FromNNS->getAsType(), 0u));
+      if (!T.isNull()) {
+        bool bTemplate = FromNNS->getKind() == 
+                         NestedNameSpecifier::TypeSpecWithTemplate;
+        return NestedNameSpecifier::Create(ToContext, prefix, 
+                                           bTemplate, T.getTypePtr());
+      }
+    }
+    return 0;
+  }
+
+  llvm_unreachable("Invalid nested name specifier kind");
   return 0;
 }
 





More information about the cfe-commits mailing list