[PATCH] D62573: [Index] Correctly set symbol kind of IndirectFieldDecl
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 29 01:24:22 PDT 2019
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added subscribers: arphaman, jkorous.
Herald added a project: clang.
The kind has been 'unknown' before, now it is 'field'.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62573
Files:
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang/lib/Index/IndexSymbol.cpp
clang/test/Index/index-anonymous-union-fields.cpp
Index: clang/test/Index/index-anonymous-union-fields.cpp
===================================================================
--- /dev/null
+++ clang/test/Index/index-anonymous-union-fields.cpp
@@ -0,0 +1,10 @@
+struct X {
+ union {
+ void *a;
+ };
+};
+
+// RUN: c-index-test -index-file %s > %t
+// RUN: FileCheck %s -input-file=%t
+
+// CHECK: [indexDeclaration]: kind: field | name: a | {{.*}} | loc: 3:11
Index: clang/lib/Index/IndexSymbol.cpp
===================================================================
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -168,6 +168,7 @@
Info.Kind = SymbolKind::Function;
break;
case Decl::Field:
+ case Decl::IndirectField:
Info.Kind = SymbolKind::Field;
if (const CXXRecordDecl *
CXXRec = dyn_cast<CXXRecordDecl>(D->getDeclContext())) {
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -449,6 +449,20 @@
Results = completions("nam^");
EXPECT_THAT(Results.Completions,
Has("namespace", CompletionItemKind::Snippet));
+
+ // Members of anonymous unions are of kind 'field'.
+ Results = completions(
+ R"cpp(
+ struct X{
+ union {
+ void *a;
+ };
+ };
+ auto u = X().^
+ )cpp");
+ EXPECT_THAT(
+ Results.Completions,
+ UnorderedElementsAre(AllOf(Named("a"), Kind(CompletionItemKind::Field))));
}
TEST(CompletionTest, NoDuplicates) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62573.201837.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190529/cdb10647/attachment.bin>
More information about the cfe-commits
mailing list