A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://clang.llvm.org/doxygen/PPCaching_8cpp_source.html below:

clang: lib/Lex/PPCaching.cpp Source File

15using namespace clang

;

17

std::pair<Preprocessor::CachedTokensTy::size_type, bool>

18

Preprocessor::LastBacktrackPos() {

20 auto

BacktrackPos = BacktrackPositions.back();

22 static_cast<

CachedTokensTy::difference_type

>

(BacktrackPos) < 0;

23 return

{Unannotated ? ~BacktrackPos : BacktrackPos, Unannotated};

35

assert(LexLevel == 0 &&

"cannot use lookahead while lexing"

);

36

BacktrackPositions.push_back(Unannotated ? ~CachedLexPos : CachedLexPos);

39

EnterCachingLexMode();

44 auto

[UnannotatedTokens, NumCachedToks] =

45

std::move(UnannotatedBacktrackTokens.back());

46

UnannotatedBacktrackTokens.pop_back();

50

UnannotatedBacktrackTokens.back().first.append(

51

UnannotatedTokens.begin() + NumCachedToks, UnannotatedTokens.end());

52 return

std::move(UnannotatedTokens);

58 auto

[BacktrackPos, Unannotated] = LastBacktrackPos();

59

BacktrackPositions.pop_back();

61

PopUnannotatedBacktrackTokens();

68 auto

[BacktrackPos, Unannotated] = LastBacktrackPos();

69

BacktrackPositions.pop_back();

70

CachedLexPos = BacktrackPos;

77 if

(!InCachingLexMode())

81

assert(LexLevel == 1 &&

82 "should not use token caching within the preprocessor"

);

95

EnterCachingLexModeUnchecked();

99

UnannotatedBacktrackTokens.back().first.push_back(

Result

);

104

EnterCachingLexModeUnchecked();

112void

Preprocessor::EnterCachingLexMode() {

117

assert(LexLevel == 0 &&

118 "entered caching lex mode while lexing something else"

);

120 if

(InCachingLexMode()) {

121

assert(CurLexerCallback == CLK_CachingLexer &&

"Unexpected lexer kind"

);

125

EnterCachingLexModeUnchecked();

128void

Preprocessor::EnterCachingLexModeUnchecked() {

129

assert(CurLexerCallback != CLK_CachingLexer &&

"already in caching lex mode"

);

130

PushIncludeMacroStack();

131

CurLexerCallback = CLK_CachingLexer;

135const Token

&Preprocessor::PeekAhead(

unsigned

N) {

136

assert(CachedLexPos + N >

CachedTokens

.size() &&

"Confused caching."

);

137

ExitCachingLexMode();

138 for

(

size_t C

= CachedLexPos + N -

CachedTokens

.size();

C

> 0; --

C

) {

142

UnannotatedBacktrackTokens.back().first.push_back(

CachedTokens

.back());

144

EnterCachingLexMode();

148void

Preprocessor::AnnotatePreviousCachedTokens(

const Token

&Tok) {

149

assert(Tok.

isAnnotation

() &&

"Expected annotation token"

);

150

assert(CachedLexPos != 0 &&

"Expected to have some cached tokens"

);

152

&&

"The annotation should be until the most recent cached token"

);

156 for

(CachedTokensTy::size_type i = CachedLexPos; i != 0; --i) {

157

CachedTokensTy::iterator AnnotBegin =

CachedTokens

.begin() + i-1;

158 if

(AnnotBegin->getLocation() == Tok.

getLocation

()) {

160 "The backtrack pos points inside the annotated tokens!"

);

162 if

(i < CachedLexPos)

190

assert(CachedLexPos != 0 &&

"Expected to have some cached tokens"

);

194

CachedLexPos += NewToks.size() - 1;

Defines the clang::Preprocessor interface.

bool IsPreviousCachedToken(const Token &Tok) const

Whether Tok is the most recent token (CachedLexPos - 1) in CachedTokens.

void CommitBacktrackedTokens()

Disable the last EnableBacktrackAtThisPos call.

void Lex(Token &Result)

Lex the next token for this preprocessor.

void Backtrack()

Make Preprocessor re-lex the tokens that were lexed since EnableBacktrackAtThisPos() was previously c...

SourceManager & getSourceManager() const

bool isBacktrackEnabled() const

True if EnableBacktrackAtThisPos() was called and caching of tokens is on.

bool isUnannotatedBacktrackEnabled() const

True if EnableBacktrackAtThisPos() was called and caching of unannotated tokens is on.

void recomputeCurLexerKind()

Recompute the current lexer kind based on the CurLexer/ CurTokenLexer pointers.

void ReplacePreviousCachedToken(ArrayRef< Token > NewToks)

Replace token in CachedLexPos - 1 in CachedTokens by the tokens in NewToks.

void EnableBacktrackAtThisPos(bool Unannotated=false)

From the point that this method is called, and until CommitBacktrackedTokens() or Backtrack() is call...

SourceLocation getLastCachedTokenLocation() const

Get the location of the last cached token, suitable for setting the end location of an annotation tok...

Token - This structure provides full information about a lexed token.

SourceLocation getLocation() const

Return a source location identifier for the specified offset in the current file.

SourceLocation getAnnotationEndLoc() const

tok::TokenKind getKind() const

bool isAnnotation() const

Return true if this is any of tok::annot_* kind tokens.

The JSON file list parser is used to communicate input to InstallAPI.

@ Result

The result type of a method or function.


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