DiagnosticBuilder;
81 voidanchor()
override;
87 const char*BufferStart;
90 const char*BufferEnd;
122 unsigned charExtendedTokenMode;
131 const char*BufferPtr;
135 boolIsAtStartOfLine;
137 boolIsAtPhysicalStartOfLine;
139 boolHasLeadingSpace;
141 boolHasLeadingEmptyMacro;
144 boolIsFirstTimeLexingFile;
148 const char*NewLinePtr;
158 unsignedNextDepDirectiveTokenIndex = 0;
160 voidInitLexer(
const char*BufStart,
const char*BufPtr,
const char*BufEnd);
168 boolIsFirstIncludeOfFile =
true);
174 const char*BufStart,
const char*BufPtr,
const char*BufEnd,
175 boolIsFirstIncludeOfFile =
true);
182 boolIsFirstIncludeOfFile =
true);
207 boolLexDependencyDirectiveToken(
Token&
Result);
211 boolLexDependencyDirectiveTokenWhileSkipping(
Token&
Result);
215 boolisDependencyDirectivesLexer()
const{
return!DepDirectives.empty(); }
220 const char*convertDependencyDirectiveToken(
221 constdependency_directives_scan::Token &DDTok, Token &
Result);
241 returnBufferPtr == BufferEnd;
249 returnExtendedTokenMode > 1;
256 "Can only retain whitespace in raw mode or -traditional-cpp");
257ExtendedTokenMode = Val ? 2 : 0;
263 returnExtendedTokenMode > 0;
271 "Can't play with comment retention state when retaining whitespace");
272ExtendedTokenMode = Mode ? 1 : 0;
285 returnStringRef(BufferStart, BufferEnd - BufferStart);
312assert(BufferPtr >= BufferStart &&
"Invalid buffer state");
313 returnBufferPtr - BufferStart;
317 void seek(
unsignedOffset,
boolIsAtStartOfLine);
322 staticstd::string
Stringify(StringRef Str,
boolCharify =
false);
365 bool*invalid =
nullptr);
380 boolIgnoreWhiteSpace =
false);
436 Range.getBegin(), End);
441 return Range.isTokenRange()
550 unsignedMaxLines = 0);
558 boolIncludeComments =
false);
564 boolIncludeComments);
575 boolSkipTrailingWhitespaceAndNewLine);
597 if(isObviouslySimpleCharacter(Ptr[0])) {
601 returngetCharAndSizeSlowNoWarn(Ptr, LangOpts);
619 boolLexTokenInternal(
Token&
Result,
boolTokAtPhysicalStartOfLine);
621 boolCheckUnicodeWhitespace(
Token&
Result, uint32_t
C,
const char*CurPtr);
623 boolLexUnicodeIdentifierStart(
Token&
Result, uint32_t
C,
const char*CurPtr);
630 voidFormTokenWithChars(
Token&
Result,
const char*TokEnd,
632 unsignedTokLen = TokEnd-BufferPtr;
633 Result.setLength(TokLen);
642 unsignedisNextPPTokenLParen();
666 static boolisObviouslySimpleCharacter(
char C) {
667 return C!=
'?'&&
C!=
'\\';
674 inline chargetAndAdvanceChar(
const char*&Ptr, Token &Tok) {
677 if(isObviouslySimpleCharacter(Ptr[0]))
return*Ptr++;
679 auto[
C,
Size] = getCharAndSizeSlow(Ptr, &Tok);
688 const char*ConsumeChar(
const char*Ptr,
unsignedSize, Token &Tok) {
695 returnPtr + getCharAndSizeSlow(Ptr, &Tok).
Size;
702 inline chargetCharAndSize(
const char*Ptr,
unsigned&Size) {
705 if(isObviouslySimpleCharacter(Ptr[0])) {
710 autoCharAndSize = getCharAndSizeSlow(Ptr);
711 Size= CharAndSize.Size;
712 returnCharAndSize.Char;
717SizedChar getCharAndSizeSlow(
const char*Ptr, Token *Tok =
nullptr);
722 static unsignedgetEscapedNewLineSize(
const char*
P);
727 static const char*SkipEscapedNewLines(
const char*
P);
731 staticSizedChar getCharAndSizeSlowNoWarn(
const char*Ptr,
732 constLangOptions &LangOpts);
737 voidSetByteOffset(
unsignedOffset,
boolStartOfLine);
739 voidPropagateLineStartLeadingSpaceInfo(Token &
Result);
741 const char*LexUDSuffix(Token &
Result,
const char*CurPtr,
742 boolIsStringLiteral);
748 boolLexIdentifierContinue(Token &
Result,
const char*CurPtr);
750 boolLexNumericConstant (Token &
Result,
const char*CurPtr);
751 boolLexStringLiteral (Token &
Result,
const char*CurPtr,
753 boolLexRawStringLiteral (Token &
Result,
const char*CurPtr,
755 boolLexAngledStringLiteral(Token &
Result,
const char*CurPtr);
756 boolLexCharConstant (Token &
Result,
const char*CurPtr,
758 boolLexEndOfFile (Token &
Result,
const char*CurPtr);
759 boolSkipWhitespace (Token &
Result,
const char*CurPtr,
760 bool&TokAtPhysicalStartOfLine);
761 boolSkipLineComment (Token &
Result,
const char*CurPtr,
762 bool&TokAtPhysicalStartOfLine);
763 boolSkipBlockComment (Token &
Result,
const char*CurPtr,
764 bool&TokAtPhysicalStartOfLine);
765 boolSaveLineComment (Token &
Result,
const char*CurPtr);
767 boolIsStartOfConflictMarker(
const char*CurPtr);
768 boolHandleEndOfConflictMarker(
const char*CurPtr);
770 boollexEditorPlaceholder(Token &
Result,
const char*CurPtr);
772 boolisCodeCompletionPoint(
const char*CurPtr)
const;
773 voidcutOffLexing() { BufferPtr = BufferEnd; }
775 boolisHexaLiteral(
const char*Start,
constLangOptions &LangOpts);
777 voidcodeCompleteIncludedFile(
const char*PathStart,
778 const char*CompletionPoint,
boolIsAngled);
780std::optional<uint32_t>
781tryReadNumericUCN(
const char*&StartPtr,
const char*SlashLoc, Token *
Result);
782std::optional<uint32_t> tryReadNamedUCN(
const char*&StartPtr,
783 const char*SlashLoc, Token *
Result);
797 uint32_ttryReadUCN(
const char*&StartPtr,
const char*SlashLoc, Token *
Result);
810 booltryConsumeIdentifierUCN(
const char*&CurPtr,
unsignedSize,
819 booltryConsumeIdentifierUTF8Char(
const char*&CurPtr, Token &
Result);
enum clang::sema::@1704::IndirectLocalPathEntry::EntryKind Kind
This is the interface for scanning header and source files to get the minimum necessary preprocessor ...
Defines the clang::LangOptions interface.
Defines the PreprocessorLexer interface.
Defines the clang::SourceLocation class and associated facilities.
Defines the clang::TokenKind enum and support functions.
__device__ __2f16 float c
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
A little helper class used to produce diagnostics.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
void SetKeepWhitespaceMode(bool Val)
SetKeepWhitespaceMode - This method lets clients enable or disable whitespace retention mode.
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
static CharSourceRange getAsCharRange(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
bool LexFromRawLexer(Token &Result)
LexFromRawLexer - Lex a token from a designated raw lexer (one with no associated preprocessor object...
bool inKeepCommentMode() const
inKeepCommentMode - Return true if the lexer should return comments as tokens.
void SetCommentRetentionState(bool Mode)
SetCommentRetentionMode - Change the comment retention mode of the lexer to the specified mode.
static std::optional< Token > findPreviousToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeComments)
Finds the token that comes before the given location.
void seek(unsigned Offset, bool IsAtStartOfLine)
Set the lexer's buffer pointer to Offset.
static StringRef getImmediateMacroName(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
void ReadToEndOfLine(SmallVectorImpl< char > *Result=nullptr)
ReadToEndOfLine - Read the rest of the current preprocessor line as an uninterpreted string.
static CharSourceRange getAsCharRange(SourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
Given a token range, produce a corresponding CharSourceRange that is not a token range.
static bool isAtStartOfMacroExpansion(SourceLocation loc, const SourceManager &SM, const LangOptions &LangOpts, SourceLocation *MacroBegin=nullptr)
Returns true if the given MacroID location points at the first token of the macro expansion.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token,...
DiagnosticBuilder Diag(const char *Loc, unsigned DiagID) const
Diag - Forwarding function for diagnostics.
StringRef getBuffer() const
Gets source code buffer.
const char * getBufferLocation() const
Return the current location in the buffer.
bool Lex(Token &Result)
Lex - Return the next token in the file.
bool isPragmaLexer() const
isPragmaLexer - Returns true if this Lexer is being used to lex a pragma.
static unsigned getTokenPrefixLength(SourceLocation TokStart, unsigned CharNo, const SourceManager &SM, const LangOptions &LangOpts)
Get the physical length (including trigraphs and escaped newlines) of the first Characters characters...
static bool isAtEndOfMacroExpansion(SourceLocation loc, const SourceManager &SM, const LangOptions &LangOpts, SourceLocation *MacroEnd=nullptr)
Returns true if the given MacroID location points at the last token of the macro expansion.
SourceLocation getSourceLocation() override
getSourceLocation - Return a source location for the next character in the current file.
static CharSourceRange makeFileCharRange(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
Accepts a range and returns a character range with file locations.
unsigned getCurrentBufferOffset()
Returns the current lexing offset.
static bool isNewLineEscaped(const char *BufferStart, const char *Str)
Checks whether new line pointed by Str is preceded by escape sequence.
SourceLocation getFileLoc() const
getFileLoc - Return the File Location for the file we are lexing out of.
static StringRef getIndentationForLine(SourceLocation Loc, const SourceManager &SM)
Returns the leading whitespace for line that corresponds to the given location Loc.
static unsigned getSpelling(const Token &Tok, const char *&Buffer, const SourceManager &SourceMgr, const LangOptions &LangOpts, bool *Invalid=nullptr)
getSpelling - This method is used to get the spelling of a token into a preallocated buffer,...
Lexer & operator=(const Lexer &)=delete
bool isKeepWhitespaceMode() const
isKeepWhitespaceMode - Return true if the lexer should return tokens for every character in the file,...
static bool isAsciiIdentifierContinueChar(char c, const LangOptions &LangOpts)
Returns true if the given character could appear in an identifier.
static std::optional< Token > findNextToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeComments=false)
Finds the token that comes right after the given location.
static unsigned MeasureTokenLength(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
MeasureTokenLength - Relex the token at the specified location and return its length in bytes in the ...
static SourceLocation GetBeginningOfToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Given a location any where in a source buffer, find the location that corresponds to the beginning of...
void resetExtendedTokenMode()
Sets the extended token mode back to its initial value, according to the language options and preproc...
static StringRef getImmediateMacroNameForDiagnostics(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
static Lexer * Create_PragmaLexer(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned TokLen, Preprocessor &PP)
Create_PragmaLexer: Lexer constructor - Create a new lexer object for _Pragma expansion.
static PreambleBounds ComputePreamble(StringRef Buffer, const LangOptions &LangOpts, unsigned MaxLines=0)
Compute the preamble of the given file.
Lexer(const Lexer &)=delete
static bool getRawToken(SourceLocation Loc, Token &Result, const SourceManager &SM, const LangOptions &LangOpts, bool IgnoreWhiteSpace=false)
Relex the token at the specified location.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
static std::string Stringify(StringRef Str, bool Charify=false)
Stringify - Convert the specified string into a C string by i) escaping '\' and " characters and ii) ...
static SizedChar getCharAndSizeNoWarn(const char *Ptr, const LangOptions &LangOpts)
getCharAndSizeNoWarn - Like the getCharAndSize method, but does not ever emit a warning.
bool isFirstTimeLexingFile() const
Check if this is the first time we're lexing the input file.
bool LexingRawMode
True if in raw mode.
const FileID FID
The SourceManager FileID corresponding to the file being lexed.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
Token - This structure provides full information about a lexed token.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
ConflictMarkerKind
ConflictMarkerKind - Kinds of conflict marker which the lexer might be recovering from.
@ CMK_Perforce
A Perforce-style conflict marker, initiated by 4 ">"s, separated by 4 "="s, and terminated by 4 "<"s.
@ CMK_None
Not within a conflict marker.
@ CMK_Normal
A normal or diff3 conflict marker, initiated by at least 7 "<"s, separated by at least 7 "="s or "|"s...
@ Result
The result type of a method or function.
Diagnostic wrappers for TextAPI types for error reporting.
Represents a char and the number of bytes parsed to produce it.
Describes the bounds (start, size) of the preamble and a flag required by PreprocessorOptions::Precom...
unsigned Size
Size of the preamble in bytes.
bool PreambleEndsAtStartOfLine
Whether the preamble ends at the start of a new line.
PreambleBounds(unsigned Size, bool PreambleEndsAtStartOfLine)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4