kadircet updated this revision to Diff 187376. kadircet marked an inline comment as done. kadircet added a comment.
- Revert last change Repository: rCTE Clang Tools Extra CHANGES SINCE LAST ACTION https://reviews.llvm.org/D58341/new/ https://reviews.llvm.org/D58341 Files: 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@foo#"), CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"), - CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}}, + CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"), + CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@UD@foo")}}, { R"cpp( // Multiple symbols returned - implicit conversion struct foo {}; Index: unittests/clangd/SymbolCollectorTests.cpp =================================================================== --- unittests/clangd/SymbolCollectorTests.cpp +++ unittests/clangd/SymbolCollectorTests.cpp @@ -7,8 +7,12 @@ //===----------------------------------------------------------------------===// #include "Annotations.h" +#include "ClangdServer.h" +#include "SyncAPI.h" #include "TestFS.h" #include "TestTU.h" +#include "index/Index.h" +#include "index/MemIndex.h" #include "index/SymbolCollector.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" @@ -50,6 +54,7 @@ MATCHER_P(Snippet, S, "") { return (arg.Name + arg.CompletionSnippetSuffix).str() == S; } +MATCHER_P(CompletionQName, Name, "") { return (arg.Scope + arg.Name) == Name; } MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; } MATCHER_P(DeclURI, P, "") { return StringRef(arg.CanonicalDeclaration.FileURI) == P; @@ -325,9 +330,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 +356,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 +1121,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/SymbolInfoTests.cpp =================================================================== --- unittests/clangd/SymbolInfoTests.cpp +++ unittests/clangd/SymbolInfoTests.cpp @@ -167,7 +167,8 @@ )cpp", {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"), CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"), - CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}}, + CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#"), + CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@UD@foo")}}, { R"cpp( // Multiple symbols returned - implicit conversion struct foo {}; Index: unittests/clangd/SymbolCollectorTests.cpp =================================================================== --- unittests/clangd/SymbolCollectorTests.cpp +++ unittests/clangd/SymbolCollectorTests.cpp @@ -7,8 +7,12 @@ //===----------------------------------------------------------------------===// #include "Annotations.h" +#include "ClangdServer.h" +#include "SyncAPI.h" #include "TestFS.h" #include "TestTU.h" +#include "index/Index.h" +#include "index/MemIndex.h" #include "index/SymbolCollector.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" @@ -50,6 +54,7 @@ MATCHER_P(Snippet, S, "") { return (arg.Name + arg.CompletionSnippetSuffix).str() == S; } +MATCHER_P(CompletionQName, Name, "") { return (arg.Scope + arg.Name) == Name; } MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; } MATCHER_P(DeclURI, P, "") { return StringRef(arg.CanonicalDeclaration.FileURI) == P; @@ -325,9 +330,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 +356,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 +1121,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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits