Index: cfe/trunk/lib/Index/IndexDecl.cpp =================================================================== --- cfe/trunk/lib/Index/IndexDecl.cpp +++ cfe/trunk/lib/Index/IndexDecl.cpp @@ -580,9 +580,10 @@ } bool VisitUsingDecl(const UsingDecl *D) { + IndexCtx.handleDecl(D); + const DeclContext *DC = D->getDeclContext()->getRedeclContext(); const NamedDecl *Parent = dyn_cast(DC); - IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent, D->getLexicalDeclContext()); for (const auto *I : D->shadows()) Index: cfe/trunk/lib/Index/IndexSymbol.cpp =================================================================== --- cfe/trunk/lib/Index/IndexSymbol.cpp +++ cfe/trunk/lib/Index/IndexSymbol.cpp @@ -316,6 +316,10 @@ Info.Lang = SymbolLanguage::CXX; Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic; break; + case Decl::Using: + Info.Kind = SymbolKind::Using; + Info.Lang = SymbolLanguage::CXX; + break; case Decl::Binding: Info.Kind = SymbolKind::Variable; Info.Lang = SymbolLanguage::CXX; Index: cfe/trunk/lib/Index/USRGeneration.cpp =================================================================== --- cfe/trunk/lib/Index/USRGeneration.cpp +++ cfe/trunk/lib/Index/USRGeneration.cpp @@ -111,7 +111,12 @@ } void VisitUsingDecl(const UsingDecl *D) { - IgnoreResults = true; + VisitDeclContext(D->getDeclContext()); + Out << "@UD@"; + + bool EmittedDeclName = !EmitDeclName(D); + assert(EmittedDeclName && "EmitDeclName can not fail for UsingDecls"); + (void)EmittedDeclName; } bool ShouldGenerateLocation(const NamedDecl *D); Index: cfe/trunk/test/Index/usrs.cpp =================================================================== --- cfe/trunk/test/Index/usrs.cpp +++ cfe/trunk/test/Index/usrs.cpp @@ -158,7 +158,7 @@ // CHECK: usrs.cpp c:@NA@foo_alias // CHECK-NOT: foo // CHECK: usrs.cpp c:@NA@foo_alias2 -// CHECK-NOT: ClsB +// CHECK: usrs.cpp c:@UD@ClsB Extent=[64:1 - 64:16] // CHECK: usrs.cpp c:@NA@foo_alias3 // CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2] // CHECK: usrs.cpp c:usrs.cpp@aN@S@RDar9371763_Foo Extent=[69:1 - 72:2] Index: cfe/trunk/unittests/Index/IndexTests.cpp =================================================================== --- cfe/trunk/unittests/Index/IndexTests.cpp +++ cfe/trunk/unittests/Index/IndexTests.cpp @@ -57,6 +57,7 @@ std::string QName; Position WrittenPos; Position DeclPos; + SymbolInfo SymInfo; // FIXME: add more information. }; @@ -78,6 +79,7 @@ if (!ND) return true; TestSymbol S; + S.SymInfo = getSymbolInfo(D); S.QName = ND->getQualifiedNameAsString(); S.WrittenPos = Position::fromSourceLocation(Loc, AST->getSourceManager()); S.DeclPos = @@ -140,6 +142,7 @@ MATCHER_P(QName, Name, "") { return arg.QName == Name; } MATCHER_P(WrittenAt, Pos, "") { return arg.WrittenPos == Pos; } MATCHER_P(DeclAt, Pos, "") { return arg.DeclPos == Pos; } +MATCHER_P(Kind, SymKind, "") { return arg.SymInfo.Kind == SymKind; } TEST(IndexTest, Simple) { auto Index = std::make_shared(); @@ -240,6 +243,20 @@ Contains(QName("Foo::C")), Contains(QName("Foo::NoRef")))); } +TEST(IndexTest, UsingDecls) { + std::string Code = R"cpp( + void foo(int bar); + namespace std { + using ::foo; + } + )cpp"; + auto Index = std::make_shared(); + IndexingOptions Opts; + tooling::runToolOnCode(new IndexAction(Index, Opts), Code); + EXPECT_THAT(Index->Symbols, + Contains(AllOf(QName("std::foo"), Kind(SymbolKind::Using)))); +} + } // namespace } // namespace index } // namespace clang