[clang-tools-extra] r354879 - [clangd] Index UsingDecls
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 26 06:23:47 PST 2019
Author: kadircet
Date: Tue Feb 26 06:23:47 2019
New Revision: 354879
URL: http://llvm.org/viewvc/llvm-project?rev=354879&view=rev
Log:
[clangd] Index UsingDecls
Summary:
D58340 enables indexing of USRs, this makes sure test in clangd are
aligned with the change
Reviewers: hokein
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58341
Modified:
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=354879&r1=354878&r2=354879&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Tue Feb 26 06:23:47 2019
@@ -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 @@ TEST(CompletionTest, WorksWithNullType)
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
Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp?rev=354879&r1=354878&r2=354879&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Tue Feb 26 06:23:47 2019
@@ -368,9 +368,6 @@ TEST_F(DocumentSymbolsTest, BasicSymbols
// 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
)");
@@ -415,7 +412,7 @@ TEST_F(DocumentSymbolsTest, BasicSymbols
Children()))),
AllOf(WithName("baz"), WithKind(SymbolKind::Namespace),
Children()),
- AllOf(WithName("v2"), WithKind(SymbolKind::Variable))))}));
+ AllOf(WithName("v2"), WithKind(SymbolKind::Namespace))))}));
}
TEST_F(DocumentSymbolsTest, DeclarationDefinition) {
Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=354879&r1=354878&r2=354879&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Tue Feb 26 06:23:47 2019
@@ -331,9 +331,6 @@ TEST_F(SymbolCollectorTest, CollectSymbo
// 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
)";
@@ -360,6 +357,7 @@ TEST_F(SymbolCollectorTest, CollectSymbo
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))}));
}
@@ -1149,6 +1147,16 @@ TEST_F(SymbolCollectorTest, Implementati
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
Modified: clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp?rev=354879&r1=354878&r2=354879&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp Tue Feb 26 06:23:47 2019
@@ -167,7 +167,8 @@ TEST(SymbolInfoTests, All) {
)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 {};
More information about the cfe-commits
mailing list