14 #ifndef LLVM_CLANG_LEX_TOKEN_H
15 #define LLVM_CLANG_LEX_TOKEN_H
19 #include "llvm/ADT/StringRef.h"
97 return is(K1) ||
is(K2);
99 template <
typename... Ts>
127 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
133 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
138 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
142 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
177 assert(
isNot(tok::raw_identifier) &&
178 "getIdentifierInfo() on a tok::raw_identifier token!");
180 "getIdentifierInfo() on an annotation token!");
186 PtrData = (
void*) II;
191 return reinterpret_cast<const void *
>(PtrData);
196 PtrData =
const_cast<void *
>(D);
203 assert(
is(tok::raw_identifier));
204 return StringRef(reinterpret_cast<const char *>(PtrData),
getLength());
207 assert(
is(tok::raw_identifier));
208 PtrData =
const_cast<char*
>(Ptr);
215 assert(
isLiteral() &&
"Cannot get literal data of non-literal");
216 return reinterpret_cast<const char*
>(PtrData);
219 assert(
isLiteral() &&
"Cannot set literal data of non-literal");
220 PtrData =
const_cast<char*
>(Ptr);
224 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
228 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
239 return (Flags & Flag) != 0;
329 #endif // LLVM_CLANG_LEX_TOKEN_H
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
tok::ObjCKeywordKind getObjCKeywordID() const
Return the ObjC keyword kind.
SourceLocation getEnd() const
void setFlagValue(TokenFlags Flag, bool Val)
Set a flag to either true or false.
const char * getName() const
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
bool hasUCN() const
Returns true if this token contains a universal character name.
void setFlag(TokenFlags Flag)
Set the specified flag.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
bool needsCleaning() const
Return true if this token has trigraphs or escaped newlines in it.
bool isAnyIdentifier() const
Return true if this is a raw identifier (when lexing in raw mode) or a non-keyword identifier (when l...
One of these records is kept for each identifier that is lexed.
bool stringifiedInMacro() const
Returns true if this token is formed by macro by stringizing or charizing operator.
void setRawIdentifierData(const char *Ptr)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Token - This structure provides full information about a lexed token.
void setKind(tok::TokenKind K)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
tok::TokenKind getKind() const
bool FoundNonSkip
True if we have emitted tokens already, and now we're in an #else block or something.
void * getAnnotationValue() const
StringRef getRawIdentifier() const
getRawIdentifier - For a raw identifier token (i.e., an identifier lexed in raw mode), returns a reference to the text substring in the buffer if known.
const void * getEofData() const
void setAnnotationRange(SourceRange R)
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
void setAnnotationValue(void *val)
void setEofData(const void *D)
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix. ...
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2, Ts...Ks) const
bool isNot(tok::TokenKind K) const
Information about the conditional stack (#if directives) currently active.
SourceLocation getAnnotationEndLoc() const
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
const char * getLiteralData() const
getLiteralData - For a literal token (numeric constant, string, etc), this returns a pointer to the s...
bool WasSkipping
True if this was contained in a skipping directive, e.g., in a "\#if 0" block.
Encodes a location in the source.
void setLength(unsigned Len)
bool isAnnotation(TokenKind K)
Return true if this is any of tok::annot_* kinds.
SourceLocation getEndLoc() const
void setAnnotationEndLoc(SourceLocation L)
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
bool getFlag(TokenFlags Flag) const
Get the specified flag.
void setIdentifierInfo(IdentifierInfo *II)
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
SourceLocation getLastLoc() const
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
SourceLocation getBegin() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
bool commaAfterElided() const
Returns true if the comma after this token was elided.
SourceLocation IfLoc
Location where the conditional started.
unsigned getFlags() const
Return the internal represtation of the flags.
void setLiteralData(const char *Ptr)
bool isLiteral() const
Return true if this is a "literal", like a numeric constant, string, etc.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool hasLeadingEmptyMacro() const
Return true if this token has an empty macro before it.
Defines the clang::TokenKind enum and support functions.
Defines the clang::SourceLocation class and associated facilities.
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
unsigned getLength() const
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
void clearFlag(TokenFlags Flag)
Unset the specified flag.
bool FoundElse
True if we've seen a #else in this block.
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
bool isExpandDisabled() const
Return true if this identifier token should never be expanded in the future, due to C99 6...
bool isAnyIdentifier(TokenKind K)
Return true if this is a raw identifier or an identifier kind.
void startToken()
Reset all flags to cleared.
IdentifierInfo * getIdentifierInfo() const