[clang-tools-extra] 9fe89a1 - [clangd] Add parsing for IgnoreHeaders config option
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri May 6 07:12:04 PDT 2022
Author: Kadir Cetinkaya
Date: 2022-05-06T16:11:37+02:00
New Revision: 9fe89a1f0fa6d88aa4786580b89e81dc906fcc52
URL: https://github.com/llvm/llvm-project/commit/9fe89a1f0fa6d88aa4786580b89e81dc906fcc52
DIFF: https://github.com/llvm/llvm-project/commit/9fe89a1f0fa6d88aa4786580b89e81dc906fcc52.diff
LOG: [clangd] Add parsing for IgnoreHeaders config option
Added:
Modified:
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYAML.cpp
index 9e4a4e0792df2..ec39bb9686640 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -128,6 +128,7 @@ class Parser {
Dict.handle("UnusedIncludes", [&](Node &N) {
F.UnusedIncludes = scalarValue(N, "UnusedIncludes");
});
+ Dict.handle("Includes", [&](Node &N) { parse(F.Includes, N); });
Dict.handle("ClangTidy", [&](Node &N) { parse(F.ClangTidy, N); });
Dict.parse(N);
}
@@ -154,6 +155,15 @@ class Parser {
Dict.parse(N);
}
+ void parse(Fragment::DiagnosticsBlock::IncludesBlock &F, Node &N) {
+ DictParser Dict("Includes", this);
+ Dict.handle("IgnoreHeader", [&](Node &N) {
+ if (auto Values = scalarValues(N))
+ F.IgnoreHeader = std::move(*Values);
+ });
+ Dict.parse(N);
+ }
+
void parse(Fragment::IndexBlock &F, Node &N) {
DictParser Dict("Index", this);
Dict.handle("Background",
diff --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
index d4be2e9ad4eb0..143bcf99fc547 100644
--- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -247,6 +247,20 @@ TEST(ParseYAML, InlayHints) {
EXPECT_EQ(Results[0].InlayHints.DeducedTypes, llvm::None);
}
+TEST(ParseYAML, IncludesIgnoreHeader) {
+ CapturedDiags Diags;
+ Annotations YAML(R"yaml(
+Diagnostics:
+ Includes:
+ IgnoreHeader: [foo, bar]
+ )yaml");
+ auto Results =
+ Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+ ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+ ASSERT_EQ(Results.size(), 1u);
+ EXPECT_THAT(Results[0].Diagnostics.Includes.IgnoreHeader,
+ ElementsAre(val("foo"), val("bar")));
+}
} // namespace
} // namespace config
} // namespace clangd
More information about the cfe-commits
mailing list