Mercurial > hg > CbC > CbC_llvm
changeset 54:d48478628b39
fix bug : #include
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 19 Jan 2014 02:50:31 +0900 |
parents | f679cc5126db |
children | cdd58a41c04c |
files | tools/clang/include/clang/Lex/Preprocessor.h tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Lex/PPDirectives.cpp tools/clang/lib/Lex/PPLexerChange.cpp tools/clang/lib/Lex/Preprocessor.cpp tools/clang/lib/Parse/ParseCbC.cpp tools/clang/lib/Parse/Parser.cpp |
diffstat | 7 files changed, 42 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/clang/include/clang/Lex/Preprocessor.h Sat Jan 18 23:56:19 2014 +0900 +++ b/tools/clang/include/clang/Lex/Preprocessor.h Sun Jan 19 02:50:31 2014 +0900 @@ -1559,7 +1559,10 @@ /// warnings. void markMacroAsUsed(MacroInfo *MI); #ifndef noCbC - void LexHeader(SourceLocation Loc, const char* Name); + void LexHeader(Token Tok, const char* Name); + unsigned long SavedDepth; + Token SavedToken; + bool SavedTokenFlag; #endif };
--- a/tools/clang/include/clang/Parse/Parser.h Sat Jan 18 23:56:19 2014 +0900 +++ b/tools/clang/include/clang/Parse/Parser.h Sun Jan 19 02:50:31 2014 +0900 @@ -284,11 +284,6 @@ return handleUnexpectedCodeCompletionToken(); PrevTokLocation = Tok.getLocation(); -#ifndef noCbC - if (NextToken().is(tok::kw___code)) { - IncludeHeader("setjmp.h"); - } -#endif PP.Lex(Tok); return PrevTokLocation; }
--- a/tools/clang/lib/Lex/PPDirectives.cpp Sat Jan 18 23:56:19 2014 +0900 +++ b/tools/clang/lib/Lex/PPDirectives.cpp Sun Jan 19 02:50:31 2014 +0900 @@ -2393,7 +2393,16 @@ ElifToken.getLocation()); } #ifndef noCbC -void Preprocessor::LexHeader(SourceLocation Loc, const char* Name) { +void Preprocessor::LexHeader(Token Tok, const char* Name) { + SourceLocation Loc = Tok.getLocation(); + SavedToken = Tok; + SavedDepth = IncludeMacroStack.size(); + SavedTokenFlag = true; + bool isExit = false; + if (CurPPLexer == NULL) { + ExitCachingLexMode(); + isExit = true; + } CurPPLexer->ParsingPreprocessorDirective = true; if (CurLexer) CurLexer->SetKeepWhitespaceMode(false); CurPPLexer->MIOpt.resetImmediatelyAfterTopLevelIfndef();
--- a/tools/clang/lib/Lex/PPLexerChange.cpp Sat Jan 18 23:56:19 2014 +0900 +++ b/tools/clang/lib/Lex/PPLexerChange.cpp Sun Jan 19 02:50:31 2014 +0900 @@ -385,7 +385,6 @@ // We're done with the #included file. RemoveTopOfLexerStack(); - // Propagate info about start-of-line/leading white-space/etc. PropagateLineStartLeadingSpaceInfo(Result); @@ -396,7 +395,24 @@ Callbacks->FileChanged(CurPPLexer->getSourceLocation(), PPCallbacks::ExitFile, FileType, ExitedFID); } +#ifndef noCbC + if (SavedTokenFlag && IncludeMacroStack.size() == SavedDepth){ + Result = SavedToken; + SavedTokenFlag = false; + if (CurLexer->ParsingPreprocessorDirective) { + // Done parsing the "line". + CurLexer->ParsingPreprocessorDirective = false; + // 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; + } + return true; + } +#endif // Client should lex another token unless we generated an EOM. return LeavingSubmodule; }
--- a/tools/clang/lib/Lex/Preprocessor.cpp Sat Jan 18 23:56:19 2014 +0900 +++ b/tools/clang/lib/Lex/Preprocessor.cpp Sun Jan 19 02:50:31 2014 +0900 @@ -136,6 +136,9 @@ assert(Target && "Must provide target information for PP initialization"); Initialize(*Target); } +#ifndef noCbC + SavedTokenFlag = false; +#endif } Preprocessor::~Preprocessor() {
--- a/tools/clang/lib/Parse/ParseCbC.cpp Sat Jan 18 23:56:19 2014 +0900 +++ b/tools/clang/lib/Parse/ParseCbC.cpp Sun Jan 19 02:50:31 2014 +0900 @@ -727,7 +727,8 @@ SourceLocation Loc = Tok.getLocation(); LookupResult R(Actions, CreateIdentifierInfo("setjmp", Loc), Loc, Actions.LookupOrdinaryName, Actions.ForRedeclaration); if (!Actions.LookupName(R, getCurScope())){ - PP.LexHeader(Tok.getLocation(), HeaderName); + PP.LexHeader(Tok, HeaderName); + ConsumeToken(); } } #endif
--- a/tools/clang/lib/Parse/Parser.cpp Sat Jan 18 23:56:19 2014 +0900 +++ b/tools/clang/lib/Parse/Parser.cpp Sun Jan 19 02:50:31 2014 +0900 @@ -889,6 +889,12 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs, ParsingDeclSpec &DS, AccessSpecifier AS) { +#ifndef noCbC + if (Tok.is(tok::kw___code)) { + IncludeHeader("setjmp.h"); + } +#endif + // Parse the common declaration-specifiers piece. ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DSC_top_level);