25 using namespace clang;
32 const llvm::MemoryBuffer *FromFile = SM.
getBuffer(FID);
33 Lexer RawLex(FID, FromFile, SM, LangOpts);
43 if (
Tok.
is(tok::raw_identifier)) {
46 PP.LookUpIdentifierInfo(
Tok);
50 AddToken(RawTok, TokenList.end());
59 TokenRewriter::TokenRefTy TokenRewriter::RemapIterator(
token_iterator I) {
60 if (I ==
token_end())
return TokenList.end();
64 std::map<SourceLocation, TokenRefTy>::iterator MapIt =
65 TokenAtLoc.find(I->getLocation());
66 assert(MapIt != TokenAtLoc.end() &&
"iterator not in rewriter?");
72 TokenRewriter::TokenRefTy
73 TokenRewriter::AddToken(
const Token &T, TokenRefTy Where) {
74 Where = TokenList.insert(Where, T);
76 bool InsertSuccess = TokenAtLoc.insert(std::make_pair(T.
getLocation(),
78 assert(InsertSuccess &&
"Token location already in rewriter!");
85 unsigned Len = strlen(Val);
92 Tok.
setLocation(ScratchBuf->getToken(Val, Len, Spelling));
99 return AddToken(Tok, RemapIterator(I));
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
bool LexFromRawLexer(Token &Result)
LexFromRawLexer - Lex a token from a designated raw lexer (one with no associated preprocessor object...
Defines the SourceManager interface.
token_iterator token_end() const
Token - This structure provides full information about a lexed token.
void setKind(tok::TokenKind K)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
token_iterator AddTokenBefore(token_iterator I, const char *Val)
std::list< Token >::const_iterator token_iterator
llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
void setLength(unsigned Len)
TokenRewriter(FileID FID, SourceManager &SM, const LangOptions &LO)
TokenRewriter - This creates a TokenRewriter for the file with the specified FileID.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool isNot(tok::TokenKind K) const
Dataflow Directional Tag Classes.
void setLocation(SourceLocation L)
void SetKeepWhitespaceMode(bool Val)
SetKeepWhitespaceMode - This method lets clients enable or disable whitespace retention mode...
ScratchBuffer - This class exposes a simple interface for the dynamic construction of tokens...
This class handles loading and caching of source files into memory.
void startToken()
Reset all flags to cleared.