diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2019-04-10 15:16:54 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2019-04-10 15:16:54 +0000 |
| commit | b814e57ffba00be55237863790fb4f0b33cb80c2 (patch) | |
| tree | e6045493ed7f7bc6024d0d725cad726e0dc971ea /clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp | |
| parent | 0d9f609d824d50e963799b826f2cb2328e51b047 (diff) | |
| download | bcm5719-llvm-b814e57ffba00be55237863790fb4f0b33cb80c2.tar.gz bcm5719-llvm-b814e57ffba00be55237863790fb4f0b33cb80c2.zip | |
[clangd] Don't insert extra namespace qualifiers when Sema gets lost.
Summary:
There are cases where Sema can't tell that "foo" in foo::Bar is a
namespace qualifier, like in incomplete macro expansions.
After this patch, if sema reports no specifier but it looks like there's one in
the source code, then we take it into account.
Reworked structure and comments in getQueryScopes to try to fight
creeping complexity - unsure if I succeeded.
I made the test harder (the original version also passes).
Reviewers: ioeric
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60503
llvm-svn: 358091
Diffstat (limited to 'clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp')
| -rw-r--r-- | clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp b/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp index f0a8097bf46..f60ed1c8426 100644 --- a/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp +++ b/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp @@ -2384,19 +2384,19 @@ TEST(CompletionTest, NestedScopeIsUnresolved) { UnorderedElementsAre(AllOf(Qualifier(""), Named("XYZ")))); } -// Regression test: clang parser gets confused here and doesn't report the ns:: -// prefix - naive behavior is to insert it again. -// However we can recognize this from the source code. -// Test disabled until we can make it pass. -TEST(CompletionTest, DISABLED_NamespaceDoubleInsertion) { +// Clang parser gets confused here and doesn't report the ns:: prefix. +// Naive behavior is to insert it again. We examine the source and recover. +TEST(CompletionTest, NamespaceDoubleInsertion) { clangd::CodeCompleteOptions Opts = {}; auto Results = completions(R"cpp( + namespace foo { namespace ns {} #define M(X) < X M(ns::ABC^ + } )cpp", - {cls("ns::ABCDE")}, Opts); + {cls("foo::ns::ABCDE")}, Opts); EXPECT_THAT(Results.Completions, UnorderedElementsAre(AllOf(Qualifier(""), Named("ABCDE")))); } |

