Mercurial > hg > CbC > CbC_llvm
changeset 98:88e6d15e811d
fix proto generator bug
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 02 Nov 2015 03:57:17 +0900 |
parents | b0dd3743370f |
children | 21681fa9647e |
files | tools/clang/.git/index tools/clang/include/clang/Lex/Lexer.h tools/clang/include/clang/Lex/Preprocessor.h tools/clang/lib/Lex/Lexer.cpp tools/clang/lib/Lex/Preprocessor.cpp tools/clang/lib/Parse/ParseCbC.cpp |
diffstat | 6 files changed, 36 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/clang/include/clang/Lex/Lexer.h Wed Oct 14 19:39:58 2015 +0900 +++ b/tools/clang/include/clang/Lex/Lexer.h Mon Nov 02 03:57:17 2015 +0900 @@ -136,7 +136,11 @@ private: /// Lex - Return the next token in the file. If this is the end of file, it /// return the tok::eof token. This implicitly involves the preprocessor. +#ifndef noCbC + bool Lex(Token &Result, bool ProtoParsing = false); +#else bool Lex(Token &Result); +#endif public: /// isPragmaLexer - Returns true if this Lexer is being used to lex a pragma. @@ -465,7 +469,11 @@ /// LexTokenInternal - Internal interface to lex a preprocessing token. Called /// by Lex. /// +#ifndef noCbC + bool LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine, bool ignoreInclude = false); +#else bool LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine); +#endif bool CheckUnicodeWhitespace(Token &Result, uint32_t C, const char *CurPtr);
--- a/tools/clang/include/clang/Lex/Preprocessor.h Wed Oct 14 19:39:58 2015 +0900 +++ b/tools/clang/include/clang/Lex/Preprocessor.h Mon Nov 02 03:57:17 2015 +0900 @@ -1900,6 +1900,7 @@ bool SavedTokenFlag; void ClearCache(); void RestoreTokens(Token *Toks, unsigned NumToks); + bool ProtoParsing = false; #endif };
--- a/tools/clang/lib/Lex/Lexer.cpp Wed Oct 14 19:39:58 2015 +0900 +++ b/tools/clang/lib/Lex/Lexer.cpp Mon Nov 02 03:57:17 2015 +0900 @@ -28,6 +28,9 @@ #include <cstring> using namespace clang; +#ifndef noCbC +#include <string.h> +#endif //===----------------------------------------------------------------------===// // Token Class Implementation //===----------------------------------------------------------------------===// @@ -2861,7 +2864,11 @@ // Note that this doesn't affect IsAtPhysicalStartOfLine. } +#ifndef noCbC +bool Lexer::Lex(Token &Result, bool ProtoParsing) { +#else bool Lexer::Lex(Token &Result) { +#endif // Start a new token. Result.startToken(); @@ -2885,7 +2892,11 @@ IsAtPhysicalStartOfLine = false; bool isRawLex = isLexingRawMode(); (void) isRawLex; +#ifndef noCbC + bool returnedToken = LexTokenInternal(Result, atPhysicalStartOfLine, ProtoParsing); +#else bool returnedToken = LexTokenInternal(Result, atPhysicalStartOfLine); +#endif // (After the LexTokenInternal call, the lexer might be destroyed.) assert((returnedToken || !isRawLex) && "Raw lex must succeed"); return returnedToken; @@ -2896,7 +2907,11 @@ /// has a null character at the end of the file. This returns a preprocessing /// token, not a normal token, as such, it is an internal interface. It assumes /// that the Flags of result have been cleared before calling this. +#ifndef noCbC +bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine, bool ignoreInclude) { +#else bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) { +#endif LexNextToken: // New token, can't need cleaning yet. Result.clearFlag(Token::NeedsCleaning); @@ -3524,6 +3539,12 @@ Kind = tok::comma; break; case '#': +#ifndef noCbC + if (ignoreInclude && strncmp(CurPtr, "include", 7) == 0){ + SkipLineComment(Result, CurPtr, TokAtPhysicalStartOfLine); + return true; + } +#endif Char = getCharAndSize(CurPtr, SizeTmp); if (Char == '#') { Kind = tok::hashhash;
--- a/tools/clang/lib/Lex/Preprocessor.cpp Wed Oct 14 19:39:58 2015 +0900 +++ b/tools/clang/lib/Lex/Preprocessor.cpp Mon Nov 02 03:57:17 2015 +0900 @@ -725,7 +725,11 @@ do { switch (CurLexerKind) { case CLK_Lexer: +#ifndef noCbC + ReturnedToken = CurLexer->Lex(Result, ProtoParsing); +#else ReturnedToken = CurLexer->Lex(Result); +#endif break; case CLK_PTHLexer: ReturnedToken = CurPTHLexer->Lex(Result);
--- a/tools/clang/lib/Parse/ParseCbC.cpp Wed Oct 14 19:39:58 2015 +0900 +++ b/tools/clang/lib/Parse/ParseCbC.cpp Mon Nov 02 03:57:17 2015 +0900 @@ -971,6 +971,7 @@ Token SavedToken = Tok; Token IITok = Tok.is(tok::identifier) ? Tok : Next; PP.ClearCache(); + PP.ProtoParsing = true; ProtoParsing = true; const DirectoryLookup *CurDir = nullptr; @@ -1005,9 +1006,8 @@ Actions.CurContext = SavedContext; Actions.FunctionScopes.push_back(SavedFSI); - - ProtoParsing = false; + PP.ProtoParsing = false; } static bool HasFlagsSet(Parser::SkipUntilFlags L, Parser::SkipUntilFlags R) {