Lines Matching defs:Lexer

1 //===- Lexer.cpp - C Language Family Lexer --------------------------------===//
9 // This file implements the Lexer and Token interfaces.
13 #include "clang/Lex/Lexer.h"
123 // Lexer Class Implementation
126 void Lexer::anchor() {}
128 void Lexer::InitLexer(const char *BufStart, const char *BufPtr,
180 /// Lexer constructor - Create a new lexer object for the specified buffer
184 Lexer::Lexer(FileID FID, const llvm::MemoryBufferRef &InputFile,
196 /// Lexer constructor - Create a new raw lexer object. This object is only
199 Lexer::Lexer(SourceLocation fileloc, const LangOptions &langOpts,
210 /// Lexer constructor - Create a new raw lexer object. This object is only
213 Lexer::Lexer(FileID FID, const llvm::MemoryBufferRef &FromFile,
216 : Lexer(SM.getLocForStartOfFile(FID), langOpts, FromFile.getBufferStart(),
220 void Lexer::resetExtendedTokenMode() {
228 /// Create_PragmaLexer: Lexer constructor - Create a new lexer object for
230 /// sets up. It returns a new'd Lexer that must be delete'd when done.
243 Lexer *Lexer::Create_PragmaLexer(SourceLocation SpellingLoc,
252 Lexer *L = new Lexer(SpellingFID, InputFile, PP);
278 void Lexer::seek(unsigned Offset, bool IsAtStartOfLine) {
310 std::string Lexer::Stringify(StringRef Str, bool Charify) {
317 void Lexer::Stringify(SmallVectorImpl<char> &Str) { StringifyImpl(Str, '"'); }
335 auto CharAndSize = Lexer::getCharAndSizeNoWarn(BufPtr, LangOpts);
364 auto CharAndSize = Lexer::getCharAndSizeNoWarn(BufPtr, LangOpts);
379 StringRef Lexer::getSpelling(SourceLocation loc,
398 Lexer lexer(SM.getLocForStartOfFile(locInfo.first), options,
420 std::string Lexer::getSpelling(const Token &Tok, const SourceManager &SourceMgr,
452 unsigned Lexer::getSpelling(const Token &Tok, const char *&Buffer,
499 unsigned Lexer::MeasureTokenLength(SourceLocation Loc,
510 bool Lexer::getRawToken(SourceLocation Loc, Token &Result,
517 // Lexer::isObviouslySimpleCharacter for example to handle identifiers or
535 Lexer TheLexer(SM.getLocForStartOfFile(LocInfo.first), LangOpts,
552 !Lexer::isNewLineEscaped(BufStart, LexStart)) {
583 Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
609 SourceLocation Lexer::GetBeginningOfToken(SourceLocation Loc,
637 PreambleBounds Lexer::ComputePreamble(StringRef Buffer,
645 Lexer TheLexer(FileLoc, LangOpts, Buffer.begin(), Buffer.begin(),
791 unsigned Lexer::getTokenPrefixLength(SourceLocation TokStart, unsigned CharNo,
801 if (Invalid || (CharNo == 0 && Lexer::isObviouslySimpleCharacter(*TokPtr)))
809 while (Lexer::isObviouslySimpleCharacter(*TokPtr)) {
820 auto CharAndSize = Lexer::getCharAndSizeNoWarn(TokPtr, LangOpts);
829 if (!Lexer::isObviouslySimpleCharacter(*TokPtr))
830 PhysOffset += Lexer::SkipEscapedNewLines(TokPtr)-TokPtr;
850 SourceLocation Lexer::getLocForEndOfToken(SourceLocation Loc, unsigned Offset,
861 unsigned Len = Lexer::MeasureTokenLength(Loc, SM, LangOpts);
872 bool Lexer::isAtStartOfMacroExpansion(SourceLocation loc,
894 bool Lexer::isAtEndOfMacroExpansion(SourceLocation loc,
927 End = Lexer::getLocForEndOfToken(End, 0, SM,LangOpts);
955 CharSourceRange Lexer::makeFileCharRange(CharSourceRange Range,
1024 StringRef Lexer::getSourceText(CharSourceRange Range,
1060 StringRef Lexer::getImmediateMacroName(SourceLocation Loc,
1102 unsigned MacroTokenLength = Lexer::MeasureTokenLength(Loc, SM, LangOpts);
1107 StringRef Lexer::getImmediateMacroNameForDiagnostics(
1129 unsigned MacroTokenLength = Lexer::MeasureTokenLength(Loc, SM, LangOpts);
1134 bool Lexer::isAsciiIdentifierContinueChar(char c, const LangOptions &LangOpts) {
1138 bool Lexer::isNewLineEscaped(const char *BufferStart, const char *Str) {
1158 StringRef Lexer::getIndentationForLine(SourceLocation Loc,
1213 SourceLocation Lexer::getSourceLocation(const char *Loc,
1232 DiagnosticBuilder Lexer::Diag(const char *Loc, unsigned DiagID) const {
1261 static char DecodeTrigraphChar(const char *CP, Lexer *L, bool Trigraphs) {
1280 unsigned Lexer::getEscapedNewLineSize(const char *Ptr) {
1303 const char *Lexer::SkipEscapedNewLines(const char *P) {
1319 unsigned NewLineSize = Lexer::getEscapedNewLineSize(AfterEscape);
1325 std::optional<Token> Lexer::findNextToken(SourceLocation Loc,
1329 if (!Lexer::isAtEndOfMacroExpansion(Loc, SM, LangOpts, &Loc))
1332 Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
1346 Lexer lexer(SM.getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(),
1358 SourceLocation Lexer::findLocationAfterToken(
1404 Lexer::SizedChar Lexer::getCharAndSizeSlow(const char *Ptr, Token *Tok) {
1465 Lexer::SizedChar Lexer::getCharAndSizeSlowNoWarn(const char *Ptr,
1515 void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) {
1629 static inline CharSourceRange makeCharRange(Lexer &L, const char *Begin,
1766 bool Lexer::tryConsumeIdentifierUCN(const char *&CurPtr, unsigned Size,
1807 bool Lexer::tryConsumeIdentifierUTF8Char(const char *&CurPtr, Token &Result) {
1858 bool Lexer::LexUnicodeIdentifierStart(Token &Result, uint32_t C,
1935 bool Lexer::LexIdentifierContinue(Token &Result, const char *CurPtr) {
2016 bool Lexer::isHexaLiteral(const char *Start, const LangOptions &LangOpts) {
2017 auto CharAndSize1 = Lexer::getCharAndSizeNoWarn(Start, LangOpts);
2023 Lexer::getCharAndSizeNoWarn(Start + CharAndSize1.Size, LangOpts);
2031 bool Lexer::LexNumericConstant(Token &Result, const char *CurPtr) {
2099 const char *Lexer::LexUDSuffix(Token &Result, const char *CurPtr,
2191 bool Lexer::LexStringLiteral(Token &Result, const char *CurPtr,
2252 bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr,
2343 bool Lexer::LexAngledStringLiteral(Token &Result, const char *CurPtr) {
2385 void Lexer::codeCompleteIncludedFile(const char *PathStart,
2420 bool Lexer::LexCharConstant(Token &Result, const char *CurPtr,
2487 bool Lexer::SkipWhitespace(Token &Result, const char *CurPtr,
2563 bool Lexer::SkipLineComment(Token &Result, const char *CurPtr,
2729 bool Lexer::SaveLineComment(Token &Result, const char *CurPtr) {
2757 static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr, Lexer *L,
2845 bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr,
3065 void Lexer::ReadToEndOfLine(SmallVectorImpl<char> *Result) {
3121 bool Lexer::LexEndOfFile(Token &Result, const char *CurPtr) {
3200 unsigned Lexer::isNextPPTokenLParen() {
3264 bool Lexer::IsStartOfConflictMarker(const char *CurPtr) {
3308 bool Lexer::HandleEndOfConflictMarker(const char *CurPtr) {
3357 bool Lexer::lexEditorPlaceholder(Token &Result, const char *CurPtr) {
3376 bool Lexer::isCodeCompletionPoint(const char *CurPtr) const {
3385 std::optional<uint32_t> Lexer::tryReadNumericUCN(const char *&StartPtr,
3499 std::optional<uint32_t> Lexer::tryReadNamedUCN(const char *&StartPtr,
3593 uint32_t Lexer::tryReadUCN(const char *&StartPtr, const char *SlashLoc,
3658 bool Lexer::CheckUnicodeWhitespace(Token &Result, uint32_t C,
3671 void Lexer::PropagateLineStartLeadingSpaceInfo(Token &Result) {
3678 bool Lexer::Lex(Token &Result) {
3715 bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
4502 const char *Lexer::convertDependencyDirectiveToken(
4514 bool Lexer::LexDependencyDirectiveToken(Token &Result) {
4586 bool Lexer::LexDependencyDirectiveTokenWhileSkipping(Token &Result) {