]> granicus.if.org Git - clang/commitdiff
[index] Visit and store information about namespace alias declarations
authorAlex Lorenz <arphaman@gmail.com>
Mon, 15 May 2017 10:56:31 +0000 (10:56 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Mon, 15 May 2017 10:56:31 +0000 (10:56 +0000)
rdar://32195226

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303048 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Index/IndexDecl.cpp
test/Index/Core/index-source.cpp

index e55dea8e7761b269ba281b0cf80d13dd515744f9..203862c46e98bf5dc677bc2262bb405260795595 100644 (file)
@@ -544,6 +544,14 @@ public:
     return true;
   }
 
+  bool VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
+    TRY_DECL(D, IndexCtx.handleDecl(D));
+    IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D);
+    IndexCtx.handleReference(D->getAliasedNamespace(), D->getTargetNameLoc(), D,
+                             D->getLexicalDeclContext());
+    return true;
+  }
+
   bool VisitUsingDecl(const UsingDecl *D) {
     const DeclContext *DC = D->getDeclContext()->getRedeclContext();
     const NamedDecl *Parent = dyn_cast<NamedDecl>(DC);
index 48ca3a9b573b07fcf19f81c72b4210f04640d160..9248e86ff697f27a2136811f951ca5e86f686195 100644 (file)
@@ -323,8 +323,15 @@ void func();
 
 }
 namespace innerAlias = inner;
+// CHECK: [[@LINE-1]]:11 | namespace-alias/C++ | innerAlias | c:@N@ns@NA@innerAlias | <no-cgname> | Decl,RelChild | rel: 1
+// CHECK: [[@LINE-2]]:24 | namespace/C++ | inner | c:@N@ns@N@inner | <no-cgname> | Ref,RelCont | rel: 1
 }
 
+namespace namespaceAlias = ::ns::innerAlias;
+// CHECK: [[@LINE-1]]:11 | namespace-alias/C++ | namespaceAlias | c:@NA@namespaceAlias | <no-cgname> | Decl | rel: 0
+// CHECK: [[@LINE-2]]:30 | namespace/C++ | ns | c:@N@ns | <no-cgname> | Ref,RelCont | rel: 1
+// CHECK: [[@LINE-3]]:34 | namespace-alias/C++ | innerAlias | c:@N@ns@NA@innerAlias | <no-cgname> | Ref,RelCont | rel: 1
+
 void ::ns::inner::func() {
 // CHECK: [[@LINE-1]]:8 | namespace/C++ | ns | c:@N@ns | <no-cgname> | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-2]]:12 | namespace/C++ | inner | c:@N@ns@N@inner | <no-cgname> | Ref,RelCont | rel: 1