13#ifndef LLVM_CLANG_LEX_TOKEN_H
14#define LLVM_CLANG_LEX_TOKEN_H
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/StringRef.h"
102 return is(K1) ||
is(K2);
136 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
142 assert(!
isAnnotation() &&
"Annotation tokens have no length field");
147 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
151 assert(
isAnnotation() &&
"Used AnnotEndLocID on non-annotation token");
188 assert(
isNot(tok::raw_identifier) &&
189 "getIdentifierInfo() on a tok::raw_identifier token!");
191 "getIdentifierInfo() on an annotation token!");
193 if (
is(tok::eof))
return nullptr;
197 PtrData = (
void*) II;
201 assert(
is(tok::eof));
202 return reinterpret_cast<const void *
>(PtrData);
205 assert(
is(tok::eof));
207 PtrData =
const_cast<void *
>(
D);
214 assert(
is(tok::raw_identifier));
215 return StringRef(
reinterpret_cast<const char *
>(PtrData),
getLength());
218 assert(
is(tok::raw_identifier));
219 PtrData =
const_cast<char*
>(Ptr);
226 assert(
isLiteral() &&
"Cannot get literal data of non-literal");
227 return reinterpret_cast<const char*
>(PtrData);
230 assert(
isLiteral() &&
"Cannot set literal data of non-literal");
231 PtrData =
const_cast<char*
>(Ptr);
235 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
239 assert(
isAnnotation() &&
"Used AnnotVal on non-annotation token");
250 return (Flags & Flag) != 0;
static constexpr bool isOneOf()
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TokenKind enum and support functions.
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Encodes a location in the source.
static SourceLocation getFromRawEncoding(UIntTy Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void setLiteralData(const char *Ptr)
bool isAnyIdentifier() const
Return true if this is a raw identifier (when lexing in raw mode) or a non-keyword identifier (when l...
SourceLocation getEndLoc() const
unsigned getFlags() const
Return the internal represtation of the flags.
void setAnnotationEndLoc(SourceLocation L)
bool hasUCN() const
Returns true if this token contains a universal character name.
void clearFlag(TokenFlags Flag)
Unset the specified flag.
bool isLiteral() const
Return true if this is a "literal", like a numeric constant, string, etc.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
const char * getName() const
unsigned getLength() const
void setLength(unsigned Len)
bool isEditorPlaceholder() const
Returns true if this token is an editor placeholder.
bool isExpandDisabled() const
Return true if this identifier token should never be expanded in the future, due to C99 6....
void setKind(tok::TokenKind K)
bool commaAfterElided() const
Returns true if the comma after this token was elided.
SourceLocation getAnnotationEndLoc() const
tok::ObjCKeywordKind getObjCKeywordID() const
Return the ObjC keyword kind.
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 * getAnnotationValue() const
bool isOneOf(tok::TokenKind K1, Ts... Ks) const
tok::TokenKind getKind() const
bool isRegularKeywordAttribute() const
Return true if the token is a keyword that is parsed in the same position as a standard attribute,...
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
void setEofData(const void *D)
bool getFlag(TokenFlags Flag) const
Get the specified flag.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
void setLocation(SourceLocation L)
bool hasLeadingEmptyMacro() const
Return true if this token has an empty macro before it.
void setRawIdentifierData(const char *Ptr)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void setAnnotationValue(void *val)
const void * getEofData() const
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix.
bool stringifiedInMacro() const
Returns true if this token is formed by macro by stringizing or charizing operator.
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
void setAnnotationRange(SourceRange R)
bool isSimpleTypeSpecifier(const LangOptions &LangOpts) const
Determine whether the token kind starts a simple-type-specifier.
void startToken()
Reset all flags to cleared.
bool needsCleaning() const
Return true if this token has trigraphs or escaped newlines in it.
void setIdentifierInfo(IdentifierInfo *II)
SourceLocation getLastLoc() const
void setFlagValue(TokenFlags Flag, bool Val)
Set a flag to either true or false.
StringRef getRawIdentifier() const
getRawIdentifier - For a raw identifier token (i.e., an identifier lexed in raw mode),...
const char * getLiteralData() const
getLiteralData - For a literal token (numeric constant, string, etc), this returns a pointer to the s...
void setFlag(TokenFlags Flag)
Set the specified flag.
const char * getTokenName(TokenKind Kind) LLVM_READNONE
Determines the name of a token as used within the front end.
bool isAnyIdentifier(TokenKind K)
Return true if this is a raw identifier or an identifier kind.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
constexpr bool isRegularKeywordAttribute(TokenKind K)
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
bool isAnnotation(TokenKind K)
Return true if this is any of tok::annot_* kinds.
The JSON file list parser is used to communicate input to InstallAPI.
Information about the conditional stack (#if directives) currently active.
bool FoundNonSkip
True if we have emitted tokens already, and now we're in an #else block or something.
SourceLocation IfLoc
Location where the conditional started.
bool WasSkipping
True if this was contained in a skipping directive, e.g., in a "\#if 0" block.
bool FoundElse
True if we've seen a #else in this block.