Skip to content

Commit 7029e5d

Browse files
committed
[clangd] Actually parse Index section of the YAML file.
This fixes a bug in dbf486c, which introduced the Index section of the config, but did not register the parse method, so it didn't work in a YAML file (but did in a test). Differential Revision: https://reviews.llvm.org/D87710
1 parent a63b2a4 commit 7029e5d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

clang-tools-extra/clangd/ConfigYAML.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Parser {
3838
DictParser Dict("Config", this);
3939
Dict.handle("If", [&](Node &N) { parse(F.If, N); });
4040
Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
41+
Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
4142
Dict.parse(N);
4243
return !(N.failed() || HadError);
4344
}

clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,21 @@ CompileFlags: { Add: [foo, bar] }
4747
Add: |
4848
b
4949
az
50+
---
51+
Index:
52+
Background: Skip
5053
)yaml";
5154
auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
5255
EXPECT_THAT(Diags.Diagnostics, IsEmpty());
53-
ASSERT_EQ(Results.size(), 2u);
54-
EXPECT_FALSE(Results.front().If.HasUnrecognizedCondition);
55-
EXPECT_THAT(Results.front().If.PathMatch, ElementsAre(Val("abc")));
56-
EXPECT_THAT(Results.front().CompileFlags.Add,
57-
ElementsAre(Val("foo"), Val("bar")));
56+
ASSERT_EQ(Results.size(), 3u);
57+
EXPECT_FALSE(Results[0].If.HasUnrecognizedCondition);
58+
EXPECT_THAT(Results[0].If.PathMatch, ElementsAre(Val("abc")));
59+
EXPECT_THAT(Results[0].CompileFlags.Add, ElementsAre(Val("foo"), Val("bar")));
60+
61+
EXPECT_THAT(Results[1].CompileFlags.Add, ElementsAre(Val("b\naz\n")));
5862

59-
EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
63+
ASSERT_TRUE(Results[2].Index.Background);
64+
EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
6065
}
6166

6267
TEST(ParseYAML, Locations) {

0 commit comments

Comments
 (0)