[clang-tools-extra] dec8d8d - [clangd] Add unit tests for comments in system headers
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 01:24:59 PST 2019
Author: Ilya Biryukov
Date: 2019-11-07T10:24:27+01:00
New Revision: dec8d8d3f205268712a928d106ff2e6f799f7a9b
URL: https://github.com/llvm/llvm-project/commit/dec8d8d3f205268712a928d106ff2e6f799f7a9b
DIFF: https://github.com/llvm/llvm-project/commit/dec8d8d3f205268712a928d106ff2e6f799f7a9b.diff
LOG: [clangd] Add unit tests for comments in system headers
Added:
Modified:
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 20f89895279c..02d7750607a4 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -872,6 +872,33 @@ TEST(CompletionTest, Documentation) {
Contains(AllOf(Named("baz"), Doc("Multi-line\nblock comment"))));
}
+TEST(CompletionTest, CommentsFromSystemHeaders) {
+ MockFSProvider FS;
+ MockCompilationDatabase CDB;
+ IgnoreDiagnostics DiagConsumer;
+
+ auto Opts = ClangdServer::optsForTest();
+ Opts.BuildDynamicSymbolIndex = true;
+
+ ClangdServer Server(CDB, FS, DiagConsumer, Opts);
+
+ FS.Files[testPath("foo.h")] = R"cpp(
+ #pragma GCC system_header
+
+ // This comment should be retained!
+ int foo();
+ )cpp";
+
+ auto Results = completions(Server,
+ R"cpp(
+#include "foo.h"
+int x = foo^
+ )cpp");
+ EXPECT_THAT(
+ Results.Completions,
+ Contains(AllOf(Named("foo"), Doc("This comment should be retained!"))));
+}
+
TEST(CompletionTest, GlobalCompletionFiltering) {
Symbol Class = cls("XYZ");
More information about the cfe-commits
mailing list