diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -605,9 +605,16 @@ const NamedDecl *Parent = dyn_cast(DC); IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent, D->getLexicalDeclContext()); - for (const auto *I : D->shadows()) + for (const auto *I : D->shadows()) { + // Skip unresolved using decls - we already have a decl for the using + // itself, so there's not much point adding another decl or reference to + // refer to the same location. + if (isa(I->getUnderlyingDecl())) + continue; + IndexCtx.handleReference(I->getUnderlyingDecl(), D->getLocation(), Parent, D->getLexicalDeclContext(), SymbolRoleSet()); + } return true; } diff --git a/clang/test/Index/using_if_exists.cpp b/clang/test/Index/using_if_exists.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Index/using_if_exists.cpp @@ -0,0 +1,9 @@ +// RUN: c-index-test core -print-source-symbols -- %s -target x86_64-unknown-unknown 2>&1 | FileCheck %s + +namespace ns { +// void foo(); +} + +using ns::foo __attribute__((using_if_exists)); +// CHECK: [[@LINE-1]]:11 | using/C++ | foo | c:@UD@foo | | Decl | rel: 0 +// CHECK-NOT: