summaryrefslogtreecommitdiffstats
path: root/clang/lib/ASTMatchers/Dynamic/Parser.cpp
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2017-06-08 22:00:38 +0000
committerPeter Wu <peter@lekensteyn.nl>2017-06-08 22:00:38 +0000
commitc04b198c50b0ed845c102e59b8eb1a6136b2347c (patch)
treeec1643c4f413c84af7e052b0f74d2fe6458db0af /clang/lib/ASTMatchers/Dynamic/Parser.cpp
parent8dde4cba4ce76a9efc663e997735e96325be7902 (diff)
downloadbcm5719-llvm-c04b198c50b0ed845c102e59b8eb1a6136b2347c.tar.gz
bcm5719-llvm-c04b198c50b0ed845c102e59b8eb1a6136b2347c.zip
[ASTMatchers] Add support for boolean literals
Summary: Recognize boolean literals for future extensions ("equals(true)"). Note that a specific VariantValue constructor is added to resolve ambiguity (like "Value = 5") between unsigned and bool. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D33093 llvm-svn: 305020
Diffstat (limited to 'clang/lib/ASTMatchers/Dynamic/Parser.cpp')
-rw-r--r--clang/lib/ASTMatchers/Dynamic/Parser.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
index ce8d0a9a020..967da8ac322 100644
--- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -153,8 +153,16 @@ private:
break;
++TokenLength;
}
- Result.Kind = TokenInfo::TK_Ident;
- Result.Text = Code.substr(0, TokenLength);
+ if (TokenLength == 4 && Code.startswith("true")) {
+ Result.Kind = TokenInfo::TK_Literal;
+ Result.Value = true;
+ } else if (TokenLength == 5 && Code.startswith("false")) {
+ Result.Kind = TokenInfo::TK_Literal;
+ Result.Value = false;
+ } else {
+ Result.Kind = TokenInfo::TK_Ident;
+ Result.Text = Code.substr(0, TokenLength);
+ }
Code = Code.drop_front(TokenLength);
} else {
Result.Kind = TokenInfo::TK_InvalidChar;
OpenPOWER on IntegriCloud