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

[cleanup] Fix -Wshadow warnings in torque

Bug: v8:12244
Change-Id: Ia441c2056a8a4edf44aa6fd5a1bb86726d599af9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3182927Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77096}
parent fee41d59
......@@ -105,7 +105,6 @@ std::vector<std::string> CCGenerator::ProcessArgumentsCommon(
std::vector<std::string> args;
for (auto it = parameter_types.rbegin(); it != parameter_types.rend(); ++it) {
const Type* type = *it;
VisitResult arg;
if (type->IsConstexpr()) {
args.push_back(std::move(constexpr_arguments.back()));
constexpr_arguments.pop_back();
......
......@@ -157,7 +157,6 @@ std::vector<std::string> CSAGenerator::ProcessArgumentsCommon(
std::vector<std::string> args;
for (auto it = parameter_types.rbegin(); it != parameter_types.rend(); ++it) {
const Type* type = *it;
VisitResult arg;
if (type->IsConstexpr()) {
args.push_back(std::move(constexpr_arguments.back()));
constexpr_arguments.pop_back();
......
......@@ -82,13 +82,12 @@ std::ostream& operator<<(std::ostream& os, const GenericCallable& g) {
}
SpecializationRequester::SpecializationRequester(SourcePosition position,
Scope* scope, std::string name)
Scope* s, std::string name)
: position(position), name(std::move(name)) {
// Skip scopes that are not related to template specializations, they might be
// stack-allocated and not live for long enough.
while (scope && scope->GetSpecializationRequester().IsNone())
scope = scope->ParentScope();
this->scope = scope;
while (s && s->GetSpecializationRequester().IsNone()) s = s->ParentScope();
this->scope = s;
}
std::vector<Declarable*> Scope::Lookup(const QualifiedName& name) {
......@@ -165,11 +164,11 @@ TypeArgumentInference GenericCallable::InferSpecializationTypes(
}
base::Optional<Statement*> GenericCallable::CallableBody() {
if (auto* decl = TorqueMacroDeclaration::DynamicCast(declaration())) {
return decl->body;
} else if (auto* decl =
if (auto* macro_decl = TorqueMacroDeclaration::DynamicCast(declaration())) {
return macro_decl->body;
} else if (auto* builtin_decl =
TorqueBuiltinDeclaration::DynamicCast(declaration())) {
return decl->body;
return builtin_decl->body;
} else {
return base::nullopt;
}
......
......@@ -293,11 +293,11 @@ VisitResult ImplementationVisitor::InlineMacro(
true);
}
size_t i = 0;
size_t count = 0;
for (auto arg : arguments) {
if (this_reference && i == signature.implicit_count) i++;
const bool mark_as_used = signature.implicit_count > i;
const Identifier* name = macro->parameter_names()[i++];
if (this_reference && count == signature.implicit_count) count++;
const bool mark_as_used = signature.implicit_count > count;
const Identifier* name = macro->parameter_names()[count++];
parameter_bindings.Add(name,
LocalValue{LocationReference::Temporary(
arg, "parameter " + name->value)},
......@@ -475,9 +475,9 @@ void ImplementationVisitor::VisitMacroCommon(Macro* macro) {
const LabelDeclaration& label_info = signature.labels[i];
assembler().Bind(label_block);
std::vector<std::string> label_parameter_variables;
for (size_t i = 0; i < label_info.types.size(); ++i) {
LowerLabelParameter(label_info.types[i],
ExternalLabelParameterName(label_info.name->value, i),
for (size_t j = 0; j < label_info.types.size(); ++j) {
LowerLabelParameter(label_info.types[j],
ExternalLabelParameterName(label_info.name->value, j),
&label_parameter_variables);
}
assembler().Emit(GotoExternalInstruction{
......@@ -741,12 +741,12 @@ const Type* ImplementationVisitor::Visit(
ReportError("constexpr variables need an initializer");
}
TypeVector lowered_types = LowerType(*type);
for (const Type* type : lowered_types) {
for (const Type* t : lowered_types) {
assembler().Emit(PushUninitializedInstruction{TypeOracle::GetTopType(
"uninitialized variable '" + stmt->name->value + "' of type " +
type->ToString() + " originally defined at " +
t->ToString() + " originally defined at " +
PositionAsString(stmt->pos),
type)});
t)});
}
init_result =
VisitResult(*type, assembler().TopRange(lowered_types.size()));
......@@ -1911,9 +1911,9 @@ void FailCallableLookup(
stream << "\nfailed to instantiate all of these generic declarations:";
for (auto& failure : inapplicable_generics) {
GenericCallable* generic = failure.first;
const std::string& reason = failure.second;
const std::string& fail_reason = failure.second;
stream << "\n " << generic->name() << " defined at "
<< generic->Position() << ":\n " << reason << "\n";
<< generic->Position() << ":\n " << fail_reason << "\n";
}
}
ReportError(stream.str());
......@@ -3020,10 +3020,10 @@ VisitResult ImplementationVisitor::GenerateCall(
arguments_to_getter.parameters.begin(),
converted_arguments.begin() + 1, converted_arguments.end());
Callable* callable = LookupCallable(
Callable* callable_macro = LookupCallable(
qualified_getter_name, Declarations::Lookup(qualified_getter_name),
arguments_to_getter, {});
Macro* getter = Macro::DynamicCast(callable);
Macro* getter = Macro::DynamicCast(callable_macro);
if (!getter || getter->IsMethod()) {
ReportError(
"%MakeLazy expects a macro, not builtin or other type of callable");
......@@ -3050,10 +3050,10 @@ VisitResult ImplementationVisitor::GenerateCall(
StackRange argument_range_for_getter = assembler().TopRange(0);
std::vector<std::string> constexpr_arguments_for_getter;
size_t current = 0;
size_t arg_count = 0;
for (auto arg : arguments_to_getter.parameters) {
DCHECK_LT(current, getter->signature().types().size());
const Type* to_type = getter->signature().types()[current++];
DCHECK_LT(arg_count, getter->signature().types().size());
const Type* to_type = getter->signature().types()[arg_count++];
AddCallParameter(getter, arg, to_type, &converted_arguments_for_getter,
&argument_range_for_getter,
&constexpr_arguments_for_getter,
......@@ -4127,10 +4127,10 @@ void CppClassGenerator::GenerateClass() {
// V8_INLINE int32_t AllocatedSize() const
{
cpp::Function f =
cpp::Function allocated_size_f =
cpp::Function::DefaultGetter("int32_t", &c, "AllocatedSize");
f.SetFlag(cpp::Function::kV8Inline);
f.PrintInlineDefinition(hdr_, [&](std::ostream& stream) {
allocated_size_f.SetFlag(cpp::Function::kV8Inline);
allocated_size_f.PrintInlineDefinition(hdr_, [&](std::ostream& stream) {
stream << " return SizeFor(";
bool first = true;
for (auto field : *index_fields) {
......@@ -5373,12 +5373,12 @@ void ImplementationVisitor::GenerateCSATypes(
}
h_contents << "\n std::tuple<";
bool first = true;
for (const Type* type : LowerType(struct_type)) {
for (const Type* lowered_type : LowerType(struct_type)) {
if (!first) {
h_contents << ", ";
}
first = false;
h_contents << type->GetGeneratedTypeName();
h_contents << lowered_type->GetGeneratedTypeName();
}
std::vector<std::string> all_fields;
for (auto& field : struct_type->fields()) {
......
......@@ -311,22 +311,22 @@ void HandleDocumentSymbolRequest(DocumentSymbolRequest request,
DCHECK(symbol->IsUserDefined());
if (symbol->IsMacro()) {
Macro* macro = Macro::cast(symbol);
SymbolInformation symbol = response.add_result();
symbol.set_name(macro->ReadableName());
symbol.set_kind(SymbolKind::kFunction);
symbol.location().SetTo(macro->Position());
SymbolInformation info = response.add_result();
info.set_name(macro->ReadableName());
info.set_kind(SymbolKind::kFunction);
info.location().SetTo(macro->Position());
} else if (symbol->IsBuiltin()) {
Builtin* builtin = Builtin::cast(symbol);
SymbolInformation symbol = response.add_result();
symbol.set_name(builtin->ReadableName());
symbol.set_kind(SymbolKind::kFunction);
symbol.location().SetTo(builtin->Position());
SymbolInformation info = response.add_result();
info.set_name(builtin->ReadableName());
info.set_kind(SymbolKind::kFunction);
info.location().SetTo(builtin->Position());
} else if (symbol->IsGenericCallable()) {
GenericCallable* generic = GenericCallable::cast(symbol);
SymbolInformation symbol = response.add_result();
symbol.set_name(generic->name());
symbol.set_kind(SymbolKind::kFunction);
symbol.location().SetTo(generic->Position());
SymbolInformation info = response.add_result();
info.set_name(generic->name());
info.set_kind(SymbolKind::kFunction);
info.location().SetTo(generic->Position());
} else if (symbol->IsTypeAlias()) {
const Type* type = TypeAlias::cast(symbol)->type();
SymbolKind kind =
......
......@@ -327,7 +327,7 @@ Expression* MakeCall(IdentifierExpression* callee,
// All IdentifierExpressions are treated as label names and can be directly
// used as labels identifiers. All other statements in a call's otherwise
// must create intermediate Labels for the otherwise's statement code.
size_t label_id = 0;
size_t label_id_count = 0;
std::vector<TryHandler*> temp_labels;
for (auto* statement : otherwise) {
if (auto* e = ExpressionStatement::DynamicCast(statement)) {
......@@ -339,7 +339,7 @@ Expression* MakeCall(IdentifierExpression* callee,
continue;
}
}
auto label_name = std::string("__label") + std::to_string(label_id++);
auto label_name = std::string("__label") + std::to_string(label_id_count++);
auto label_id = MakeNode<Identifier>(label_name);
label_id->pos = SourcePosition::Invalid();
labels.push_back(label_id);
......@@ -728,7 +728,7 @@ base::Optional<ParseResult> MakeAbstractTypeDeclaration(
constexpr_name, flags | AbstractTypeFlag::kConstexpr, constexpr_extends,
constexpr_generates);
constexpr_decl->pos = name->pos;
Declaration* decl = constexpr_decl;
decl = constexpr_decl;
if (!generic_parameters.empty()) {
decl =
MakeNode<GenericTypeDeclaration>(generic_parameters, constexpr_decl);
......@@ -1498,7 +1498,7 @@ base::Optional<ParseResult> MakeTypeswitchStatement(
ParseResultIterator* child_results) {
auto expression = child_results->NextAs<Expression*>();
auto cases = child_results->NextAs<std::vector<TypeswitchCase>>();
CurrentSourcePosition::Scope current_source_position(
CurrentSourcePosition::Scope matched_input_current_source_position(
child_results->matched_input().pos);
// typeswitch (expression) case (x1 : T1) {
......
......@@ -189,7 +189,7 @@ const StructType* TypeVisitor::ComputeType(
StructDeclaration* decl, MaybeSpecializationKey specialized_from) {
StructType* struct_type = TypeOracle::GetStructType(decl, specialized_from);
CurrentScope::Scope struct_namespace_scope(struct_type->nspace());
CurrentSourcePosition::Scope position_activator(decl->pos);
CurrentSourcePosition::Scope decl_position_activator(decl->pos);
ResidueClass offset = 0;
for (auto& field : decl->fields) {
......
......@@ -176,8 +176,8 @@ void PrintCommaSeparatedList(std::ostream& os, const T& list) {
struct BottomOffset {
size_t offset;
BottomOffset& operator=(std::size_t offset) {
this->offset = offset;
BottomOffset& operator=(std::size_t other_offset) {
this->offset = other_offset;
return *this;
}
BottomOffset& operator++() {
......
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