19 using namespace clang;
26 const llvm::MemoryBuffer *FromFile = SM.
getBuffer(FID);
27 Lexer RawLex(FID, FromFile, SM, LangOpts);
37 if (Tok.is(tok::raw_identifier)) {
40 PP.LookUpIdentifierInfo(Tok);
44 AddToken(RawTok, TokenList.end());
55 TokenRewriter::TokenRefTy TokenRewriter::RemapIterator(token_iterator
I) {
56 if (I ==
token_end())
return TokenList.end();
61 TokenAtLoc.find(I->getLocation());
62 assert(MapIt != TokenAtLoc.end() &&
"iterator not in rewriter?");
69 TokenRewriter::TokenRefTy
70 TokenRewriter::AddToken(
const Token &T, TokenRefTy Where) {
71 Where = TokenList.insert(Where, T);
73 bool InsertSuccess = TokenAtLoc.insert(std::make_pair(T.
getLocation(),
75 assert(InsertSuccess &&
"Token location already in rewriter!");
83 unsigned Len = strlen(Val);
90 Tok.
setLocation(ScratchBuf->getToken(Val, Len, Spelling));
97 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.
llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
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...
detail::InMemoryDirectory::const_iterator I
std::list< Token >::const_iterator token_iterator
token_iterator token_end() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isNot(tok::TokenKind K) const
token_iterator AddTokenBefore(token_iterator I, const char *Val)
const TemplateArgument * iterator
void setLength(unsigned Len)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
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.