Mercurial > hg > CbC > CbC_llvm
diff clang/lib/Lex/Preprocessor.cpp @ 198:cef006dc7fd5
CurLexer vanish after EnterMacro finish
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 02 Jun 2021 23:09:47 +0900 |
parents | af96f86c1b6d |
children | 5784c86f13b3 |
line wrap: on
line diff
--- a/clang/lib/Lex/Preprocessor.cpp Wed Jun 02 11:22:01 2021 +0900 +++ b/clang/lib/Lex/Preprocessor.cpp Wed Jun 02 23:09:47 2021 +0900 @@ -1435,17 +1435,20 @@ #ifndef noCbC -Token Preprocessor::ReadFromString(const char *src ) { +Token Preprocessor::ReadFromString(const char *src , SourceLocation Loc) { // Push the ( "string" ) tokens into the token stream. - Token StrTok,Result ; - std::string str(src); - CreateString(str, StrTok); - auto ToksCopy = std::make_unique<Token[]>(1); - ToksCopy[0] = StrTok; - EnterTokenStream(std::move(ToksCopy), 1, - /*DisableMacroExpansion*/ true, - /*IsReinject*/ true); - Lex(Result); + MacroInfo *MI = AllocateMacroInfo(Loc); + Token Tok,FirstTok,Result; + bool Invalid = false; + Lexer lx(CurLexer->getFileID(),getSourceManager().getBuffer(CurLexer->getFileID(), Loc, &Invalid),*this); + lx.InitLexer(src,src,src + strlen(src)); + lx.Lex(Tok); + FirstTok = Tok; + while (Tok.getKind() != tok::TokenKind::eof) { + MI->AddTokenToBody(Tok); + lx.Lex(Tok); + } + EnterMacro(Result, Loc, MI , 0 ); return Result; }