[PATCH] D58341: [clangd] Index UsingDecls
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 25 07:28:19 PST 2019
kadircet updated this revision to Diff 188170.
kadircet marked 2 inline comments as done.
kadircet added a comment.
- Address comments
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58341/new/
https://reviews.llvm.org/D58341
Files:
unittests/clangd/CodeCompleteTests.cpp
unittests/clangd/SymbolCollectorTests.cpp
unittests/clangd/SymbolInfoTests.cpp
Index: unittests/clangd/SymbolInfoTests.cpp
===================================================================
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -167,7 +167,8 @@
)cpp",
{CreateExpectedSymbolDetails("foo", "", "c:@F at foo#"),
CreateExpectedSymbolDetails("foo", "", "c:@F at foo#b#"),
- CreateExpectedSymbolDetails("foo", "", "c:@F at foo#I#")}},
+ CreateExpectedSymbolDetails("foo", "", "c:@F at foo#I#"),
+ CreateExpectedSymbolDetails("foo", "bar::", "c:@N at bar@UD at foo")}},
{
R"cpp( // Multiple symbols returned - implicit conversion
struct foo {};
Index: unittests/clangd/SymbolCollectorTests.cpp
===================================================================
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -325,9 +325,6 @@
// Namespace alias
namespace baz = bar;
- // FIXME: using declaration is not supported as the IndexAction will ignore
- // implicit declarations (the implicit using shadow declaration) by default,
- // and there is no way to customize this behavior at the moment.
using bar::v2;
} // namespace foo
)";
@@ -354,6 +351,7 @@
AllOf(QName("foo::int32_t"), ForCodeCompletion(true)),
AllOf(QName("foo::v1"), ForCodeCompletion(true)),
AllOf(QName("foo::bar::v2"), ForCodeCompletion(true)),
+ AllOf(QName("foo::v2"), ForCodeCompletion(true)),
AllOf(QName("foo::baz"), ForCodeCompletion(true))}));
}
@@ -1118,6 +1116,16 @@
AllOf(QName("Public"), Not(ImplementationDetail()))));
}
+TEST_F(SymbolCollectorTest, UsingDecl) {
+ const char *Header = R"(
+ void foo();
+ namespace std {
+ using ::foo;
+ })";
+ runSymbolCollector(Header, /**/ "");
+ EXPECT_THAT(Symbols, Contains(QName("std::foo")));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
Index: unittests/clangd/CodeCompleteTests.cpp
===================================================================
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -17,6 +17,7 @@
#include "SyncAPI.h"
#include "TestFS.h"
#include "TestIndex.h"
+#include "TestTU.h"
#include "index/MemIndex.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "llvm/Support/Error.h"
@@ -2314,6 +2315,26 @@
EXPECT_THAT(R.Completions, ElementsAre(Named("loopVar")));
}
+TEST(CompletionTest, UsingDecl) {
+ const char *Header(R"cpp(
+ void foo(int);
+ namespace std {
+ using ::foo;
+ })cpp");
+ const char *Source(R"cpp(
+ void bar() {
+ std::^;
+ })cpp");
+ auto Index = TestTU::withHeaderCode(Header).index();
+ clangd::CodeCompleteOptions Opts;
+ Opts.Index = Index.get();
+ Opts.AllScopes = true;
+ auto R = completions(Source, {}, Opts);
+ EXPECT_THAT(R.Completions,
+ ElementsAre(AllOf(Scope("std::"), Named("foo"),
+ Kind(CompletionItemKind::Reference))));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58341.188170.patch
Type: text/x-patch
Size: 3196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190225/d14d0678/attachment.bin>
More information about the cfe-commits
mailing list