Mercurial > hg > CbC > CbC_llvm
comparison 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 |
comparison
equal
deleted
inserted
replaced
197:af96f86c1b6d | 198:cef006dc7fd5 |
---|---|
1433 addPPCallbacks(std::unique_ptr<PPCallbacks>(Record)); | 1433 addPPCallbacks(std::unique_ptr<PPCallbacks>(Record)); |
1434 } | 1434 } |
1435 | 1435 |
1436 #ifndef noCbC | 1436 #ifndef noCbC |
1437 | 1437 |
1438 Token Preprocessor::ReadFromString(const char *src ) { | 1438 Token Preprocessor::ReadFromString(const char *src , SourceLocation Loc) { |
1439 // Push the ( "string" ) tokens into the token stream. | 1439 // Push the ( "string" ) tokens into the token stream. |
1440 Token StrTok,Result ; | 1440 MacroInfo *MI = AllocateMacroInfo(Loc); |
1441 std::string str(src); | 1441 Token Tok,FirstTok,Result; |
1442 CreateString(str, StrTok); | 1442 bool Invalid = false; |
1443 auto ToksCopy = std::make_unique<Token[]>(1); | 1443 Lexer lx(CurLexer->getFileID(),getSourceManager().getBuffer(CurLexer->getFileID(), Loc, &Invalid),*this); |
1444 ToksCopy[0] = StrTok; | 1444 lx.InitLexer(src,src,src + strlen(src)); |
1445 EnterTokenStream(std::move(ToksCopy), 1, | 1445 lx.Lex(Tok); |
1446 /*DisableMacroExpansion*/ true, | 1446 FirstTok = Tok; |
1447 /*IsReinject*/ true); | 1447 while (Tok.getKind() != tok::TokenKind::eof) { |
1448 Lex(Result); | 1448 MI->AddTokenToBody(Tok); |
1449 lx.Lex(Tok); | |
1450 } | |
1451 EnterMacro(Result, Loc, MI , 0 ); | |
1449 return Result; | 1452 return Result; |
1450 } | 1453 } |
1451 | 1454 |
1452 #endif | 1455 #endif |