14 #ifndef LLVM_CLANG_LEX_TOKEN_H 15 #define LLVM_CLANG_LEX_TOKEN_H 19 #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");
240 return (Flags & Flag) != 0;
337 #endif // LLVM_CLANG_LEX_TOKEN_H SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void setFlagValue(TokenFlags Flag, bool Val)
Set a flag to either true or false.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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 setFlag(TokenFlags Flag)
Set the specified flag.
bool isAnyIdentifier() const
Return true if this is a raw identifier (when lexing in raw mode) or a non-keyword identifier (when l...
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
tok::TokenKind getKind() const
bool isLiteral() const
Return true if this is a "literal", like a numeric constant, string, etc.
One of these records is kept for each identifier that is lexed.
SourceLocation getAnnotationEndLoc() const
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)
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix. ...
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
bool commaAfterElided() const
Returns true if the comma after this token was elided.
bool FoundNonSkip
True if we have emitted tokens already, and now we're in an #else block or something.
const char * getName() const
void setAnnotationRange(SourceRange R)
void setAnnotationValue(void *val)
bool hasLeadingEmptyMacro() const
Return true if this token has an empty macro before it.
void setEofData(const void *D)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Information about the conditional stack (#if directives) currently active.
SourceLocation getEnd() const
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
bool isExpandDisabled() const
Return true if this identifier token should never be expanded in the future, due to C99 6...
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.
IdentifierInfo * getIdentifierInfo() const
void setAnnotationEndLoc(SourceLocation L)
void setIdentifierInfo(IdentifierInfo *II)
const void * getEofData() const
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
tok::ObjCKeywordKind getObjCKeywordID() const
Return the ObjC keyword kind.
SourceLocation IfLoc
Location where the conditional started.
bool isNot(tok::TokenKind K) const
Dataflow Directional Tag Classes.
bool getFlag(TokenFlags Flag) const
Get the specified flag.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
unsigned getLength() const
void setLiteralData(const char *Ptr)
const char * getLiteralData() const
getLiteralData - For a literal token (numeric constant, string, etc), this returns a pointer to the s...
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2, Ts... Ks) const
Defines the clang::TokenKind enum and support functions.
Defines the clang::SourceLocation class and associated facilities.
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.
SourceLocation getLastLoc() const
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
bool needsCleaning() const
Return true if this token has trigraphs or escaped newlines in it.
bool stringifiedInMacro() const
Returns true if this token is formed by macro by stringizing or charizing operator.
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
unsigned getFlags() const
Return the internal represtation of the flags.
void clearFlag(TokenFlags Flag)
Unset the specified flag.
bool hasUCN() const
Returns true if this token contains a universal character name.
bool isEditorPlaceholder() const
Returns true if this token is an editor placeholder.
bool FoundElse
True if we've seen a #else in this block.
void * getAnnotationValue() const
SourceLocation getBegin() const
bool isAnyIdentifier(TokenKind K)
Return true if this is a raw identifier or an identifier kind.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
void startToken()
Reset all flags to cleared.
SourceLocation getEndLoc() const