Commit fd22cfc8 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Remove RETURN_IF* part 16

Bug: v8:8363, v8:7926
Change-Id: I9f0b9e25cf6b47c8ff32451880e348b92ab3cfaa
Reviewed-on: https://chromium-review.googlesource.com/c/1309760
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57172}
parent 517331c5
...@@ -449,9 +449,7 @@ class FunctionDeclaration final : public Declaration { ...@@ -449,9 +449,7 @@ class FunctionDeclaration final : public Declaration {
friend class AstNodeFactory; friend class AstNodeFactory;
FunctionDeclaration(VariableProxy* proxy, FunctionLiteral* fun, int pos) FunctionDeclaration(VariableProxy* proxy, FunctionLiteral* fun, int pos)
: Declaration(proxy, pos, kFunctionDeclaration), fun_(fun) { : Declaration(proxy, pos, kFunctionDeclaration), fun_(fun) {}
DCHECK_NOT_NULL(fun);
}
FunctionLiteral* fun_; FunctionLiteral* fun_;
}; };
......
...@@ -1547,7 +1547,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() { ...@@ -1547,7 +1547,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
if (impl()->IsEvalOrArguments(name)) { if (impl()->IsEvalOrArguments(name)) {
if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) { if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) {
ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer); ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer);
return impl()->NullIdentifier(); return impl()->EmptyIdentifierString();
} }
classifier()->RecordStrictModeFormalParameterError( classifier()->RecordStrictModeFormalParameterError(
...@@ -1575,7 +1575,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() { ...@@ -1575,7 +1575,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
return impl()->GetSymbol(); return impl()->GetSymbol();
} else { } else {
ReportUnexpectedToken(next); ReportUnexpectedToken(next);
return impl()->NullIdentifier(); return impl()->EmptyIdentifierString();
} }
} }
...@@ -1594,7 +1594,7 @@ ParserBase<Impl>::ParseIdentifierOrStrictReservedWord( ...@@ -1594,7 +1594,7 @@ ParserBase<Impl>::ParseIdentifierOrStrictReservedWord(
*is_strict_reserved = true; *is_strict_reserved = true;
} else { } else {
ReportUnexpectedToken(next); ReportUnexpectedToken(next);
return impl()->NullIdentifier(); return impl()->EmptyIdentifierString();
} }
return impl()->GetSymbol(); return impl()->GetSymbol();
...@@ -1606,7 +1606,7 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName() { ...@@ -1606,7 +1606,7 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName() {
if (!Token::IsAnyIdentifier(next) && next != Token::ESCAPED_KEYWORD && if (!Token::IsAnyIdentifier(next) && next != Token::ESCAPED_KEYWORD &&
!Token::IsKeyword(next)) { !Token::IsKeyword(next)) {
ReportUnexpectedToken(next); ReportUnexpectedToken(next);
return impl()->NullIdentifier(); return impl()->EmptyIdentifierString();
} }
return impl()->GetSymbol(); return impl()->GetSymbol();
...@@ -1628,7 +1628,6 @@ ParserBase<Impl>::ParseIdentifierNameOrPrivateName() { ...@@ -1628,7 +1628,6 @@ ParserBase<Impl>::ParseIdentifierNameOrPrivateName() {
name = ParseIdentifierName(); name = ParseIdentifierName();
key = factory()->NewStringLiteral(name, pos); key = factory()->NewStringLiteral(name, pos);
} }
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(name); impl()->PushLiteralName(name);
return key; return key;
} }
...@@ -2131,7 +2130,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName( ...@@ -2131,7 +2130,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
if (*kind == ParsePropertyKind::kNotSet) { if (*kind == ParsePropertyKind::kNotSet) {
ParsePropertyKindFromToken(peek(), kind); ParsePropertyKindFromToken(peek(), kind);
} }
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(*name); impl()->PushLiteralName(*name);
return is_array_index ? factory()->NewNumberLiteral(index, pos) return is_array_index ? factory()->NewNumberLiteral(index, pos)
: factory()->NewStringLiteral(*name, pos); : factory()->NewStringLiteral(*name, pos);
...@@ -2705,8 +2703,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN) { ...@@ -2705,8 +2703,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN) {
} }
scope->set_start_position(lhs_beg_pos); scope->set_start_position(lhs_beg_pos);
// TODO(verwaest): Disable DCHECKs in failure mode?
RETURN_IF_PARSE_ERROR;
impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc); impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc);
expression = expression =
...@@ -3837,8 +3833,6 @@ ParserBase<Impl>::ParseHoistableDeclaration( ...@@ -3837,8 +3833,6 @@ ParserBase<Impl>::ParseHoistableDeclaration(
} }
FuncNameInferrerState fni_state(&fni_); FuncNameInferrerState fni_state(&fni_);
// TODO(verwaest): Remove once we have FailureIdentifier.
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
impl()->PushEnclosingName(name); impl()->PushEnclosingName(name);
FunctionKind kind = FunctionKindFor(flags); FunctionKind kind = FunctionKindFor(flags);
...@@ -3862,7 +3856,6 @@ ParserBase<Impl>::ParseHoistableDeclaration( ...@@ -3862,7 +3856,6 @@ ParserBase<Impl>::ParseHoistableDeclaration(
!scope()->is_declaration_scope() && !scope()->is_declaration_scope() &&
flags == ParseFunctionFlag::kIsNormal; flags == ParseFunctionFlag::kIsNormal;
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareFunction(variable_name, function, mode, pos, return impl()->DeclareFunction(variable_name, function, mode, pos,
is_sloppy_block_function, names); is_sloppy_block_function, names);
} }
...@@ -3904,7 +3897,6 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration( ...@@ -3904,7 +3897,6 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
ExpressionT value = ParseClassLiteral(name, scanner()->location(), ExpressionT value = ParseClassLiteral(name, scanner()->location(),
is_strict_reserved, class_token_pos); is_strict_reserved, class_token_pos);
int end_pos = position(); int end_pos = position();
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareClass(variable_name, value, names, class_token_pos, return impl()->DeclareClass(variable_name, value, names, class_token_pos,
end_pos); end_pos);
} }
...@@ -4138,7 +4130,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -4138,7 +4130,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
base::ElapsedTimer timer; base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start(); if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
DCHECK_EQ(Token::ARROW, peek()); DCHECK_IMPLIES(!has_error(), peek() == Token::ARROW);
if (scanner_->HasLineTerminatorBeforeNext()) { if (scanner_->HasLineTerminatorBeforeNext()) {
// ASI inserts `;` after arrow parameters if a line terminator is found. // ASI inserts `;` after arrow parameters if a line terminator is found.
// `=> ...` is never a valid expression, so report as syntax error. // `=> ...` is never a valid expression, so report as syntax error.
......
...@@ -2436,7 +2436,7 @@ void Parser::AddArrowFunctionFormalParameters( ...@@ -2436,7 +2436,7 @@ void Parser::AddArrowFunctionFormalParameters(
void Parser::DeclareArrowFunctionFormalParameters( void Parser::DeclareArrowFunctionFormalParameters(
ParserFormalParameters* parameters, Expression* expr, ParserFormalParameters* parameters, Expression* expr,
const Scanner::Location& params_loc) { const Scanner::Location& params_loc) {
if (expr->IsEmptyParentheses()) return; if (expr->IsEmptyParentheses() || has_error()) return;
AddArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos); AddArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos);
...@@ -2446,7 +2446,8 @@ void Parser::DeclareArrowFunctionFormalParameters( ...@@ -2446,7 +2446,8 @@ void Parser::DeclareArrowFunctionFormalParameters(
} }
DeclareFormalParameters(parameters); DeclareFormalParameters(parameters);
DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters()); DCHECK_IMPLIES(parameters->is_simple,
parameters->scope->has_simple_parameters());
} }
void Parser::PrepareGeneratorVariables() { void Parser::PrepareGeneratorVariables() {
......
...@@ -862,7 +862,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { ...@@ -862,7 +862,6 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
V8_INLINE VariableProxy* ExpressionFromIdentifier( V8_INLINE VariableProxy* ExpressionFromIdentifier(
const AstRawString* name, int start_position, const AstRawString* name, int start_position,
InferName infer = InferName::kYes) { InferName infer = InferName::kYes) {
if (has_error()) return nullptr;
if (infer == InferName::kYes) { if (infer == InferName::kYes) {
fni_.PushVariableName(name); fni_.PushVariableName(name);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment