Mercurial > hg > CbC > CbC_llvm
diff clang/lib/Lex/Preprocessor.cpp @ 209:dd44ba33042e
merged...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:36:09 +0900 |
parents | 2e18cbf3894f b7591485f4cd |
children | 50b3abffaea6 |
line wrap: on
line diff
--- a/clang/lib/Lex/Preprocessor.cpp Tue Jun 08 06:08:56 2021 +0900 +++ b/clang/lib/Lex/Preprocessor.cpp Tue Jun 08 06:36:09 2021 +0900 @@ -146,6 +146,7 @@ Ident_AbnormalTermination = nullptr; } + // If using a PCH where a #pragma hdrstop is expected, start skipping tokens. if (usingPCHWithPragmaHdrStop()) SkippingUntilPragmaHdrStop = true; @@ -155,6 +156,11 @@ !this->PPOpts->ImplicitPCHInclude.empty()) SkippingUntilPCHThroughHeader = true; + #ifndef noCbC + SavedDepth = 0; + SavedTokenFlag = false; +#endif + if (this->PPOpts->GeneratePreamble) PreambleConditionalStack.startRecording(); @@ -891,7 +897,11 @@ do { switch (CurLexerKind) { case CLK_Lexer: +#ifndef noCbC + ReturnedToken = CurLexer->Lex(Result, ProtoParsing); +#else ReturnedToken = CurLexer->Lex(Result); +#endif break; case CLK_TokenLexer: ReturnedToken = CurTokenLexer->Lex(Result); @@ -1422,3 +1432,32 @@ Record = new PreprocessingRecord(getSourceManager()); addPPCallbacks(std::unique_ptr<PPCallbacks>(Record)); } + +#ifndef noCbC + +Token Preprocessor::ReadFromString(const char *src , SourceLocation Loc) { + // Push the ( "string" ) tokens into the token stream. + MacroInfo *MI = AllocateMacroInfo(Loc); + Token Tok; + bool Invalid = false; + std::unique_ptr<Lexer> lx(new Lexer(CurLexer->getFileID(),getSourceManager().getBuffer(CurLexer->getFileID(), Loc, &Invalid),*this)); + lx->InitLexer(src,src,src + strlen(src)); + lx->Lex(Tok); + CurLexer.swap(lx); + int i = 0; + while (Tok.getKind() != tok::TokenKind::eof) { + Tok.setLocation(Loc); + MI->AddTokenToBody(Tok); + Lex(Tok); i++; + } + Tok.setLocation(Loc); + MI->AddTokenToBody(Tok); i++; + MI->DefinitionLength = i; + CurLexer = std::move(lx); + CurPPLexer = CurLexer.get(); + EnterMacro(Tok, Loc, MI , 0 ); + CurTokenLexer->MacroDefLength = i; + return Tok; +} + +#endif