//===--- PPCaching.cpp - Handle caching lexed tokens ----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements pieces of the Preprocessor interface that manage the // caching of lexed tokens. // //===----------------------------------------------------------------------===// #include "clang/Lex/Preprocessor.h" usingnamespaceclang; std::pair<Preprocessor::CachedTokensTy::size_type, bool> Preprocessor::LastBacktrackPos() { … } // EnableBacktrackAtThisPos - From the point that this method is called, and // until CommitBacktrackedTokens() or Backtrack() is called, the Preprocessor // keeps track of the lexed tokens so that a subsequent Backtrack() call will // make the Preprocessor re-lex the same tokens. // // Nested backtracks are allowed, meaning that EnableBacktrackAtThisPos can // be called multiple times and CommitBacktrackedTokens/Backtrack calls will // be combined with the EnableBacktrackAtThisPos calls in reverse order. void Preprocessor::EnableBacktrackAtThisPos(bool Unannotated) { … } Preprocessor::CachedTokensTy Preprocessor::PopUnannotatedBacktrackTokens() { … } // Disable the last EnableBacktrackAtThisPos call. void Preprocessor::CommitBacktrackedTokens() { … } // Make Preprocessor re-lex the tokens that were lexed since // EnableBacktrackAtThisPos() was previously called. void Preprocessor::Backtrack() { … } void Preprocessor::CachingLex(Token &Result) { … } void Preprocessor::EnterCachingLexMode() { … } void Preprocessor::EnterCachingLexModeUnchecked() { … } const Token &Preprocessor::PeekAhead(unsigned N) { … } void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) { … } bool Preprocessor::IsPreviousCachedToken(const Token &Tok) const { … } void Preprocessor::ReplacePreviousCachedToken(ArrayRef<Token> NewToks) { … }