[clang-query] Add missing 'l' command handling

The `let` command was added in commit 045c15ba (Add new 'let' command to
bind arbitrary values into constants., 2014-04-23).

The `let` command and the non-existant `l` command were documented in
commit 233092a0 (Add 'let' to the help message., 2015-02-27).

Implement the `l` command now for completeness.

llvm-svn: 343533
This commit is contained in:
Stephen Kelly 2018-10-01 20:34:21 +00:00
parent c6356eceaa
commit 9af02f2028
2 changed files with 7 additions and 0 deletions

View File

@ -162,6 +162,7 @@ QueryRef QueryParser::doParse() {
ParsedQueryKind QKind = LexOrCompleteWord<ParsedQueryKind>(this, CommandStr)
.Case("", PQK_NoOp)
.Case("help", PQK_Help)
.Case("l", PQK_Let, /*IsCompletion=*/false)
.Case("let", PQK_Let)
.Case("m", PQK_Match, /*IsCompletion=*/false)
.Case("match", PQK_Match)

View File

@ -103,6 +103,12 @@ TEST_F(QueryParserTest, LetUnlet) {
EXPECT_TRUE(cast<LetQuery>(Q)->Value.isMatcher());
EXPECT_TRUE(cast<LetQuery>(Q)->Value.getMatcher().hasTypedMatcher<Decl>());
Q = parse("l foo decl()");
ASSERT_TRUE(isa<LetQuery>(Q));
EXPECT_EQ("foo", cast<LetQuery>(Q)->Name);
EXPECT_TRUE(cast<LetQuery>(Q)->Value.isMatcher());
EXPECT_TRUE(cast<LetQuery>(Q)->Value.getMatcher().hasTypedMatcher<Decl>());
Q = parse("let bar \"str\"");
ASSERT_TRUE(isa<LetQuery>(Q));
EXPECT_EQ("bar", cast<LetQuery>(Q)->Name);