[PATCH] D124288: [Index] Add a USR and symbol kind for UnresolvedUsingIfExists
Ben Barham via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 22 14:42:35 PDT 2022
bnbarham updated this revision to Diff 424621.
bnbarham added a comment.
After speaking with Ben, we decided it makes more sense to just remove the reference entirely.
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 at foo | <no-cgname> | Decl | rel: 0
+// CHECK-NOT: [[@LINE-2]]:11 | <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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124288.424621.patch
Type: text/x-patch
Size: 1458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220422/ee988dac/attachment.bin>
More information about the cfe-commits
mailing list