diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-09-14 12:36:06 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-09-14 12:36:06 +0000 |
| commit | ebef81227b9e80e4255707a84736af7f994ac0fd (patch) | |
| tree | 9a83bb809efa0ab3f2183e35026627992e44c6ae /clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp | |
| parent | 053c9ee82650907a0e12a65ca43a1958692ed2fd (diff) | |
| download | bcm5719-llvm-ebef81227b9e80e4255707a84736af7f994ac0fd.tar.gz bcm5719-llvm-ebef81227b9e80e4255707a84736af7f994ac0fd.zip | |
[clangd] Don't override the preamble while completing inside it, it doesn't work.
Summary:
To stay fast, enable single-file-mode instead. This is fine since completions
in the preamble are simple.
The net effect for now is to suppress the spurious TopLevel completions when
completing inside the preamble.
Once Sema has include directive completion, this will be more important.
Reviewers: ilya-biryukov
Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D52071
llvm-svn: 342230
Diffstat (limited to 'clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp')
| -rw-r--r-- | clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp b/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp index 248dab8ca27..9a703761224 100644 --- a/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp +++ b/clang-tools-extra/unittests/clangd/CodeCompleteTests.cpp @@ -657,6 +657,22 @@ TEST(CompletionTest, IndexSuppressesPreambleCompletions) { UnorderedElementsAre(Named("local"), Named("preamble"))); } +// This verifies that we get normal preprocessor completions in the preamble. +// This is a regression test for an old bug: if we override the preamble and +// try to complete inside it, clang kicks our completion point just outside the +// preamble, resulting in always getting top-level completions. +TEST(CompletionTest, CompletionInPreamble) { + EXPECT_THAT(completions(R"cpp( + #ifnd^ef FOO_H_ + #define BAR_H_ + #include <bar.h> + int foo() {} + #endif + )cpp") + .Completions, + ElementsAre(Named("ifndef"))); +}; + TEST(CompletionTest, DynamicIndexMultiFile) { MockFSProvider FS; MockCompilationDatabase CDB; |

