summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-query/QueryParser.cpp
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2018-10-03 08:21:54 +0000
committerStephen Kelly <steveire@gmail.com>2018-10-03 08:21:54 +0000
commit2c4079c090aa05dc542169bbc0c3e4b31c6920e9 (patch)
tree7963b5afbd264bcac9b5aa72f1d124f33f0792eb /clang-tools-extra/clang-query/QueryParser.cpp
parent7c787b8adf1b85e2bbb03db9a47ee8a6af9690ab (diff)
downloadbcm5719-llvm-2c4079c090aa05dc542169bbc0c3e4b31c6920e9.tar.gz
bcm5719-llvm-2c4079c090aa05dc542169bbc0c3e4b31c6920e9.zip
[clang-query] Add comment token handling
Summary: It is possible to pass a file of commands to clang-query using the command line option -f or --preload. Make it possible to write comments in such files. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D52752 llvm-svn: 343666
Diffstat (limited to 'clang-tools-extra/clang-query/QueryParser.cpp')
-rw-r--r--clang-tools-extra/clang-query/QueryParser.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-query/QueryParser.cpp b/clang-tools-extra/clang-query/QueryParser.cpp
index ddedd1ece7a..55504f70c2b 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -37,6 +37,11 @@ StringRef QueryParser::lexWord() {
++Begin;
}
+ if (*Begin == '#') {
+ End = Begin;
+ return StringRef();
+ }
+
const char *WordBegin = Begin;
while (true) {
@@ -127,6 +132,7 @@ namespace {
enum ParsedQueryKind {
PQK_Invalid,
+ PQK_Comment,
PQK_NoOp,
PQK_Help,
PQK_Let,
@@ -161,6 +167,7 @@ QueryRef QueryParser::doParse() {
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 @@ QueryRef QueryParser::doParse() {
.Default(PQK_Invalid);
switch (QKind) {
+ case PQK_Comment:
case PQK_NoOp:
return new NoOpQuery;
OpenPOWER on IntegriCloud