Fix newline handling in clang-query parser

Don't prematurely remove characters from the end of the string
This commit is contained in:
Stephen Kelly 2019-12-29 14:48:47 +00:00
parent dc93540acb
commit 544f200c78
2 changed files with 9 additions and 1 deletions

View File

@ -250,7 +250,7 @@ QueryRef QueryParser::doParse() {
return completeMatcherExpression();
Diagnostics Diag;
auto MatcherSource = Line.trim();
auto MatcherSource = Line.ltrim();
auto OrigMatcherSource = MatcherSource;
Optional<DynTypedMatcher> Matcher = Parser::parseMatcherExpression(
MatcherSource, nullptr, &QS.NamedValues, &Diag);

View File

@ -348,4 +348,12 @@ match callExpr
ASSERT_TRUE(isa<InvalidQuery>(Q));
EXPECT_EQ("1:1: Invalid token <NewLine> found when looking for a value.", cast<InvalidQuery>(Q)->ErrStr);
Q = parse("\nm parmVarDecl()\nlet someMatcher\n");
ASSERT_TRUE(isa<MatchQuery>(Q));
Q = parse(Q->RemainingContent);
ASSERT_TRUE(isa<InvalidQuery>(Q));
EXPECT_EQ("1:1: Invalid token <NewLine> found when looking for a value.", cast<InvalidQuery>(Q)->ErrStr);
}