Mercurial > hg > CbC > CbC_llvm
changeset 200:40b1cab18437
swap CurLexer
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 04 Jun 2021 20:14:29 +0900 |
parents | 5784c86f13b3 |
children | a96fbbdf2d0f |
files | clang/lib/Lex/PPLexerChange.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Parse/ParseCbC.cpp |
diffstat | 3 files changed, 18 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/clang/lib/Lex/PPLexerChange.cpp Thu Jun 03 00:48:49 2021 +0900 +++ b/clang/lib/Lex/PPLexerChange.cpp Fri Jun 04 20:14:29 2021 +0900 @@ -471,20 +471,20 @@ } #ifndef noCbC - if (SavedTokenFlag && IncludeMacroStack.size() == SavedDepth){ + if (SavedTokenFlag && IncludeMacroStack.size() == SavedDepth){ // dead code? Result = SavedToken; SavedTokenFlag = false; - if (CurLexer->ParsingPreprocessorDirective) { - // Done parsing the "line". - CurLexer->ParsingPreprocessorDirective = false; + if (CurLexer->ParsingPreprocessorDirective) { + // Done parsing the "line". + CurLexer->ParsingPreprocessorDirective = false; - // Restore comment saving mode, in case it was disabled for directive. - CurLexer->resetExtendedTokenMode(); + // Restore comment saving mode, in case it was disabled for directive. + CurLexer->resetExtendedTokenMode(); - // Since we consumed a newline, we are back at the start of a line. - CurLexer->IsAtStartOfLine = true; - CurLexer->IsAtPhysicalStartOfLine = true; - } + // Since we consumed a newline, we are back at the start of a line. + CurLexer->IsAtStartOfLine = true; + CurLexer->IsAtPhysicalStartOfLine = true; + } return true; } #endif
--- a/clang/lib/Lex/Preprocessor.cpp Thu Jun 03 00:48:49 2021 +0900 +++ b/clang/lib/Lex/Preprocessor.cpp Fri Jun 04 20:14:29 2021 +0900 @@ -1440,15 +1440,17 @@ 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.ParsingPreprocessorDirective = true ; // to prevent from EOF sucide of CurLexer in PP - lx.Lex(Tok); + std::unique_ptr<Lexer> lx(new Lexer(CurLexer->getFileID(),getSourceManager().getBuffer(CurLexer->getFileID(), Loc, &Invalid),*this)); + lx->InitLexer(src,src,src + strlen(src)); + // lx.ParsingPreprocessorDirective = true ; // to prevent from EOF sucide of CurLexer in PP + lx->Lex(Tok); FirstTok = Tok; + CurLexer.swap(lx); while (Tok.getKind() != tok::TokenKind::eof) { MI->AddTokenToBody(Tok); - lx.Lex(Tok); + Lex(Tok); } + CurLexer = std::move(lx); EnterMacro(Result, Loc, MI , 0 ); // EnterTokenStream(&MI->ReplacementTokens,MI->getNumTokens(),true,true,false); return Result;
--- a/clang/lib/Parse/ParseCbC.cpp Thu Jun 03 00:48:49 2021 +0900 +++ b/clang/lib/Parse/ParseCbC.cpp Fri Jun 04 20:14:29 2021 +0900 @@ -241,7 +241,7 @@ CompoundStmts.push_back(innerRes.get()); // jmp_buf env_buf; --> int env_buf[64]; - Tok = PP.ReadFromString("int env_buf[64];;",Loc); + Tok = PP.ReadFromString("int env_buf[64];",Loc); ConsumeAnyToken(); // innerRes = CreateDeclStmt(bufII, false, false, 64, DeclSpec::TST_typename, CreateIdentifierInfo("int", Loc)); StmtVector Stmts;