Mercurial > hg > CbC > CbC_llvm
comparison 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 |
comparison
equal
deleted
inserted
replaced
208:874d1390268d | 209:dd44ba33042e |
---|---|
144 Ident___exception_code = Ident___abnormal_termination = nullptr; | 144 Ident___exception_code = Ident___abnormal_termination = nullptr; |
145 Ident_GetExceptionInfo = Ident_GetExceptionCode = nullptr; | 145 Ident_GetExceptionInfo = Ident_GetExceptionCode = nullptr; |
146 Ident_AbnormalTermination = nullptr; | 146 Ident_AbnormalTermination = nullptr; |
147 } | 147 } |
148 | 148 |
149 | |
149 // If using a PCH where a #pragma hdrstop is expected, start skipping tokens. | 150 // If using a PCH where a #pragma hdrstop is expected, start skipping tokens. |
150 if (usingPCHWithPragmaHdrStop()) | 151 if (usingPCHWithPragmaHdrStop()) |
151 SkippingUntilPragmaHdrStop = true; | 152 SkippingUntilPragmaHdrStop = true; |
152 | 153 |
153 // If using a PCH with a through header, start skipping tokens. | 154 // If using a PCH with a through header, start skipping tokens. |
154 if (!this->PPOpts->PCHThroughHeader.empty() && | 155 if (!this->PPOpts->PCHThroughHeader.empty() && |
155 !this->PPOpts->ImplicitPCHInclude.empty()) | 156 !this->PPOpts->ImplicitPCHInclude.empty()) |
156 SkippingUntilPCHThroughHeader = true; | 157 SkippingUntilPCHThroughHeader = true; |
158 | |
159 #ifndef noCbC | |
160 SavedDepth = 0; | |
161 SavedTokenFlag = false; | |
162 #endif | |
157 | 163 |
158 if (this->PPOpts->GeneratePreamble) | 164 if (this->PPOpts->GeneratePreamble) |
159 PreambleConditionalStack.startRecording(); | 165 PreambleConditionalStack.startRecording(); |
160 | 166 |
161 ExcludedConditionalDirectiveSkipMappings = | 167 ExcludedConditionalDirectiveSkipMappings = |
889 // We loop here until a lex function returns a token; this avoids recursion. | 895 // We loop here until a lex function returns a token; this avoids recursion. |
890 bool ReturnedToken; | 896 bool ReturnedToken; |
891 do { | 897 do { |
892 switch (CurLexerKind) { | 898 switch (CurLexerKind) { |
893 case CLK_Lexer: | 899 case CLK_Lexer: |
900 #ifndef noCbC | |
901 ReturnedToken = CurLexer->Lex(Result, ProtoParsing); | |
902 #else | |
894 ReturnedToken = CurLexer->Lex(Result); | 903 ReturnedToken = CurLexer->Lex(Result); |
904 #endif | |
895 break; | 905 break; |
896 case CLK_TokenLexer: | 906 case CLK_TokenLexer: |
897 ReturnedToken = CurTokenLexer->Lex(Result); | 907 ReturnedToken = CurTokenLexer->Lex(Result); |
898 break; | 908 break; |
899 case CLK_CachingLexer: | 909 case CLK_CachingLexer: |
1420 return; | 1430 return; |
1421 | 1431 |
1422 Record = new PreprocessingRecord(getSourceManager()); | 1432 Record = new PreprocessingRecord(getSourceManager()); |
1423 addPPCallbacks(std::unique_ptr<PPCallbacks>(Record)); | 1433 addPPCallbacks(std::unique_ptr<PPCallbacks>(Record)); |
1424 } | 1434 } |
1435 | |
1436 #ifndef noCbC | |
1437 | |
1438 Token Preprocessor::ReadFromString(const char *src , SourceLocation Loc) { | |
1439 // Push the ( "string" ) tokens into the token stream. | |
1440 MacroInfo *MI = AllocateMacroInfo(Loc); | |
1441 Token Tok; | |
1442 bool Invalid = false; | |
1443 std::unique_ptr<Lexer> lx(new Lexer(CurLexer->getFileID(),getSourceManager().getBuffer(CurLexer->getFileID(), Loc, &Invalid),*this)); | |
1444 lx->InitLexer(src,src,src + strlen(src)); | |
1445 lx->Lex(Tok); | |
1446 CurLexer.swap(lx); | |
1447 int i = 0; | |
1448 while (Tok.getKind() != tok::TokenKind::eof) { | |
1449 Tok.setLocation(Loc); | |
1450 MI->AddTokenToBody(Tok); | |
1451 Lex(Tok); i++; | |
1452 } | |
1453 Tok.setLocation(Loc); | |
1454 MI->AddTokenToBody(Tok); i++; | |
1455 MI->DefinitionLength = i; | |
1456 CurLexer = std::move(lx); | |
1457 CurPPLexer = CurLexer.get(); | |
1458 EnterMacro(Tok, Loc, MI , 0 ); | |
1459 CurTokenLexer->MacroDefLength = i; | |
1460 return Tok; | |
1461 } | |
1462 | |
1463 #endif |