Push nested-name-specifier source location information into using directives.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126489 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index d7e389e..73fe117 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -841,8 +841,10 @@
   // UsingDirectiveDecl's are not really NamedDecl's, and all have same name.
   // We want to keep it, unless it nominates same namespace.
   if (getKind() == Decl::UsingDirective) {
-    return cast<UsingDirectiveDecl>(this)->getNominatedNamespace() ==
-           cast<UsingDirectiveDecl>(OldD)->getNominatedNamespace();
+    return cast<UsingDirectiveDecl>(this)->getNominatedNamespace()
+             ->getOriginalNamespace() ==
+           cast<UsingDirectiveDecl>(OldD)->getNominatedNamespace()
+             ->getOriginalNamespace();
   }
 
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index a1d6cc3..aafe480e 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -1267,15 +1267,14 @@
 UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC,
                                                SourceLocation L,
                                                SourceLocation NamespaceLoc,
-                                               SourceRange QualifierRange,
-                                               NestedNameSpecifier *Qualifier,
+                                           NestedNameSpecifierLoc QualifierLoc,
                                                SourceLocation IdentLoc,
                                                NamedDecl *Used,
                                                DeclContext *CommonAncestor) {
   if (NamespaceDecl *NS = dyn_cast_or_null<NamespaceDecl>(Used))
     Used = NS->getOriginalNamespace();
-  return new (C) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierRange,
-                                    Qualifier, IdentLoc, Used, CommonAncestor);
+  return new (C) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierLoc,
+                                    IdentLoc, Used, CommonAncestor);
 }
 
 NamespaceDecl *UsingDirectiveDecl::getNominatedNamespace() {
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp
index 0689ae1..6f1ec05 100644
--- a/lib/AST/NestedNameSpecifier.cpp
+++ b/lib/AST/NestedNameSpecifier.cpp
@@ -321,8 +321,11 @@
 }
 
 SourceRange NestedNameSpecifierLoc::getSourceRange() const {
+  if (!Qualifier)
+    return SourceRange();
+  
   NestedNameSpecifierLoc First = *this;
-  while (NestedNameSpecifierLoc Prefix= First.getPrefix())
+  while (NestedNameSpecifierLoc Prefix = First.getPrefix())
     First = Prefix;
   
   return SourceRange(First.getLocalSourceRange().getBegin(), 
@@ -330,6 +333,9 @@
 }
 
 SourceRange NestedNameSpecifierLoc::getLocalSourceRange() const {
+  if (!Qualifier)
+    return SourceRange();
+  
   unsigned Offset = getDataLength(Qualifier->getPrefix());
   switch (Qualifier->getKind()) {
   case NestedNameSpecifier::Global: