bnbarham updated this revision to Diff 424631. bnbarham added a comment. Remove line for <unknown> check
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124288/new/ https://reviews.llvm.org/D124288 Files: clang/lib/Index/IndexDecl.cpp clang/test/Index/using_if_exists.cpp Index: clang/test/Index/using_if_exists.cpp =================================================================== --- /dev/null +++ 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 | <no-cgname> | Decl | rel: 0 +// CHECK-NOT: <unknown> Index: clang/lib/Index/IndexDecl.cpp =================================================================== --- clang/lib/Index/IndexDecl.cpp +++ clang/lib/Index/IndexDecl.cpp @@ -605,9 +605,16 @@ const NamedDecl *Parent = dyn_cast<NamedDecl>(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<UnresolvedUsingIfExistsDecl>(I->getUnderlyingDecl())) + continue; + IndexCtx.handleReference(I->getUnderlyingDecl(), D->getLocation(), Parent, D->getLexicalDeclContext(), SymbolRoleSet()); + } return true; }
Index: clang/test/Index/using_if_exists.cpp =================================================================== --- /dev/null +++ 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 | <no-cgname> | Decl | rel: 0 +// CHECK-NOT: <unknown> Index: clang/lib/Index/IndexDecl.cpp =================================================================== --- clang/lib/Index/IndexDecl.cpp +++ clang/lib/Index/IndexDecl.cpp @@ -605,9 +605,16 @@ const NamedDecl *Parent = dyn_cast<NamedDecl>(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<UnresolvedUsingIfExistsDecl>(I->getUnderlyingDecl())) + continue; + IndexCtx.handleReference(I->getUnderlyingDecl(), D->getLocation(), Parent, D->getLexicalDeclContext(), SymbolRoleSet()); + } return true; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits