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();
60 std::map<SourceLocation, TokenRefTy>::iterator MapIt =
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));
bool LexFromRawLexer(Token &Result)
Defines the SourceManager interface.
llvm::MemoryBuffer * getBuffer(FileID FID, SourceLocation Loc, bool *Invalid=nullptr) const
Return the buffer for the specified FileID.
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...
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)
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)
This class handles loading and caching of source files into memory.
void startToken()
Reset all flags to cleared.