Commit 0405d6ef authored by Maya Lekova's avatar Maya Lekova Committed by Commit Bot

Revert "[parser] Remove RETURN_IF* part 16"

This reverts commit fd22cfc8.

Reason for revert: Breaking MSAN build, see
https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux%20-%20arm64%20-%20sim%20-%20MSAN/23602

Original change's description:
> [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: Igor Sheludko <ishell@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#57172}

TBR=ishell@chromium.org,verwaest@chromium.org

Change-Id: Ic03a669c1a9598c7bd5ca186d783987e91dca5b5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:8363, v8:7926
Reviewed-on: https://chromium-review.googlesource.com/c/1309828Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57175}
parent 162d4e6d
......@@ -449,7 +449,9 @@ class FunctionDeclaration final : public Declaration {
friend class AstNodeFactory;
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_;
};
......
......@@ -1547,7 +1547,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
if (impl()->IsEvalOrArguments(name)) {
if (impl()->IsArguments(name) && scope()->ShouldBanArguments()) {
ReportMessage(MessageTemplate::kArgumentsDisallowedInInitializer);
return impl()->EmptyIdentifierString();
return impl()->NullIdentifier();
}
classifier()->RecordStrictModeFormalParameterError(
......@@ -1575,7 +1575,7 @@ ParserBase<Impl>::ParseAndClassifyIdentifier() {
return impl()->GetSymbol();
} else {
ReportUnexpectedToken(next);
return impl()->EmptyIdentifierString();
return impl()->NullIdentifier();
}
}
......@@ -1594,7 +1594,7 @@ ParserBase<Impl>::ParseIdentifierOrStrictReservedWord(
*is_strict_reserved = true;
} else {
ReportUnexpectedToken(next);
return impl()->EmptyIdentifierString();
return impl()->NullIdentifier();
}
return impl()->GetSymbol();
......@@ -1606,7 +1606,7 @@ typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName() {
if (!Token::IsAnyIdentifier(next) && next != Token::ESCAPED_KEYWORD &&
!Token::IsKeyword(next)) {
ReportUnexpectedToken(next);
return impl()->EmptyIdentifierString();
return impl()->NullIdentifier();
}
return impl()->GetSymbol();
......@@ -1628,6 +1628,7 @@ ParserBase<Impl>::ParseIdentifierNameOrPrivateName() {
name = ParseIdentifierName();
key = factory()->NewStringLiteral(name, pos);
}
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(name);
return key;
}
......@@ -2130,6 +2131,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
if (*kind == ParsePropertyKind::kNotSet) {
ParsePropertyKindFromToken(peek(), kind);
}
RETURN_IF_PARSE_ERROR;
impl()->PushLiteralName(*name);
return is_array_index ? factory()->NewNumberLiteral(index, pos)
: factory()->NewStringLiteral(*name, pos);
......@@ -2703,6 +2705,8 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN) {
}
scope->set_start_position(lhs_beg_pos);
// TODO(verwaest): Disable DCHECKs in failure mode?
RETURN_IF_PARSE_ERROR;
impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc);
expression =
......@@ -3833,6 +3837,8 @@ ParserBase<Impl>::ParseHoistableDeclaration(
}
FuncNameInferrerState fni_state(&fni_);
// TODO(verwaest): Remove once we have FailureIdentifier.
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
impl()->PushEnclosingName(name);
FunctionKind kind = FunctionKindFor(flags);
......@@ -3856,6 +3862,7 @@ ParserBase<Impl>::ParseHoistableDeclaration(
!scope()->is_declaration_scope() &&
flags == ParseFunctionFlag::kIsNormal;
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareFunction(variable_name, function, mode, pos,
is_sloppy_block_function, names);
}
......@@ -3897,6 +3904,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
ExpressionT value = ParseClassLiteral(name, scanner()->location(),
is_strict_reserved, class_token_pos);
int end_pos = position();
RETURN_IF_PARSE_ERROR_CUSTOM(NullStatement);
return impl()->DeclareClass(variable_name, value, names, class_token_pos,
end_pos);
}
......@@ -4130,7 +4138,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
base::ElapsedTimer timer;
if (V8_UNLIKELY(FLAG_log_function_events)) timer.Start();
DCHECK_IMPLIES(!has_error(), peek() == Token::ARROW);
DCHECK_EQ(Token::ARROW, peek());
if (scanner_->HasLineTerminatorBeforeNext()) {
// ASI inserts `;` after arrow parameters if a line terminator is found.
// `=> ...` is never a valid expression, so report as syntax error.
......
......@@ -2436,7 +2436,7 @@ void Parser::AddArrowFunctionFormalParameters(
void Parser::DeclareArrowFunctionFormalParameters(
ParserFormalParameters* parameters, Expression* expr,
const Scanner::Location& params_loc) {
if (expr->IsEmptyParentheses() || has_error()) return;
if (expr->IsEmptyParentheses()) return;
AddArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos);
......@@ -2446,8 +2446,7 @@ void Parser::DeclareArrowFunctionFormalParameters(
}
DeclareFormalParameters(parameters);
DCHECK_IMPLIES(parameters->is_simple,
parameters->scope->has_simple_parameters());
DCHECK_EQ(parameters->is_simple, parameters->scope->has_simple_parameters());
}
void Parser::PrepareGeneratorVariables() {
......
......@@ -862,6 +862,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
V8_INLINE VariableProxy* ExpressionFromIdentifier(
const AstRawString* name, int start_position,
InferName infer = InferName::kYes) {
if (has_error()) return nullptr;
if (infer == InferName::kYes) {
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