Skip to content

Commit

Permalink
[cleanup] Fix Wshadow warnings in cctests
Browse files Browse the repository at this point in the history
Bug: v8:12244, v8:12245
Change-Id: I5745daaa18dba962b45a05d1064face610d05e2b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3185460
Reviewed-by: Patrick Thier <pthier@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77083}
  • Loading branch information
marjakh authored and V8 LUCI CQ committed Sep 27, 2021
1 parent c1700c5 commit bd87901
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 61 deletions.
4 changes: 2 additions & 2 deletions test/cctest/parsing/test-scanner-streams.cc
Expand Up @@ -373,8 +373,8 @@ TEST(Utf8ChunkBoundaries) {
v8::internal::ScannerStream::For(
&chunk_source, v8::ScriptCompiler::StreamedSource::UTF8));

for (size_t i = 0; unicode_ucs2[i]; i++) {
CHECK_EQ(unicode_ucs2[i], stream->Advance());
for (size_t j = 0; unicode_ucs2[j]; j++) {
CHECK_EQ(unicode_ucs2[j], stream->Advance());
}
CHECK_EQ(v8::internal::Utf16CharacterStream::kEndOfInput,
stream->Advance());
Expand Down
2 changes: 1 addition & 1 deletion test/cctest/test-accessors.cc
Expand Up @@ -316,7 +316,7 @@ THREADED_TEST(HandleScopePop) {
int count_before =
i::HandleScope::NumberOfHandles(reinterpret_cast<i::Isolate*>(isolate));
{
v8::HandleScope scope(isolate);
v8::HandleScope inner_scope(isolate);
CompileRun(
"for (var i = 0; i < 1000; i++) {"
" obj.one;"
Expand Down
67 changes: 35 additions & 32 deletions test/cctest/test-api.cc
Expand Up @@ -2627,7 +2627,7 @@ THREADED_TEST(DescriptorInheritance2) {
v8::Local<v8::Script> script = v8_compile("o = new F()");

for (int i = 0; i < 100; i++) {
v8::HandleScope scope(isolate);
v8::HandleScope inner_scope(isolate);
script->Run(env.local()).ToLocalChecked();
}
v8::Local<v8::Object> object = script->Run(env.local())
Expand Down Expand Up @@ -7857,7 +7857,7 @@ void InternalFieldCallback(bool global_gc) {
instance_templ->SetInternalFieldCount(2);
v8::Persistent<v8::Object> handle;
{
v8::HandleScope scope(isolate);
v8::HandleScope inner_scope(isolate);
Local<v8::Object> obj = templ->GetFunction(env.local())
.ToLocalChecked()
->NewInstance(env.local())
Expand Down Expand Up @@ -9249,7 +9249,8 @@ THREADED_TEST(SecurityChecksForPrototypeChain) {
// Change context to be able to get to the Object function in the
// other context without hitting the security checks.
v8::Local<Value> other_object;
{ Context::Scope scope(other);
{
Context::Scope context_scope(other);
other_object =
other->Global()->Get(other, v8_str("Object")).ToLocalChecked();
CHECK(other->Global()->Set(other, v8_num(42), v8_num(87)).FromJust());
Expand Down Expand Up @@ -9293,7 +9294,8 @@ THREADED_TEST(SecurityChecksForPrototypeChain) {
// Now it gets hairy: Set the prototype for the other global object
// to be the current global object. The prototype chain for 'f' now
// goes through 'other' but ends up in the current global object.
{ Context::Scope scope(other);
{
Context::Scope context_scope(other);
CHECK(other->Global()
->Set(other, v8_str("__proto__"), current->Global())
.FromJust());
Expand Down Expand Up @@ -9589,7 +9591,7 @@ TEST(DetachGlobal) {

// Create a property on the global object in env2.
{
v8::Context::Scope scope(env2);
v8::Context::Scope context_scope(env2);
CHECK(env2->Global()
->Set(env2, v8_str("p"), v8::Integer::New(env2->GetIsolate(), 42))
.FromJust());
Expand Down Expand Up @@ -9624,7 +9626,7 @@ TEST(DetachGlobal) {

// Create a property on the global object in env3.
{
v8::Context::Scope scope(env3);
v8::Context::Scope context_scope(env3);
CHECK(env3->Global()
->Set(env3, v8_str("p"), v8::Integer::New(env3->GetIsolate(), 24))
.FromJust());
Expand Down Expand Up @@ -9667,7 +9669,7 @@ TEST(DetachedAccesses) {
.FromJust());

{
v8::Context::Scope scope(env2);
v8::Context::Scope context_scope(env2);
CHECK(env2->Global()->Set(env2, v8_str("x"), v8_str("env2_x")).FromJust());
CompileRun(
"function bound_x() { return x; }"
Expand Down Expand Up @@ -9706,7 +9708,7 @@ TEST(DetachedAccesses) {
v8::Local<v8::ObjectTemplate>(), env2_global);
env2->SetSecurityToken(foo);
{
v8::Context::Scope scope(env2);
v8::Context::Scope context_scope(env2);
CHECK(env2->Global()->Set(env2, v8_str("x"), v8_str("env3_x")).FromJust());
CHECK(env2->Global()->Set(env2, v8_str("env1"), env1->Global()).FromJust());
result = CompileRun(
Expand Down Expand Up @@ -10548,7 +10550,6 @@ THREADED_TEST(ObjectGetOwnPropertyNames) {
->Equals(context.local(), v8_str("length"))
.FromMaybe(false));
for (int i = 0; i < 4; ++i) {
v8::Local<v8::Value> property;
CHECK(properties->Get(context.local(), i).ToLocal(&property) &&
property->IsInt32());
CHECK_EQ(property.As<v8::Int32>()->Value(), i);
Expand Down Expand Up @@ -10594,7 +10595,6 @@ THREADED_TEST(ObjectGetOwnPropertyNames) {
bool concat_found = false;
bool starts_with_found = false;
for (uint32_t i = 0; i < properties->Length(); ++i) {
v8::Local<v8::Value> property;
CHECK(properties->Get(context.local(), i).ToLocal(&property));
if (!property->IsString()) continue;
if (!concat_found)
Expand Down Expand Up @@ -15316,8 +15316,9 @@ TEST(DefineProperty) {
v8::TryCatch try_catch(isolate);
// Use a writable descriptor, otherwise the next test, that changes
// the array length will fail.
v8::PropertyDescriptor desc(v8_num(42), true);
CHECK(arr->DefineProperty(env.local(), v8_str("length"), desc).FromJust());
v8::PropertyDescriptor desc_writable(v8_num(42), true);
CHECK(arr->DefineProperty(env.local(), v8_str("length"), desc_writable)
.FromJust());
CHECK(!try_catch.HasCaught());
}

Expand Down Expand Up @@ -15412,11 +15413,11 @@ TEST(DefineProperty) {
env->Global()->Get(env.local(), v8_str("get")).ToLocalChecked());
v8::Local<v8::Function> set = v8::Local<v8::Function>::Cast(
env->Global()->Get(env.local(), v8_str("set")).ToLocalChecked());
v8::PropertyDescriptor desc(get, set);
v8::PropertyDescriptor desc_getter_setter(get, set);

p = v8_str("v7");
v8::TryCatch try_catch(isolate);
CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
CHECK(obj->DefineProperty(env.local(), p, desc_getter_setter).FromJust());
CHECK(!try_catch.HasCaught());

v8::Local<v8::Value> val = obj->Get(env.local(), p).ToLocalChecked();
Expand All @@ -15437,12 +15438,12 @@ TEST(DefineProperty) {
// Redefine an existing property.

// desc = {value: 42, enumerable: true}
v8::PropertyDescriptor desc(v8_num(42));
desc.set_enumerable(true);
v8::PropertyDescriptor desc42(v8_num(42));
desc42.set_enumerable(true);

p = v8_str("v8");
v8::TryCatch try_catch(isolate);
CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
CHECK(obj->DefineProperty(env.local(), p, desc42).FromJust());
CHECK(!try_catch.HasCaught());

// desc = {enumerable: true}
Expand Down Expand Up @@ -15476,11 +15477,11 @@ TEST(DefineProperty) {
env->Global()->Get(env.local(), v8_str("get")).ToLocalChecked());

// desc = {get: function() {}}
v8::PropertyDescriptor desc(get, v8::Local<v8::Function>());
v8::PropertyDescriptor desc_getter(get, v8::Local<v8::Function>());
v8::TryCatch try_catch(isolate);

p = v8_str("v9");
CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
CHECK(obj->DefineProperty(env.local(), p, desc_getter).FromJust());
CHECK(!try_catch.HasCaught());

// desc_empty = {}
Expand All @@ -15491,7 +15492,7 @@ TEST(DefineProperty) {

// desc = {get: function() {}}
// Successful because we redefine the getter with its current value.
CHECK(obj->DefineProperty(env.local(), p, desc).FromJust());
CHECK(obj->DefineProperty(env.local(), p, desc_getter).FromJust());
CHECK(!try_catch.HasCaught());

// desc = {get: undefined}
Expand Down Expand Up @@ -17345,7 +17346,7 @@ TEST(Regress528) {
// cache to the global object.
const char* source_simple = "1";
{
v8::HandleScope scope(isolate);
v8::HandleScope inner_scope(isolate);
v8::Local<Context> context = Context::New(isolate);

context->Enter();
Expand All @@ -17369,7 +17370,7 @@ TEST(Regress528) {
// global object.
const char* source_eval = "function f(){eval('1')}; f()";
{
v8::HandleScope scope(isolate);
v8::HandleScope inner_scope(isolate);
v8::Local<Context> context = Context::New(isolate);

context->Enter();
Expand All @@ -17391,7 +17392,7 @@ TEST(Regress528) {
// compilation cache to the global object.
const char* source_exception = "function f(){throw 1;} f()";
{
v8::HandleScope scope(isolate);
v8::HandleScope inner_scope(isolate);
v8::Local<Context> context = Context::New(isolate);

context->Enter();
Expand Down Expand Up @@ -20333,7 +20334,7 @@ TEST(SetAutorunMicrotasks) {
env->GetIsolate()->EnqueueMicrotask(
Function::New(env.local(), MicrotaskTwo).ToLocalChecked());
{
v8::Isolate::SuppressMicrotaskExecutionScope scope(env->GetIsolate());
v8::Isolate::SuppressMicrotaskExecutionScope suppress(env->GetIsolate());
CompileRun("1+1;");
CHECK_EQ(2, CompileRun("ext1Calls")->Int32Value(env.local()).FromJust());
CHECK_EQ(3, CompileRun("ext2Calls")->Int32Value(env.local()).FromJust());
Expand Down Expand Up @@ -24264,11 +24265,12 @@ TEST(CodeCache) {
v8::Context::Scope cscope(context);
v8::Local<v8::String> source_string = v8_str(source);
v8::ScriptOrigin script_origin(isolate1, v8_str(origin));
v8::ScriptCompiler::Source source(source_string, script_origin);
v8::ScriptCompiler::Source script_source(source_string, script_origin);
v8::ScriptCompiler::CompileOptions option =
v8::ScriptCompiler::kNoCompileOptions;
v8::Local<v8::Script> script =
v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked();
v8::ScriptCompiler::Compile(context, &script_source, option)
.ToLocalChecked();
cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
}
isolate1->Dispose();
Expand All @@ -24281,14 +24283,15 @@ TEST(CodeCache) {
v8::Context::Scope cscope(context);
v8::Local<v8::String> source_string = v8_str(source);
v8::ScriptOrigin script_origin(isolate2, v8_str(origin));
v8::ScriptCompiler::Source source(source_string, script_origin, cache);
v8::ScriptCompiler::Source script_source(source_string, script_origin,
cache);
v8::ScriptCompiler::CompileOptions option =
v8::ScriptCompiler::kConsumeCodeCache;
v8::Local<v8::Script> script;
{
i::DisallowCompilation no_compile(
reinterpret_cast<i::Isolate*>(isolate2));
script = v8::ScriptCompiler::Compile(context, &source, option)
script = v8::ScriptCompiler::Compile(context, &script_source, option)
.ToLocalChecked();
}
CHECK_EQ(2, script->Run(context)
Expand Down Expand Up @@ -24879,11 +24882,11 @@ TEST(CodeCacheScriptModuleMismatch) {
v8::Context::Scope cscope(context);
v8::Local<v8::String> source_string = v8_str(source);
v8::ScriptOrigin script_origin(isolate, v8_str(origin));
v8::ScriptCompiler::Source source(source_string, script_origin);
v8::ScriptCompiler::Source script_source(source_string, script_origin);
v8::ScriptCompiler::CompileOptions option =
v8::ScriptCompiler::kNoCompileOptions;
v8::Local<v8::Script> script =
v8::ScriptCompiler::Compile(context, &source, option)
v8::ScriptCompiler::Compile(context, &script_source, option)
.ToLocalChecked();
cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
}
Expand Down Expand Up @@ -25147,7 +25150,7 @@ TEST(SealHandleScopeNested) {
v8::SealHandleScope seal(isolate);

{
v8::HandleScope handle_scope(isolate);
v8::HandleScope inner_handle_scope(isolate);

// Should work
v8::Local<v8::Object> obj = v8::Object::New(isolate);
Expand Down Expand Up @@ -26044,7 +26047,7 @@ TEST(CrossActivationEval) {
v8::HandleScope scope(isolate);
{
call_eval_context = v8::Context::New(isolate);
v8::Context::Scope scope(call_eval_context);
v8::Context::Scope context_scope(call_eval_context);
call_eval_bound_function =
Local<Function>::Cast(CompileRun("eval.bind(this, '1')"));
}
Expand Down
13 changes: 8 additions & 5 deletions test/cctest/test-code-stub-assembler.cc
Expand Up @@ -3036,12 +3036,15 @@ TEST(NewPromiseCapability) {
handle(JSFunction::cast(result->reject()), isolate)};

for (auto&& callback : callbacks) {
Handle<Context> context(Context::cast(callback->context()), isolate);
Handle<Context> callback_context(Context::cast(callback->context()),
isolate);
CHECK_EQ(isolate->root(RootIndex::kEmptyScopeInfo),
context->scope_info());
CHECK_EQ(*isolate->native_context(), context->native_context());
CHECK_EQ(PromiseBuiltins::kPromiseContextLength, context->length());
CHECK_EQ(context->get(PromiseBuiltins::kPromiseSlot), result->promise());
callback_context->scope_info());
CHECK_EQ(*isolate->native_context(), callback_context->native_context());
CHECK_EQ(PromiseBuiltins::kPromiseContextLength,
callback_context->length());
CHECK_EQ(callback_context->get(PromiseBuiltins::kPromiseSlot),
result->promise());
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/cctest/test-concurrent-feedback-vector.cc
Expand Up @@ -68,8 +68,8 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
if (state == MONOMORPHIC || state == POLYMORPHIC) {
MapHandles maps;
nexus.ExtractMaps(&maps);
for (unsigned int i = 0; i < maps.size(); i++) {
CHECK(maps[i]->IsMap());
for (unsigned int j = 0; j < maps.size(); j++) {
CHECK(maps[j]->IsMap());
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/cctest/test-concurrent-script-context-table.cc
Expand Up @@ -184,10 +184,10 @@ TEST(ScriptContextTable_AccessScriptContextTable) {
sema_started.Wait();

for (; initialized_entries < 1000; ++initialized_entries) {
Handle<Context> context =
Handle<Context> new_context =
factory->NewScriptContext(native_context, scope_info);
script_context_table =
ScriptContextTable::Extend(script_context_table, context);
ScriptContextTable::Extend(script_context_table, new_context);
native_context->synchronized_set_script_context_table(
*script_context_table);
// Update with relaxed semantics to not introduce ordering constraints.
Expand Down
2 changes: 1 addition & 1 deletion test/cctest/test-cpu-profiler.cc
Expand Up @@ -4277,7 +4277,7 @@ TEST(BytecodeFlushEventsEagerLogging) {

// This compile will add the code to the compilation cache.
{
v8::HandleScope scope(isolate);
v8::HandleScope inner_scope(isolate);
CompileRun(source);
}

Expand Down
21 changes: 11 additions & 10 deletions test/cctest/test-debug.cc
Expand Up @@ -3269,15 +3269,16 @@ TEST(DebugScriptLineEndsAreAscending) {
v8::HandleScope scope(isolate);

// Compile a test script.
v8::Local<v8::String> script = v8_str(isolate,
"function f() {\n"
" debugger;\n"
"}\n");
v8::Local<v8::String> script_source = v8_str(isolate,
"function f() {\n"
" debugger;\n"
"}\n");

v8::ScriptOrigin origin1 = v8::ScriptOrigin(isolate, v8_str(isolate, "name"));
v8::Local<v8::Script> script1 =
v8::Script::Compile(env.local(), script, &origin1).ToLocalChecked();
USE(script1);
v8::Local<v8::Script> script =
v8::Script::Compile(env.local(), script_source, &origin1)
.ToLocalChecked();
USE(script);

Handle<v8::internal::FixedArray> instances;
{
Expand All @@ -3287,12 +3288,12 @@ TEST(DebugScriptLineEndsAreAscending) {

CHECK_GT(instances->length(), 0);
for (int i = 0; i < instances->length(); i++) {
Handle<v8::internal::Script> script = Handle<v8::internal::Script>(
Handle<v8::internal::Script> new_script = Handle<v8::internal::Script>(
v8::internal::Script::cast(instances->get(i)), CcTest::i_isolate());

v8::internal::Script::InitLineEnds(CcTest::i_isolate(), script);
v8::internal::Script::InitLineEnds(CcTest::i_isolate(), new_script);
v8::internal::FixedArray ends =
v8::internal::FixedArray::cast(script->line_ends());
v8::internal::FixedArray::cast(new_script->line_ends());
CHECK_GT(ends.length(), 0);

int prev_end = -1;
Expand Down
10 changes: 5 additions & 5 deletions test/cctest/test-field-type-tracking.cc
Expand Up @@ -785,9 +785,9 @@ void TestGeneralizeField(const CRFTData& from, const CRFTData& to,
// Check the cases when the map being reconfigured is NOT a part of the
// transition tree. "None -> anything" representation changes make sense
// only for "attached" maps.
int indices[] = {0, kPropCount - 1};
for (int i = 0; i < static_cast<int>(arraysize(indices)); i++) {
TestGeneralizeField(indices[i], 2, from, to, expected, expected_alert);
int indices2[] = {0, kPropCount - 1};
for (int i = 0; i < static_cast<int>(arraysize(indices2)); i++) {
TestGeneralizeField(indices2[i], 2, from, to, expected, expected_alert);
}

// Check that reconfiguration to the very same field works correctly.
Expand Down Expand Up @@ -2196,8 +2196,8 @@ static void TestGeneralizeFieldWithSpecialTransition(
if (config->is_non_equivalent_transition()) {
// In case of non-equivalent transition currently we generalize all
// representations.
for (int i = 0; i < kPropCount; i++) {
expectations2.GeneralizeField(i);
for (int j = 0; j < kPropCount; j++) {
expectations2.GeneralizeField(j);
}
CHECK(new_map2->GetBackPointer().IsUndefined(isolate));
CHECK(expectations2.Check(*new_map2));
Expand Down

0 comments on commit bd87901

Please sign in to comment.