summaryrefslogtreecommitdiffstats
path: root/clang/include/clang/Lex/Token.h
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@gmail.com>2010-12-22 08:23:18 +0000
committerAbramo Bagnara <abramo.bagnara@gmail.com>2010-12-22 08:23:18 +0000
commitea4f7c776194c96f8ece1456bc22102c6cbc9a33 (patch)
treed1053edb8868105b02ca8fdf61a21462e03a8501 /clang/include/clang/Lex/Token.h
parentfe86bc527a0d50b653d2df8fa8b091a5397d3a9d (diff)
downloadbcm5719-llvm-ea4f7c776194c96f8ece1456bc22102c6cbc9a33.tar.gz
bcm5719-llvm-ea4f7c776194c96f8ece1456bc22102c6cbc9a33.zip
Introduced raw_identifier token kind.
llvm-svn: 122394
Diffstat (limited to 'clang/include/clang/Lex/Token.h')
-rw-r--r--clang/include/clang/Lex/Token.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/clang/include/clang/Lex/Token.h b/clang/include/clang/Lex/Token.h
index 2a190839069..ef4f02cb575 100644
--- a/clang/include/clang/Lex/Token.h
+++ b/clang/include/clang/Lex/Token.h
@@ -88,6 +88,12 @@ public:
bool is(tok::TokenKind K) const { return Kind == (unsigned) K; }
bool isNot(tok::TokenKind K) const { return Kind != (unsigned) K; }
+ /// isAnyIdentifier - Return true if this is a raw identifier (when lexing
+ /// in raw mode) or a non-keyword identifier (when lexing in non-raw mode).
+ bool isAnyIdentifier() const {
+ return is(tok::identifier) || is(tok::raw_identifier);
+ }
+
/// isLiteral - Return true if this is a "literal", like a numeric
/// constant, string, etc.
bool isLiteral() const {
@@ -154,7 +160,10 @@ public:
}
IdentifierInfo *getIdentifierInfo() const {
- assert(!isAnnotation() && "Used IdentInfo on annotation token!");
+ assert(isNot(tok::raw_identifier) &&
+ "getIdentifierInfo() on a tok::raw_identifier token!");
+ assert(!isAnnotation() &&
+ "getIdentifierInfo() on an annotation token!");
if (isLiteral()) return 0;
return (IdentifierInfo*) PtrData;
}
@@ -162,6 +171,18 @@ public:
PtrData = (void*) II;
}
+ /// getRawIdentifierData - For a raw identifier token (i.e., an identifier
+ /// lexed in raw mode), returns a pointer to the start of it in the text
+ /// buffer if known, null otherwise.
+ const char *getRawIdentifierData() const {
+ assert(is(tok::raw_identifier));
+ return reinterpret_cast<const char*>(PtrData);
+ }
+ void setRawIdentifierData(const char *Ptr) {
+ assert(is(tok::raw_identifier));
+ PtrData = const_cast<char*>(Ptr);
+ }
+
/// getLiteralData - For a literal token (numeric constant, string, etc), this
/// returns a pointer to the start of it in the text buffer if known, null
/// otherwise.
OpenPOWER on IntegriCloud