diff options
Diffstat (limited to 'gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp')
-rwxr-xr-x | gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp b/gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp index 643f73bd9..aceb3b2b2 100755 --- a/gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp +++ b/gfx/angle/src/compiler/preprocessor/DirectiveParser.cpp @@ -4,19 +4,19 @@ // found in the LICENSE file. // -#include "compiler/preprocessor/DirectiveParser.h" +#include "DirectiveParser.h" #include <algorithm> +#include <cassert> #include <cstdlib> #include <sstream> -#include "common/debug.h" -#include "compiler/preprocessor/DiagnosticsBase.h" -#include "compiler/preprocessor/DirectiveHandlerBase.h" -#include "compiler/preprocessor/ExpressionParser.h" -#include "compiler/preprocessor/MacroExpander.h" -#include "compiler/preprocessor/Token.h" -#include "compiler/preprocessor/Tokenizer.h" +#include "DiagnosticsBase.h" +#include "DirectiveHandlerBase.h" +#include "ExpressionParser.h" +#include "MacroExpander.h" +#include "Token.h" +#include "Tokenizer.h" namespace { enum DirectiveType @@ -248,7 +248,7 @@ void DirectiveParser::lex(Token *token) void DirectiveParser::parseDirective(Token *token) { - ASSERT(token->type == Token::PP_HASH); + assert(token->type == Token::PP_HASH); mTokenizer->lex(token); if (isEOD(token)) @@ -314,8 +314,8 @@ void DirectiveParser::parseDirective(Token *token) parseLine(token); break; default: - UNREACHABLE(); - break; + assert(false); + break; } skipUntilEOD(mTokenizer, token); @@ -328,7 +328,7 @@ void DirectiveParser::parseDirective(Token *token) void DirectiveParser::parseDefine(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_DEFINE); + assert(getDirective(token) == DIRECTIVE_DEFINE); mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) @@ -428,7 +428,7 @@ void DirectiveParser::parseDefine(Token *token) void DirectiveParser::parseUndef(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_UNDEF); + assert(getDirective(token) == DIRECTIVE_UNDEF); mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) @@ -445,13 +445,6 @@ void DirectiveParser::parseUndef(Token *token) { mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, token->location, token->text); - return; - } - else if (iter->second.expansionCount > 0) - { - mDiagnostics->report(Diagnostics::PP_MACRO_UNDEFINED_WHILE_INVOKED, token->location, - token->text); - return; } else { @@ -470,25 +463,25 @@ void DirectiveParser::parseUndef(Token *token) void DirectiveParser::parseIf(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_IF); + assert(getDirective(token) == DIRECTIVE_IF); parseConditionalIf(token); } void DirectiveParser::parseIfdef(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_IFDEF); + assert(getDirective(token) == DIRECTIVE_IFDEF); parseConditionalIf(token); } void DirectiveParser::parseIfndef(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_IFNDEF); + assert(getDirective(token) == DIRECTIVE_IFNDEF); parseConditionalIf(token); } void DirectiveParser::parseElse(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_ELSE); + assert(getDirective(token) == DIRECTIVE_ELSE); if (mConditionalStack.empty()) { @@ -529,7 +522,7 @@ void DirectiveParser::parseElse(Token *token) void DirectiveParser::parseElif(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_ELIF); + assert(getDirective(token) == DIRECTIVE_ELIF); if (mConditionalStack.empty()) { @@ -569,7 +562,7 @@ void DirectiveParser::parseElif(Token *token) void DirectiveParser::parseEndif(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_ENDIF); + assert(getDirective(token) == DIRECTIVE_ENDIF); if (mConditionalStack.empty()) { @@ -593,7 +586,7 @@ void DirectiveParser::parseEndif(Token *token) void DirectiveParser::parseError(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_ERROR); + assert(getDirective(token) == DIRECTIVE_ERROR); std::ostringstream stream; mTokenizer->lex(token); @@ -608,7 +601,7 @@ void DirectiveParser::parseError(Token *token) // Parses pragma of form: #pragma name[(value)]. void DirectiveParser::parsePragma(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_PRAGMA); + assert(getDirective(token) == DIRECTIVE_PRAGMA); enum State { @@ -669,7 +662,7 @@ void DirectiveParser::parsePragma(Token *token) void DirectiveParser::parseExtension(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_EXTENSION); + assert(getDirective(token) == DIRECTIVE_EXTENSION); enum State { @@ -750,7 +743,7 @@ void DirectiveParser::parseExtension(Token *token) void DirectiveParser::parseVersion(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_VERSION); + assert(getDirective(token) == DIRECTIVE_VERSION); if (mPastFirstStatement) { @@ -837,7 +830,7 @@ void DirectiveParser::parseVersion(Token *token) void DirectiveParser::parseLine(Token *token) { - ASSERT(getDirective(token) == DIRECTIVE_LINE); + assert(getDirective(token) == DIRECTIVE_LINE); bool valid = true; bool parsedFileNumber = false; @@ -938,8 +931,8 @@ void DirectiveParser::parseConditionalIf(Token *token) expression = parseExpressionIfdef(token) == 0 ? 1 : 0; break; default: - UNREACHABLE(); - break; + assert(false); + break; } block.skipGroup = expression == 0; block.foundValidGroup = expression != 0; @@ -949,7 +942,8 @@ void DirectiveParser::parseConditionalIf(Token *token) int DirectiveParser::parseExpressionIf(Token *token) { - ASSERT((getDirective(token) == DIRECTIVE_IF) || (getDirective(token) == DIRECTIVE_ELIF)); + assert((getDirective(token) == DIRECTIVE_IF) || + (getDirective(token) == DIRECTIVE_ELIF)); DefinedParser definedParser(mTokenizer, mMacroSet, mDiagnostics); MacroExpander macroExpander(&definedParser, mMacroSet, mDiagnostics); @@ -976,7 +970,8 @@ int DirectiveParser::parseExpressionIf(Token *token) int DirectiveParser::parseExpressionIfdef(Token *token) { - ASSERT((getDirective(token) == DIRECTIVE_IFDEF) || (getDirective(token) == DIRECTIVE_IFNDEF)); + assert((getDirective(token) == DIRECTIVE_IFDEF) || + (getDirective(token) == DIRECTIVE_IFNDEF)); mTokenizer->lex(token); if (token->type != Token::IDENTIFIER) |