[test][cleanup] Fix -Wshadow warnings in unittests

Bug: v8:12244,v8:12245
Change-Id: I0bcc6dcc148138a6c3b2c87fd8819a9e809e5668
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3182230
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77080}
This commit is contained in:
Jakob Kummerow 2021-09-24 17:00:41 +02:00 committed by V8 LUCI CQ
parent 732d09a63b
commit dba4f45166
12 changed files with 63 additions and 62 deletions

View File

@ -28,15 +28,15 @@ class ControlEquivalenceTest : public GraphTest {
} }
protected: protected:
void ComputeEquivalence(Node* node) { void ComputeEquivalence(Node* end_node) {
graph()->SetEnd(graph()->NewNode(common()->End(1), node)); graph()->SetEnd(graph()->NewNode(common()->End(1), end_node));
if (FLAG_trace_turbo) { if (FLAG_trace_turbo) {
SourcePositionTable table(graph()); SourcePositionTable table(graph());
NodeOriginTable table2(graph()); NodeOriginTable table2(graph());
StdoutStream{} << AsJSON(*graph(), &table, &table2); StdoutStream{} << AsJSON(*graph(), &table, &table2);
} }
ControlEquivalence equivalence(zone(), graph()); ControlEquivalence equivalence(zone(), graph());
equivalence.Run(node); equivalence.Run(end_node);
classes_.resize(graph()->NodeCount()); classes_.resize(graph()->NodeCount());
for (Node* node : all_nodes_) { for (Node* node : all_nodes_) {
classes_[node->id()] = equivalence.ClassOf(node); classes_[node->id()] = equivalence.ClassOf(node);

View File

@ -712,7 +712,7 @@ TEST_F(GraphReducerTest, Forwarding3) {
A1Forwarder r; A1Forwarder r;
for (size_t i = 0; i < 3; i++) { for (size_t j = 0; j < 3; j++) {
size_t before = graph()->NodeCount(); size_t before = graph()->NodeCount();
ReduceGraph(&r); ReduceGraph(&r);
EXPECT_EQ(before, graph()->NodeCount()); EXPECT_EQ(before, graph()->NodeCount());

View File

@ -523,10 +523,10 @@ TEST_F(LoopPeelingTest, SimpleLoopWithUnmarkedExit) {
{ {
LoopTree* loop_tree = GetLoopTree(); LoopTree* loop_tree = GetLoopTree();
LoopTree::Loop* loop = loop_tree->outer_loops()[0]; LoopTree::Loop* outer_loop = loop_tree->outer_loops()[0];
LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions(), LoopPeeler peeler(graph(), common(), loop_tree, zone(), source_positions(),
node_origins()); node_origins());
EXPECT_FALSE(peeler.CanPeel(loop)); EXPECT_FALSE(peeler.CanPeel(outer_loop));
} }
} }

View File

@ -106,8 +106,8 @@ TEST_F(SchedulerRPOTest, Line) {
BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule);
CheckRPONumbers(order, 1 + i, false); CheckRPONumbers(order, 1 + i, false);
for (size_t i = 0; i < schedule.BasicBlockCount(); i++) { for (size_t j = 0; j < schedule.BasicBlockCount(); j++) {
BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i)); BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(j));
if (block->rpo_number() >= 0 && block->SuccessorCount() == 1) { if (block->rpo_number() >= 0 && block->SuccessorCount() == 1) {
EXPECT_EQ(block->rpo_number() + 1, block->SuccessorAt(0)->rpo_number()); EXPECT_EQ(block->rpo_number() + 1, block->SuccessorAt(0)->rpo_number());
} }

View File

@ -200,7 +200,7 @@ class TyperTest : public TypedGraphTest {
Type r1 = RandomRange(); Type r1 = RandomRange();
Type r2 = RandomRange(); Type r2 = RandomRange();
Type expected_type = TypeBinaryOp(op, r1, r2); Type expected_type = TypeBinaryOp(op, r1, r2);
for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) {
double x1 = RandomInt(r1.AsRange()); double x1 = RandomInt(r1.AsRange());
double x2 = RandomInt(r2.AsRange()); double x2 = RandomInt(r2.AsRange());
double result_value = opfun(x1, x2); double result_value = opfun(x1, x2);
@ -229,7 +229,7 @@ class TyperTest : public TypedGraphTest {
Type r1 = RandomRange(); Type r1 = RandomRange();
Type r2 = RandomRange(); Type r2 = RandomRange();
Type expected_type = TypeBinaryOp(op, r1, r2); Type expected_type = TypeBinaryOp(op, r1, r2);
for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) {
double x1 = RandomInt(r1.AsRange()); double x1 = RandomInt(r1.AsRange());
double x2 = RandomInt(r2.AsRange()); double x2 = RandomInt(r2.AsRange());
bool result_value = opfun(x1, x2); bool result_value = opfun(x1, x2);
@ -249,7 +249,7 @@ class TyperTest : public TypedGraphTest {
Type r1 = RandomRange(true); Type r1 = RandomRange(true);
Type r2 = RandomRange(true); Type r2 = RandomRange(true);
Type expected_type = TypeBinaryOp(op, r1, r2); Type expected_type = TypeBinaryOp(op, r1, r2);
for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) {
int32_t x1 = static_cast<int32_t>(RandomInt(r1.AsRange())); int32_t x1 = static_cast<int32_t>(RandomInt(r1.AsRange()));
int32_t x2 = static_cast<int32_t>(RandomInt(r2.AsRange())); int32_t x2 = static_cast<int32_t>(RandomInt(r2.AsRange()));
double result_value = opfun(x1, x2); double result_value = opfun(x1, x2);

View File

@ -153,7 +153,7 @@ TEST_F(LocalEmbedderHeapTracerWithIsolate,
EmbedderStackStateScope scope( EmbedderStackStateScope scope(
&local_tracer, EmbedderHeapTracer::EmbedderStackState::kNoHeapPointers); &local_tracer, EmbedderHeapTracer::EmbedderStackState::kNoHeapPointers);
{ {
EmbedderStackStateScope scope( EmbedderStackStateScope nested_scope(
&local_tracer, &local_tracer,
EmbedderHeapTracer::EmbedderStackState::kMayContainHeapPointers); EmbedderHeapTracer::EmbedderStackState::kMayContainHeapPointers);
EXPECT_CALL( EXPECT_CALL(

View File

@ -132,8 +132,8 @@ class BackgroundThreadForGCEpilogue final : public v8::base::Thread {
unparked_scope.emplace(&lh); unparked_scope.emplace(&lh);
} }
{ {
base::Optional<UnparkedScope> unparked_scope; base::Optional<UnparkedScope> nested_unparked_scope;
if (parked_) unparked_scope.emplace(&lh); if (parked_) nested_unparked_scope.emplace(&lh);
lh.AddGCEpilogueCallback(&GCEpilogue::Callback, epilogue_); lh.AddGCEpilogueCallback(&GCEpilogue::Callback, epilogue_);
} }
epilogue_->NotifyStarted(); epilogue_->NotifyStarted();
@ -141,8 +141,8 @@ class BackgroundThreadForGCEpilogue final : public v8::base::Thread {
lh.Safepoint(); lh.Safepoint();
} }
{ {
base::Optional<UnparkedScope> unparked_scope; base::Optional<UnparkedScope> nested_unparked_scope;
if (parked_) unparked_scope.emplace(&lh); if (parked_) nested_unparked_scope.emplace(&lh);
lh.RemoveGCEpilogueCallback(&GCEpilogue::Callback, epilogue_); lh.RemoveGCEpilogueCallback(&GCEpilogue::Callback, epilogue_);
} }
} }

View File

@ -82,7 +82,7 @@ TEST_F(SafepointTest, StopParkedThreads) {
CHECK_EQ(safepoints, kRuns); CHECK_EQ(safepoints, kRuns);
} }
static const int kRuns = 10000; static const int kIterations = 10000;
class RunningThread final : public v8::base::Thread { class RunningThread final : public v8::base::Thread {
public: public:
@ -95,7 +95,7 @@ class RunningThread final : public v8::base::Thread {
LocalHeap local_heap(heap_, ThreadKind::kBackground); LocalHeap local_heap(heap_, ThreadKind::kBackground);
UnparkedScope unparked_scope(&local_heap); UnparkedScope unparked_scope(&local_heap);
for (int i = 0; i < kRuns; i++) { for (int i = 0; i < kIterations; i++) {
counter_->fetch_add(1); counter_->fetch_add(1);
if (i % 100 == 0) local_heap.Safepoint(); if (i % 100 == 0) local_heap.Safepoint();
} }

View File

@ -189,15 +189,16 @@ TEST_F(SpacesTest, FreeListManySelectFreeListCategoryType) {
} }
for (size_t size : sizes) { for (size_t size : sizes) {
FreeListCategoryType cat = free_list.SelectFreeListCategoryType(size); FreeListCategoryType selected =
if (cat == free_list.last_category_) { free_list.SelectFreeListCategoryType(size);
// If cat == last_category, then we make sure that |size| indeeds fits if (selected == free_list.last_category_) {
// in the last category. // If selected == last_category, then we make sure that |size| indeeds
EXPECT_LE(free_list.categories_min[cat], size); // fits in the last category.
EXPECT_LE(free_list.categories_min[selected], size);
} else { } else {
// Otherwise, size should fit in |cat|, but not in |cat+1|. // Otherwise, size should fit in |selected|, but not in |selected+1|.
EXPECT_LE(free_list.categories_min[cat], size); EXPECT_LE(free_list.categories_min[selected], size);
EXPECT_LT(size, free_list.categories_min[cat + 1]); EXPECT_LT(size, free_list.categories_min[selected + 1]);
} }
} }
} }
@ -268,25 +269,26 @@ TEST_F(SpacesTest,
} }
for (size_t size : sizes) { for (size_t size : sizes) {
FreeListCategoryType cat = FreeListCategoryType selected =
free_list.SelectFastAllocationFreeListCategoryType(size); free_list.SelectFastAllocationFreeListCategoryType(size);
if (size <= FreeListManyCachedFastPath::kTinyObjectMaxSize) { if (size <= FreeListManyCachedFastPath::kTinyObjectMaxSize) {
// For tiny objects, the first category of the fast path should be // For tiny objects, the first category of the fast path should be
// chosen. // chosen.
EXPECT_TRUE(cat == FreeListManyCachedFastPath::kFastPathFirstCategory); EXPECT_TRUE(selected ==
FreeListManyCachedFastPath::kFastPathFirstCategory);
} else if (size >= free_list.categories_min[free_list.last_category_] - } else if (size >= free_list.categories_min[free_list.last_category_] -
FreeListManyCachedFastPath::kFastPathOffset) { FreeListManyCachedFastPath::kFastPathOffset) {
// For objects close to the minimum of the last category, the last // For objects close to the minimum of the last category, the last
// category is chosen. // category is chosen.
EXPECT_EQ(cat, free_list.last_category_); EXPECT_EQ(selected, free_list.last_category_);
} else { } else {
// For other objects, the chosen category must satisfy that its minimum // For other objects, the chosen category must satisfy that its minimum
// is at least |size|+1.85k. // is at least |size|+1.85k.
EXPECT_GE(free_list.categories_min[cat], EXPECT_GE(free_list.categories_min[selected],
size + FreeListManyCachedFastPath::kFastPathOffset); size + FreeListManyCachedFastPath::kFastPathOffset);
// And the smaller categoriy's minimum is less than |size|+1.85k // And the smaller categoriy's minimum is less than |size|+1.85k
// (otherwise it would have been chosen instead). // (otherwise it would have been chosen instead).
EXPECT_LT(free_list.categories_min[cat - 1], EXPECT_LT(free_list.categories_min[selected - 1],
size + FreeListManyCachedFastPath::kFastPathOffset); size + FreeListManyCachedFastPath::kFastPathOffset);
} }
} }

View File

@ -713,11 +713,11 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) {
.JumpLoop(&loop_header, 0, 0) .JumpLoop(&loop_header, 0, 0)
.Bind(&after_loop); .Bind(&after_loop);
for (int i = 0; i < 42; i++) { for (int i = 0; i < 42; i++) {
BytecodeLabel after_loop; BytecodeLabel also_after_loop;
// Conditional jump to force the code after the JumpLoop to be live. // Conditional jump to force the code after the JumpLoop to be live.
builder.JumpIfNull(&after_loop) builder.JumpIfNull(&also_after_loop)
.JumpLoop(&loop_header, 0, 0) .JumpLoop(&loop_header, 0, 0)
.Bind(&after_loop); .Bind(&also_after_loop);
} }
// Add padding to force wide backwards jumps. // Add padding to force wide backwards jumps.

View File

@ -127,32 +127,32 @@ namespace module_decoder_unittest {
#define EXPECT_VERIFIES(data) \ #define EXPECT_VERIFIES(data) \
do { \ do { \
ModuleResult result = DecodeModule(data, data + sizeof(data)); \ ModuleResult _result = DecodeModule(data, data + sizeof(data)); \
EXPECT_OK(result); \ EXPECT_OK(_result); \
} while (false) } while (false)
#define EXPECT_FAILURE_LEN(data, length) \ #define EXPECT_FAILURE_LEN(data, length) \
do { \ do { \
ModuleResult result = DecodeModule(data, data + length); \ ModuleResult _result = DecodeModule(data, data + length); \
EXPECT_FALSE(result.ok()); \ EXPECT_FALSE(_result.ok()); \
} while (false) } while (false)
#define EXPECT_FAILURE(data) EXPECT_FAILURE_LEN(data, sizeof(data)) #define EXPECT_FAILURE(data) EXPECT_FAILURE_LEN(data, sizeof(data))
#define EXPECT_FAILURE_WITH_MSG(data, msg) \ #define EXPECT_FAILURE_WITH_MSG(data, msg) \
do { \ do { \
ModuleResult result = DecodeModule(data, data + sizeof(data)); \ ModuleResult _result = DecodeModule(data, data + sizeof(data)); \
EXPECT_FALSE(result.ok()); \ EXPECT_FALSE(_result.ok()); \
if (!result.ok()) { \ if (!_result.ok()) { \
EXPECT_THAT(result.error().message(), HasSubstr(msg)); \ EXPECT_THAT(_result.error().message(), HasSubstr(msg)); \
} \ } \
} while (false) } while (false)
#define EXPECT_OFF_END_FAILURE(data, min) \ #define EXPECT_OFF_END_FAILURE(data, min) \
do { \ do { \
STATIC_ASSERT(min < arraysize(data)); \ STATIC_ASSERT(min < arraysize(data)); \
for (size_t length = min; length < arraysize(data); length++) { \ for (size_t _length = min; _length < arraysize(data); _length++) { \
EXPECT_FAILURE_LEN(data, length); \ EXPECT_FAILURE_LEN(data, _length); \
} \ } \
} while (false) } while (false)

View File

@ -36,21 +36,20 @@ GET_TYPE_NAME(double)
// |var| while inside the loop body. // |var| while inside the loop body.
#define TRACED_FOREACH(_type, _var, _container) \ #define TRACED_FOREACH(_type, _var, _container) \
for (_type const _var : _container) \ for (_type const _var : _container) \
for (bool _done = false; !_done;) \ for (bool _var##_done = false; !_var##_done;) \
for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \ for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \
!_done; _done = true) !_var##_done; _var##_done = true)
// TRACED_FORRANGE(type, var, low, high) expands to a loop that assigns |var| // TRACED_FORRANGE(type, var, low, high) expands to a loop that assigns |var|
// every value in the range |low| to (including) |high| and adds a // every value in the range |low| to (including) |high| and adds a
// SCOPED_TRACE() message for the |var| while inside the loop body. // SCOPED_TRACE() message for the |var| while inside the loop body.
// TODO(bmeurer): Migrate to C++11 once we're ready. // TODO(bmeurer): Migrate to C++11 once we're ready.
#define TRACED_FORRANGE(_type, _var, _low, _high) \ #define TRACED_FORRANGE(_type, _var, _low, _high) \
for (_type _i = _low; _i <= _high; ++_i) \ for (_type _var##_i = _low; _var##_i <= _high; ++_var##_i) \
for (bool _done = false; !_done;) \ for (bool _var##_done = false; !_var##_done;) \
for (_type const _var = _i; !_done;) \ for (_type const _var = _var##_i; !_var##_done;) \
for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \ for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \
!_done; _done = true) !_var##_done; _var##_done = true)
} // namespace internal } // namespace internal
} // namespace testing } // namespace testing