[PATCH] D125088: [clangd] Add parsing for IgnoreHeaders config option
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 6 05:35:53 PDT 2022
kadircet created this revision.
kadircet added reviewers: sammccall, kbobyrev.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
https://reviews.llvm.org/D125088
Files:
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -247,6 +247,20 @@
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
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===================================================================
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -128,6 +128,7 @@
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 @@
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",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125088.427604.patch
Type: text/x-patch
Size: 1807 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220506/2b30d871/attachment.bin>
More information about the cfe-commits
mailing list