diff options
author | Liang Qi <liang.qi@qt.io> | 2018-10-26 10:28:24 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2018-10-26 10:28:24 +0000 |
commit | 00b2e45a97205975ee91aa43f00e3dbef1a8907b (patch) | |
tree | ed44e50bc893e87434d72470c2c809b1fb34de72 /src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp | |
parent | 9cd527bc1f384926985d63c741641316a66f17a4 (diff) | |
parent | e28e91ae99b8c3859899e04cc9370534c7c7b86d (diff) |
Merge "Merge remote-tracking branch 'origin/5.12' into dev" into refs/staging/dev
Diffstat (limited to 'src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp')
-rw-r--r-- | src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp b/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp index aeb9c46f9d..349c7b06c7 100644 --- a/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp +++ b/src/3rdparty/angle/src/compiler/preprocessor/Preprocessor.cpp @@ -4,16 +4,15 @@ // found in the LICENSE file. // -#include "Preprocessor.h" +#include "compiler/preprocessor/Preprocessor.h" -#include <cassert> - -#include "DiagnosticsBase.h" -#include "DirectiveParser.h" -#include "Macro.h" -#include "MacroExpander.h" -#include "Token.h" -#include "Tokenizer.h" +#include "common/debug.h" +#include "compiler/preprocessor/DiagnosticsBase.h" +#include "compiler/preprocessor/DirectiveParser.h" +#include "compiler/preprocessor/Macro.h" +#include "compiler/preprocessor/MacroExpander.h" +#include "compiler/preprocessor/Token.h" +#include "compiler/preprocessor/Tokenizer.h" namespace pp { @@ -26,19 +25,26 @@ struct PreprocessorImpl DirectiveParser directiveParser; MacroExpander macroExpander; - PreprocessorImpl(Diagnostics *diag, DirectiveHandler *directiveHandler) + PreprocessorImpl(Diagnostics *diag, + DirectiveHandler *directiveHandler, + const PreprocessorSettings &settings) : diagnostics(diag), tokenizer(diag), - directiveParser(&tokenizer, ¯oSet, diag, directiveHandler), - macroExpander(&directiveParser, ¯oSet, diag, false) + directiveParser(&tokenizer, + ¯oSet, + diag, + directiveHandler, + settings.maxMacroExpansionDepth), + macroExpander(&directiveParser, ¯oSet, diag, settings.maxMacroExpansionDepth) { } }; Preprocessor::Preprocessor(Diagnostics *diagnostics, - DirectiveHandler *directiveHandler) + DirectiveHandler *directiveHandler, + const PreprocessorSettings &settings) { - mImpl = new PreprocessorImpl(diagnostics, directiveHandler); + mImpl = new PreprocessorImpl(diagnostics, directiveHandler, settings); } Preprocessor::~Preprocessor() @@ -46,9 +52,7 @@ Preprocessor::~Preprocessor() delete mImpl; } -bool Preprocessor::init(size_t count, - const char * const string[], - const int length[]) +bool Preprocessor::init(size_t count, const char *const string[], const int length[]) { static const int kDefaultGLSLVersion = 100; @@ -74,23 +78,23 @@ void Preprocessor::lex(Token *token) mImpl->macroExpander.lex(token); switch (token->type) { - // We should not be returning internal preprocessing tokens. - // Convert preprocessing tokens to compiler tokens or report - // diagnostics. - case Token::PP_HASH: - assert(false); - break; - case Token::PP_NUMBER: - mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER, - token->location, token->text); - break; - case Token::PP_OTHER: - mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER, - token->location, token->text); - break; - default: - validToken = true; - break; + // We should not be returning internal preprocessing tokens. + // Convert preprocessing tokens to compiler tokens or report + // diagnostics. + case Token::PP_HASH: + UNREACHABLE(); + break; + case Token::PP_NUMBER: + mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER, token->location, + token->text); + break; + case Token::PP_OTHER: + mImpl->diagnostics->report(Diagnostics::PP_INVALID_CHARACTER, token->location, + token->text); + break; + default: + validToken = true; + break; } } } |