[parsing] Fix -Wshadow warnings

Bug: v8:12244,v8:12245
Change-Id: Ic84020ea7e54c50dc8f773eb655078582bb33fa7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3264361
Reviewed-by: Marja Hölttä <marja@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77771}
This commit is contained in:
Ng Zhi An 2021-11-05 14:43:17 -07:00 committed by V8 LUCI CQ
parent e7c8f7d7f7
commit 670399facb
4 changed files with 64 additions and 65 deletions

View File

@ -63,16 +63,16 @@ class ExpressionScope {
if (scope->is_with_scope()) {
passed_through_with = true;
} 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
// catch-declared variable, the initializing assignment is an
// assignment to the catch-declared variable instead.
// https://tc39.es/ecma262/#sec-variablestatements-in-catch-blocks
if (var != nullptr) {
if (masking_var != nullptr) {
result->set_is_assigned();
if (passed_through_with) break;
result->BindTo(var);
var->SetMaybeAssigned();
result->BindTo(masking_var);
masking_var->SetMaybeAssigned();
return result;
}
}

View File

@ -3446,7 +3446,7 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) {
// async () => ...
if (!args.length()) return factory()->NewEmptyParentheses(pos);
// async ( Arguments ) => ...
ExpressionT result = impl()->ExpressionListToExpression(args);
result = impl()->ExpressionListToExpression(args);
result->mark_parenthesized();
return result;
}
@ -4581,8 +4581,8 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
if (has_error()) return impl()->FailureExpression();
DeclarationScope* function_scope = next_arrow_function_info_.scope;
FunctionState function_state(&function_state_, &scope_,
function_scope);
FunctionState inner_function_state(&function_state_, &scope_,
function_scope);
Scanner::Location loc(function_scope->start_position(),
end_position());
FormalParametersT parameters(function_scope);
@ -4934,7 +4934,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
Next();
pos = position();
bool is_valid = CheckTemplateEscapes(forbid_illegal_escapes);
is_valid = CheckTemplateEscapes(forbid_illegal_escapes);
impl()->AddTemplateSpan(&ts, is_valid, next == Token::TEMPLATE_TAIL);
} while (next == Token::TEMPLATE_SPAN);

View File

@ -954,14 +954,14 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
// Parsing patterns as variable reference expression creates
// NewUnresolved references in current scope. Enter arrow function
// scope for formal parameter parsing.
BlockState block_state(&scope_, scope);
BlockState inner_block_state(&scope_, scope);
if (Check(Token::LPAREN)) {
// '(' StrictFormalParameters ')'
ParseFormalParameterList(&formals);
Expect(Token::RPAREN);
} else {
// BindingIdentifier
ParameterParsingScope scope(impl(), &formals);
ParameterParsingScope parameter_parsing_scope(impl(), &formals);
ParseFormalParameter(&formals);
DeclareFormalParameters(&formals);
}

View File

@ -74,28 +74,28 @@ void MockUseCounterCallback(v8::Isolate* isolate,
// Helpers for parsing and checking that the result has no error, implemented as
// macros to report the correct test error location.
#define FAIL_WITH_PENDING_PARSER_ERROR(info, script, isolate) \
do { \
(info)->pending_error_handler()->PrepareErrors( \
(isolate), (info)->ast_value_factory()); \
(info)->pending_error_handler()->ReportErrors((isolate), (script)); \
\
i::Handle<i::JSObject> exception_handle( \
i::JSObject::cast((isolate)->pending_exception()), (isolate)); \
i::Handle<i::String> message_string = i::Handle<i::String>::cast( \
i::JSReceiver::GetProperty((isolate), exception_handle, "message") \
.ToHandleChecked()); \
(isolate)->clear_pending_exception(); \
\
String source = String::cast((script)->source()); \
\
FATAL( \
"Parser failed on:\n" \
"\t%s\n" \
"with error:\n" \
"\t%s\n" \
"However, we expected no error.", \
source.ToCString().get(), message_string->ToCString().get()); \
#define FAIL_WITH_PENDING_PARSER_ERROR(info, script, isolate) \
do { \
(info)->pending_error_handler()->PrepareErrors( \
(isolate), (info)->ast_value_factory()); \
(info)->pending_error_handler()->ReportErrors((isolate), (script)); \
\
i::Handle<i::JSObject> exception_handle( \
i::JSObject::cast((isolate)->pending_exception()), (isolate)); \
i::Handle<i::String> message_string = i::Handle<i::String>::cast( \
i::JSReceiver::GetProperty((isolate), exception_handle, "message") \
.ToHandleChecked()); \
(isolate)->clear_pending_exception(); \
\
String script_source = String::cast((script)->source()); \
\
FATAL( \
"Parser failed on:\n" \
"\t%s\n" \
"with error:\n" \
"\t%s\n" \
"However, we expected no error.", \
script_source.ToCString().get(), message_string->ToCString().get()); \
} while (false)
#define CHECK_PARSE_PROGRAM(info, script, isolate) \
@ -1666,8 +1666,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
isolate->counters()->runtime_call_stats(),
isolate->logger(), compile_flags);
scanner.Initialize();
i::PreParser::PreParseResult result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, result);
i::PreParser::PreParseResult pre_parse_result = preparser.PreParseProgram();
CHECK_EQ(i::PreParser::kPreParseSuccess, pre_parse_result);
}
// Parse the data
@ -3417,7 +3417,7 @@ TEST(IfArgumentsArrayAccessedThenParametersMaybeAssigned) {
TEST(InnerAssignment) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate);
i::HandleScope handle_scope(isolate);
LocalContext env;
const char* prefix = "function f() {";
@ -3594,7 +3594,7 @@ TEST(InnerAssignment) {
TEST(MaybeAssignedParameters) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
i::HandleScope handle_scope(isolate);
LocalContext env;
struct {
@ -9114,36 +9114,35 @@ TEST(DestructuringPositiveTests) {
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
// v8:5201
{
// clang-format off
const char* sloppy_context_data[][2] = {
{"var ", " = {};"},
{"function f(", ") {}"},
{"function f(argument1, ", ") {}"},
{"var f = (", ") => {};"},
{"var f = (argument1,", ") => {};"},
{"try {} catch(", ") {}"},
{nullptr, nullptr}
};
const char* data[] = {
"{arguments}",
"{eval}",
"{x: arguments}",
"{x: eval}",
"{arguments = false}",
"{eval = false}",
"{...arguments}",
"{...eval}",
nullptr
};
// clang-format on
RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
}
// v8:5201
TEST(SloppyContextDestructuringPositiveTests) {
// clang-format off
const char* sloppy_context_data[][2] = {
{"var ", " = {};"},
{"function f(", ") {}"},
{"function f(argument1, ", ") {}"},
{"var f = (", ") => {};"},
{"var f = (argument1,", ") => {};"},
{"try {} catch(", ") {}"},
{nullptr, nullptr}
};
const char* data[] = {
"{arguments}",
"{eval}",
"{x: arguments}",
"{x: eval}",
"{arguments = false}",
"{eval = false}",
"{...arguments}",
"{...eval}",
nullptr
};
// clang-format on
RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
TEST(DestructuringNegativeTests) {
{ // All modes.
@ -11233,7 +11232,7 @@ TEST(ArgumentsRedeclaration) {
TEST(NoPessimisticContextAllocation) {
i::Isolate* isolate = CcTest::i_isolate();
i::Factory* factory = isolate->factory();
i::HandleScope scope(isolate);
i::HandleScope handle_scope(isolate);
LocalContext env;
const char* prefix = "(function outer() { var my_var; ";