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 {
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;
}
}
......
......@@ -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,7 +4581,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
if (has_error()) return impl()->FailureExpression();
DeclarationScope* function_scope = next_arrow_function_info_.scope;
FunctionState function_state(&function_state_, &scope_,
FunctionState inner_function_state(&function_state_, &scope_,
function_scope);
Scanner::Location loc(function_scope->start_position(),
end_position());
......@@ -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);
......
......@@ -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);
}
......
......@@ -87,7 +87,7 @@ void MockUseCounterCallback(v8::Isolate* isolate,
.ToHandleChecked()); \
(isolate)->clear_pending_exception(); \
\
String source = String::cast((script)->source()); \
String script_source = String::cast((script)->source()); \
\
FATAL( \
"Parser failed on:\n" \
......@@ -95,7 +95,7 @@ void MockUseCounterCallback(v8::Isolate* isolate,
"with error:\n" \
"\t%s\n" \
"However, we expected no error.", \
source.ToCString().get(), message_string->ToCString().get()); \
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,9 +9114,10 @@ TEST(DestructuringPositiveTests) {
// clang-format on
RunParserSyncTest(context_data, data, kSuccess);
}
// v8:5201
{
// v8:5201
TEST(SloppyContextDestructuringPositiveTests) {
// clang-format off
const char* sloppy_context_data[][2] = {
{"var ", " = {};"},
......@@ -9141,10 +9142,8 @@ TEST(DestructuringPositiveTests) {
};
// clang-format on
RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
}
TEST(DestructuringNegativeTests) {
{ // All modes.
const char* context_data[][2] = {{"'use strict'; let ", " = {};"},
......@@ -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; ";
......
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