Go to the documentation of this file.
13 #ifndef LLVM_CLANG_LEX_TOKEN_H
14 #define LLVM_CLANG_LEX_TOKEN_H
18 #include "llvm/ADT/StringRef.h"
100 return is(K1) ||
is(K2);
129 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
135 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
140 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
144 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
179 assert(
isNot(tok::raw_identifier) &&
180 "getIdentifierInfo() on a tok::raw_identifier token!");
182 "getIdentifierInfo() on an annotation token!");
188 PtrData = (
void*) II;
193 return reinterpret_cast<const void *
>(PtrData);
198 PtrData =
const_cast<void *
>(D);
205 assert(
is(tok::raw_identifier));
206 return StringRef(
reinterpret_cast<const char *
>(PtrData),
getLength());
209 assert(
is(tok::raw_identifier));
210 PtrData =
const_cast<char*
>(Ptr);
217 assert(
isLiteral() &&
"Cannot get literal data of non-literal");
218 return reinterpret_cast<const char*
>(PtrData);
221 assert(
isLiteral() &&
"Cannot set literal data of non-literal");
222 PtrData =
const_cast<char*
>(Ptr);
226 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
230 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
241 return (Flags & Flag) != 0;
333 #endif // LLVM_CLANG_LEX_TOKEN_H
void startToken()
Reset all flags to cleared.
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
bool hasUCN() const
Returns true if this token contains a universal character name.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
void setEofData(const void *D)
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
A trivial tuple used to represent a source range.
const void * getEofData() const
const char * getLiteralData() const
getLiteralData - For a literal token (numeric constant, string, etc), this returns a pointer to the s...
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
SourceLocation getBegin() const
bool isExpandDisabled() const
Return true if this identifier token should never be expanded in the future, due to C99 6....
SourceLocation getEndLoc() const
IdentifierInfo * getIdentifierInfo() const
void setAnnotationEndLoc(SourceLocation L)
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
void setIdentifierInfo(IdentifierInfo *II)
void setAnnotationRange(SourceRange R)
Token - This structure provides full information about a lexed token.
bool FoundElse
True if we've seen a #else in this block.
bool commaAfterElided() const
Returns true if the comma after this token was elided.
void setRawIdentifierData(const char *Ptr)
SourceLocation getEnd() const
void setFlagValue(TokenFlags Flag, bool Val)
Set a flag to either true or false.
tok::TokenKind getKind() const
void * getAnnotationValue() 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)) {....
void setAnnotationValue(void *val)
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
Information about the conditional stack (#if directives) currently active.
bool needsCleaning() const
Return true if this token has trigraphs or escaped newlines in it.
SourceLocation getAnnotationEndLoc() const
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
bool isAnyIdentifier() const
Return true if this is a raw identifier (when lexing in raw mode) or a non-keyword identifier (when l...
bool isNot(tok::TokenKind K) const
bool isOneOf(tok::TokenKind K1, Ts... Ks) const
StringRef getRawIdentifier() const
getRawIdentifier - For a raw identifier token (i.e., an identifier lexed in raw mode),...
bool isLiteral() const
Return true if this is a "literal", like a numeric constant, string, etc.
unsigned getLength() const
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void setLiteralData(const char *Ptr)
unsigned getFlags() const
Return the internal represtation of the flags.
const char * getName() const
bool WasSkipping
True if this was contained in a skipping directive, e.g., in a "\#if 0" block.
One of these records is kept for each identifier that is lexed.
void clearFlag(TokenFlags Flag)
Unset the specified flag.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
bool isEditorPlaceholder() const
Returns true if this token is an editor placeholder.
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void setLocation(SourceLocation L)
SourceLocation IfLoc
Location where the conditional started.
bool stringifiedInMacro() const
Returns true if this token is formed by macro by stringizing or charizing operator.
bool isAnnotation(TokenKind K)
Return true if this is any of tok::annot_* kinds.
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
void setLength(unsigned Len)
bool FoundNonSkip
True if we have emitted tokens already, and now we're in an #else block or something.
void setKind(tok::TokenKind K)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
SourceLocation getLastLoc() const
void setFlag(TokenFlags Flag)
Set the specified flag.
tok::ObjCKeywordKind getObjCKeywordID() const
Return the ObjC keyword kind.
bool isAnyIdentifier(TokenKind K)
Return true if this is a raw identifier or an identifier kind.
bool getFlag(TokenFlags Flag) const
Get the specified flag.
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix.
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
bool hasLeadingEmptyMacro() const
Return true if this token has an empty macro before it.