[PATCH] D52752: [clang-query] Add comment token handling
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 3 01:23:38 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE343666: [clang-query] Add comment token handling (authored by steveire, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D52752?vs=167848&id=168080#toc
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D52752
Files:
clang-query/QueryParser.cpp
unittests/clang-query/QueryParserTest.cpp
Index: unittests/clang-query/QueryParserTest.cpp
===================================================================
--- unittests/clang-query/QueryParserTest.cpp
+++ unittests/clang-query/QueryParserTest.cpp
@@ -146,6 +146,17 @@
cast<InvalidQuery>(Q)->ErrStr);
}
+TEST_F(QueryParserTest, Comment) {
+ QueryRef Q = parse("# let foo decl()");
+ ASSERT_TRUE(isa<NoOpQuery>(Q));
+
+ Q = parse("let foo decl() # creates a decl() matcher called foo");
+ ASSERT_TRUE(isa<LetQuery>(Q));
+
+ Q = parse("set bind-root false # reduce noise");
+ ASSERT_TRUE(isa<SetQuery<bool>>(Q));
+}
+
TEST_F(QueryParserTest, Complete) {
std::vector<llvm::LineEditor::Completion> Comps =
QueryParser::complete("", 0, QS);
Index: clang-query/QueryParser.cpp
===================================================================
--- clang-query/QueryParser.cpp
+++ clang-query/QueryParser.cpp
@@ -37,6 +37,11 @@
++Begin;
}
+ if (*Begin == '#') {
+ End = Begin;
+ return StringRef();
+ }
+
const char *WordBegin = Begin;
while (true) {
@@ -127,6 +132,7 @@
enum ParsedQueryKind {
PQK_Invalid,
+ PQK_Comment,
PQK_NoOp,
PQK_Help,
PQK_Let,
@@ -161,6 +167,7 @@
StringRef CommandStr;
ParsedQueryKind QKind = LexOrCompleteWord<ParsedQueryKind>(this, CommandStr)
.Case("", PQK_NoOp)
+ .Case("#", PQK_Comment, /*IsCompletion=*/false)
.Case("help", PQK_Help)
.Case("l", PQK_Let, /*IsCompletion=*/false)
.Case("let", PQK_Let)
@@ -173,6 +180,7 @@
.Default(PQK_Invalid);
switch (QKind) {
+ case PQK_Comment:
case PQK_NoOp:
return new NoOpQuery;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52752.168080.patch
Type: text/x-patch
Size: 1783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181003/d72413ac/attachment-0001.bin>
More information about the cfe-commits
mailing list