Commit 670399fa authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[parsing] Fix -Wshadow warnings

Bug: v8:12244,v8:12245
Change-Id: Ic84020ea7e54c50dc8f773eb655078582bb33fa7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3264361Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77771}
parent e7c8f7d7
...@@ -63,16 +63,16 @@ class ExpressionScope { ...@@ -63,16 +63,16 @@ class ExpressionScope {
if (scope->is_with_scope()) { if (scope->is_with_scope()) {
passed_through_with = true; passed_through_with = true;
} else if (scope->is_catch_scope()) { } else if (scope->is_catch_scope()) {
Variable* var = scope->LookupLocal(name); Variable* masking_var = scope->LookupLocal(name);
// If a variable is declared in a catch scope with a masking // If a variable is declared in a catch scope with a masking
// catch-declared variable, the initializing assignment is an // catch-declared variable, the initializing assignment is an
// assignment to the catch-declared variable instead. // assignment to the catch-declared variable instead.
// https://tc39.es/ecma262/#sec-variablestatements-in-catch-blocks // https://tc39.es/ecma262/#sec-variablestatements-in-catch-blocks
if (var != nullptr) { if (masking_var != nullptr) {
result->set_is_assigned(); result->set_is_assigned();
if (passed_through_with) break; if (passed_through_with) break;
result->BindTo(var); result->BindTo(masking_var);
var->SetMaybeAssigned(); masking_var->SetMaybeAssigned();
return result; return result;
} }
} }
......
...@@ -3446,7 +3446,7 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) { ...@@ -3446,7 +3446,7 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) {
// async () => ... // async () => ...
if (!args.length()) return factory()->NewEmptyParentheses(pos); if (!args.length()) return factory()->NewEmptyParentheses(pos);
// async ( Arguments ) => ... // async ( Arguments ) => ...
ExpressionT result = impl()->ExpressionListToExpression(args); result = impl()->ExpressionListToExpression(args);
result->mark_parenthesized(); result->mark_parenthesized();
return result; return result;
} }
...@@ -4581,7 +4581,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -4581,7 +4581,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
if (has_error()) return impl()->FailureExpression(); if (has_error()) return impl()->FailureExpression();
DeclarationScope* function_scope = next_arrow_function_info_.scope; DeclarationScope* function_scope = next_arrow_function_info_.scope;
FunctionState function_state(&function_state_, &scope_, FunctionState inner_function_state(&function_state_, &scope_,
function_scope); function_scope);
Scanner::Location loc(function_scope->start_position(), Scanner::Location loc(function_scope->start_position(),
end_position()); end_position());
...@@ -4934,7 +4934,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( ...@@ -4934,7 +4934,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
Next(); Next();
pos = position(); pos = position();
bool is_valid = CheckTemplateEscapes(forbid_illegal_escapes); is_valid = CheckTemplateEscapes(forbid_illegal_escapes);
impl()->AddTemplateSpan(&ts, is_valid, next == Token::TEMPLATE_TAIL); impl()->AddTemplateSpan(&ts, is_valid, next == Token::TEMPLATE_TAIL);
} while (next == Token::TEMPLATE_SPAN); } while (next == Token::TEMPLATE_SPAN);
......
...@@ -954,14 +954,14 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, ...@@ -954,14 +954,14 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
// Parsing patterns as variable reference expression creates // Parsing patterns as variable reference expression creates
// NewUnresolved references in current scope. Enter arrow function // NewUnresolved references in current scope. Enter arrow function
// scope for formal parameter parsing. // scope for formal parameter parsing.
BlockState block_state(&scope_, scope); BlockState inner_block_state(&scope_, scope);
if (Check(Token::LPAREN)) { if (Check(Token::LPAREN)) {
// '(' StrictFormalParameters ')' // '(' StrictFormalParameters ')'
ParseFormalParameterList(&formals); ParseFormalParameterList(&formals);
Expect(Token::RPAREN); Expect(Token::RPAREN);
} else { } else {
// BindingIdentifier // BindingIdentifier
ParameterParsingScope scope(impl(), &formals); ParameterParsingScope parameter_parsing_scope(impl(), &formals);
ParseFormalParameter(&formals); ParseFormalParameter(&formals);
DeclareFormalParameters(&formals); DeclareFormalParameters(&formals);
} }
......
...@@ -87,7 +87,7 @@ void MockUseCounterCallback(v8::Isolate* isolate, ...@@ -87,7 +87,7 @@ void MockUseCounterCallback(v8::Isolate* isolate,
.ToHandleChecked()); \ .ToHandleChecked()); \
(isolate)->clear_pending_exception(); \ (isolate)->clear_pending_exception(); \
\ \
String source = String::cast((script)->source()); \ String script_source = String::cast((script)->source()); \
\ \
FATAL( \ FATAL( \
"Parser failed on:\n" \ "Parser failed on:\n" \
...@@ -95,7 +95,7 @@ void MockUseCounterCallback(v8::Isolate* isolate, ...@@ -95,7 +95,7 @@ void MockUseCounterCallback(v8::Isolate* isolate,
"with error:\n" \ "with error:\n" \
"\t%s\n" \ "\t%s\n" \
"However, we expected no error.", \ "However, we expected no error.", \
source.ToCString().get(), message_string->ToCString().get()); \ script_source.ToCString().get(), message_string->ToCString().get()); \
} while (false) } while (false)
#define CHECK_PARSE_PROGRAM(info, script, isolate) \ #define CHECK_PARSE_PROGRAM(info, script, isolate) \
...@@ -1666,8 +1666,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, ...@@ -1666,8 +1666,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
isolate->counters()->runtime_call_stats(), isolate->counters()->runtime_call_stats(),
isolate->logger(), compile_flags); isolate->logger(), compile_flags);
scanner.Initialize(); scanner.Initialize();
i::PreParser::PreParseResult result = preparser.PreParseProgram(); i::PreParser::PreParseResult pre_parse_result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result); CHECK_EQ(i::PreParser::kPreParseSuccess, pre_parse_result);
} }
// Parse the data // Parse the data
...@@ -3417,7 +3417,7 @@ TEST(IfArgumentsArrayAccessedThenParametersMaybeAssigned) { ...@@ -3417,7 +3417,7 @@ TEST(IfArgumentsArrayAccessedThenParametersMaybeAssigned) {
TEST(InnerAssignment) { TEST(InnerAssignment) {
i::Isolate* isolate = CcTest::i_isolate(); i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory(); i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate); i::HandleScope handle_scope(isolate);
LocalContext env; LocalContext env;
const char* prefix = "function f() {"; const char* prefix = "function f() {";
...@@ -3594,7 +3594,7 @@ TEST(InnerAssignment) { ...@@ -3594,7 +3594,7 @@ TEST(InnerAssignment) {
TEST(MaybeAssignedParameters) { TEST(MaybeAssignedParameters) {
i::Isolate* isolate = CcTest::i_isolate(); i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate); i::HandleScope handle_scope(isolate);
LocalContext env; LocalContext env;
struct { struct {
...@@ -9114,9 +9114,10 @@ TEST(DestructuringPositiveTests) { ...@@ -9114,9 +9114,10 @@ TEST(DestructuringPositiveTests) {
// clang-format on // clang-format on
RunParserSyncTest(context_data, data, kSuccess); RunParserSyncTest(context_data, data, kSuccess);
}
// v8:5201 // v8:5201
{ TEST(SloppyContextDestructuringPositiveTests) {
// clang-format off // clang-format off
const char* sloppy_context_data[][2] = { const char* sloppy_context_data[][2] = {
{"var ", " = {};"}, {"var ", " = {};"},
...@@ -9141,10 +9142,8 @@ TEST(DestructuringPositiveTests) { ...@@ -9141,10 +9142,8 @@ TEST(DestructuringPositiveTests) {
}; };
// clang-format on // clang-format on
RunParserSyncTest(sloppy_context_data, data, kSuccess); RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
} }
TEST(DestructuringNegativeTests) { TEST(DestructuringNegativeTests) {
{ // All modes. { // All modes.
const char* context_data[][2] = {{"'use strict'; let ", " = {};"}, const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
...@@ -11233,7 +11232,7 @@ TEST(ArgumentsRedeclaration) { ...@@ -11233,7 +11232,7 @@ TEST(ArgumentsRedeclaration) {
TEST(NoPessimisticContextAllocation) { TEST(NoPessimisticContextAllocation) {
i::Isolate* isolate = CcTest::i_isolate(); i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory(); i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate); i::HandleScope handle_scope(isolate);
LocalContext env; LocalContext env;
const char* prefix = "(function outer() { var my_var; "; const char* prefix = "(function outer() { var my_var; ";
......
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