14 #ifndef LLVM_CLANG_LEX_TOKEN_H
15 #define LLVM_CLANG_LEX_TOKEN_H
21 #include "llvm/ADT/StringRef.h"
98 return is(K1) ||
is(K2);
100 template <
typename... Ts>
128 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
134 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
139 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
143 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
178 assert(
isNot(tok::raw_identifier) &&
179 "getIdentifierInfo() on a tok::raw_identifier token!");
181 "getIdentifierInfo() on an annotation token!");
187 PtrData = (
void*) II;
192 return reinterpret_cast<const void *
>(PtrData);
197 PtrData =
const_cast<void *
>(D);
204 assert(
is(tok::raw_identifier));
205 return StringRef(reinterpret_cast<const char *>(PtrData),
getLength());
208 assert(
is(tok::raw_identifier));
209 PtrData =
const_cast<char*
>(Ptr);
216 assert(
isLiteral() &&
"Cannot get literal data of non-literal");
217 return reinterpret_cast<const char*
>(PtrData);
220 assert(
isLiteral() &&
"Cannot set literal data of non-literal");
221 PtrData =
const_cast<char*
>(Ptr);
225 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
229 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
bool isAtStartOfLine() const
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...
bool stringifiedInMacro() const
void setRawIdentifierData(const char *Ptr)
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
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. Only useful in Skipping blocks.
Defines the clang::TemplateNameKind enum.
void * getAnnotationValue() const
StringRef getRawIdentifier() const
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)
Defines an enumeration for C++ overloaded operators.
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
bool WasSkipping
True if this was contained in a skipping directive, e.g., in a "\#if 0" block.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
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.
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
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. If so, #elif/#else directives are not allowed.
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