[clang-query] Add missing 'l' command handling
authorStephen Kelly <steveire@gmail.com>
Mon, 1 Oct 2018 20:34:21 +0000 (20:34 +0000)
committerStephen Kelly <steveire@gmail.com>
Mon, 1 Oct 2018 20:34:21 +0000 (20:34 +0000)
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

clang-tools-extra/clang-query/QueryParser.cpp
clang-tools-extra/unittests/clang-query/QueryParserTest.cpp

index 65bd3fc..d05a0ba 100644 (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)
index 5588ea3..9929de4 100644 (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);