diff --git a/test/unittests/compiler/control-equivalence-unittest.cc b/test/unittests/compiler/control-equivalence-unittest.cc index c37aeeb839..26cfe3ead0 100644 --- a/test/unittests/compiler/control-equivalence-unittest.cc +++ b/test/unittests/compiler/control-equivalence-unittest.cc @@ -28,15 +28,15 @@ class ControlEquivalenceTest : public GraphTest { } protected: - void ComputeEquivalence(Node* node) { - graph()->SetEnd(graph()->NewNode(common()->End(1), node)); + void ComputeEquivalence(Node* end_node) { + graph()->SetEnd(graph()->NewNode(common()->End(1), end_node)); if (FLAG_trace_turbo) { SourcePositionTable table(graph()); NodeOriginTable table2(graph()); StdoutStream{} << AsJSON(*graph(), &table, &table2); } ControlEquivalence equivalence(zone(), graph()); - equivalence.Run(node); + equivalence.Run(end_node); classes_.resize(graph()->NodeCount()); for (Node* node : all_nodes_) { classes_[node->id()] = equivalence.ClassOf(node); diff --git a/test/unittests/compiler/graph-reducer-unittest.cc b/test/unittests/compiler/graph-reducer-unittest.cc index bb965cce94..98de4c7f7c 100644 --- a/test/unittests/compiler/graph-reducer-unittest.cc +++ b/test/unittests/compiler/graph-reducer-unittest.cc @@ -712,7 +712,7 @@ TEST_F(GraphReducerTest, Forwarding3) { A1Forwarder r; - for (size_t i = 0; i < 3; i++) { + for (size_t j = 0; j < 3; j++) { size_t before = graph()->NodeCount(); ReduceGraph(&r); EXPECT_EQ(before, graph()->NodeCount()); diff --git a/test/unittests/compiler/loop-peeling-unittest.cc b/test/unittests/compiler/loop-peeling-unittest.cc index 27e6b32560..8c8178f48b 100644 --- a/test/unittests/compiler/loop-peeling-unittest.cc +++ b/test/unittests/compiler/loop-peeling-unittest.cc @@ -523,10 +523,10 @@ TEST_F(LoopPeelingTest, SimpleLoopWithUnmarkedExit) { { 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(), node_origins()); - EXPECT_FALSE(peeler.CanPeel(loop)); + EXPECT_FALSE(peeler.CanPeel(outer_loop)); } } diff --git a/test/unittests/compiler/scheduler-rpo-unittest.cc b/test/unittests/compiler/scheduler-rpo-unittest.cc index 68a7ffea4a..1ba86542b0 100644 --- a/test/unittests/compiler/scheduler-rpo-unittest.cc +++ b/test/unittests/compiler/scheduler-rpo-unittest.cc @@ -106,8 +106,8 @@ TEST_F(SchedulerRPOTest, Line) { BasicBlockVector* order = Scheduler::ComputeSpecialRPO(zone(), &schedule); CheckRPONumbers(order, 1 + i, false); - for (size_t i = 0; i < schedule.BasicBlockCount(); i++) { - BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(i)); + for (size_t j = 0; j < schedule.BasicBlockCount(); j++) { + BasicBlock* block = schedule.GetBlockById(BasicBlock::Id::FromSize(j)); if (block->rpo_number() >= 0 && block->SuccessorCount() == 1) { EXPECT_EQ(block->rpo_number() + 1, block->SuccessorAt(0)->rpo_number()); } diff --git a/test/unittests/compiler/typer-unittest.cc b/test/unittests/compiler/typer-unittest.cc index 242aa93f8d..bede5d5441 100644 --- a/test/unittests/compiler/typer-unittest.cc +++ b/test/unittests/compiler/typer-unittest.cc @@ -200,7 +200,7 @@ class TyperTest : public TypedGraphTest { Type r1 = RandomRange(); Type r2 = RandomRange(); 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 x2 = RandomInt(r2.AsRange()); double result_value = opfun(x1, x2); @@ -229,7 +229,7 @@ class TyperTest : public TypedGraphTest { Type r1 = RandomRange(); Type r2 = RandomRange(); 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 x2 = RandomInt(r2.AsRange()); bool result_value = opfun(x1, x2); @@ -249,7 +249,7 @@ class TyperTest : public TypedGraphTest { Type r1 = RandomRange(true); Type r2 = RandomRange(true); 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(RandomInt(r1.AsRange())); int32_t x2 = static_cast(RandomInt(r2.AsRange())); double result_value = opfun(x1, x2); diff --git a/test/unittests/heap/embedder-tracing-unittest.cc b/test/unittests/heap/embedder-tracing-unittest.cc index 28c40b2671..3e5813dfe9 100644 --- a/test/unittests/heap/embedder-tracing-unittest.cc +++ b/test/unittests/heap/embedder-tracing-unittest.cc @@ -153,7 +153,7 @@ TEST_F(LocalEmbedderHeapTracerWithIsolate, EmbedderStackStateScope scope( &local_tracer, EmbedderHeapTracer::EmbedderStackState::kNoHeapPointers); { - EmbedderStackStateScope scope( + EmbedderStackStateScope nested_scope( &local_tracer, EmbedderHeapTracer::EmbedderStackState::kMayContainHeapPointers); EXPECT_CALL( diff --git a/test/unittests/heap/local-heap-unittest.cc b/test/unittests/heap/local-heap-unittest.cc index 92b5eef8dc..a009d9433c 100644 --- a/test/unittests/heap/local-heap-unittest.cc +++ b/test/unittests/heap/local-heap-unittest.cc @@ -132,8 +132,8 @@ class BackgroundThreadForGCEpilogue final : public v8::base::Thread { unparked_scope.emplace(&lh); } { - base::Optional unparked_scope; - if (parked_) unparked_scope.emplace(&lh); + base::Optional nested_unparked_scope; + if (parked_) nested_unparked_scope.emplace(&lh); lh.AddGCEpilogueCallback(&GCEpilogue::Callback, epilogue_); } epilogue_->NotifyStarted(); @@ -141,8 +141,8 @@ class BackgroundThreadForGCEpilogue final : public v8::base::Thread { lh.Safepoint(); } { - base::Optional unparked_scope; - if (parked_) unparked_scope.emplace(&lh); + base::Optional nested_unparked_scope; + if (parked_) nested_unparked_scope.emplace(&lh); lh.RemoveGCEpilogueCallback(&GCEpilogue::Callback, epilogue_); } } diff --git a/test/unittests/heap/safepoint-unittest.cc b/test/unittests/heap/safepoint-unittest.cc index 8cd21c1bed..d7bfdda2cd 100644 --- a/test/unittests/heap/safepoint-unittest.cc +++ b/test/unittests/heap/safepoint-unittest.cc @@ -82,7 +82,7 @@ TEST_F(SafepointTest, StopParkedThreads) { CHECK_EQ(safepoints, kRuns); } -static const int kRuns = 10000; +static const int kIterations = 10000; class RunningThread final : public v8::base::Thread { public: @@ -95,7 +95,7 @@ class RunningThread final : public v8::base::Thread { LocalHeap local_heap(heap_, ThreadKind::kBackground); UnparkedScope unparked_scope(&local_heap); - for (int i = 0; i < kRuns; i++) { + for (int i = 0; i < kIterations; i++) { counter_->fetch_add(1); if (i % 100 == 0) local_heap.Safepoint(); } diff --git a/test/unittests/heap/spaces-unittest.cc b/test/unittests/heap/spaces-unittest.cc index 8b732f3ea2..73011ef54f 100644 --- a/test/unittests/heap/spaces-unittest.cc +++ b/test/unittests/heap/spaces-unittest.cc @@ -189,15 +189,16 @@ TEST_F(SpacesTest, FreeListManySelectFreeListCategoryType) { } for (size_t size : sizes) { - FreeListCategoryType cat = free_list.SelectFreeListCategoryType(size); - if (cat == free_list.last_category_) { - // If cat == last_category, then we make sure that |size| indeeds fits - // in the last category. - EXPECT_LE(free_list.categories_min[cat], size); + FreeListCategoryType selected = + free_list.SelectFreeListCategoryType(size); + if (selected == free_list.last_category_) { + // If selected == last_category, then we make sure that |size| indeeds + // fits in the last category. + EXPECT_LE(free_list.categories_min[selected], size); } else { - // Otherwise, size should fit in |cat|, but not in |cat+1|. - EXPECT_LE(free_list.categories_min[cat], size); - EXPECT_LT(size, free_list.categories_min[cat + 1]); + // Otherwise, size should fit in |selected|, but not in |selected+1|. + EXPECT_LE(free_list.categories_min[selected], size); + EXPECT_LT(size, free_list.categories_min[selected + 1]); } } } @@ -268,25 +269,26 @@ TEST_F(SpacesTest, } for (size_t size : sizes) { - FreeListCategoryType cat = + FreeListCategoryType selected = free_list.SelectFastAllocationFreeListCategoryType(size); if (size <= FreeListManyCachedFastPath::kTinyObjectMaxSize) { // For tiny objects, the first category of the fast path should be // chosen. - EXPECT_TRUE(cat == FreeListManyCachedFastPath::kFastPathFirstCategory); + EXPECT_TRUE(selected == + FreeListManyCachedFastPath::kFastPathFirstCategory); } else if (size >= free_list.categories_min[free_list.last_category_] - FreeListManyCachedFastPath::kFastPathOffset) { // For objects close to the minimum of the last category, the last // category is chosen. - EXPECT_EQ(cat, free_list.last_category_); + EXPECT_EQ(selected, free_list.last_category_); } else { // For other objects, the chosen category must satisfy that its minimum // is at least |size|+1.85k. - EXPECT_GE(free_list.categories_min[cat], + EXPECT_GE(free_list.categories_min[selected], size + FreeListManyCachedFastPath::kFastPathOffset); // And the smaller categoriy's minimum is less than |size|+1.85k // (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); } } diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/test/unittests/interpreter/bytecode-array-builder-unittest.cc index 8838b0b94a..bfb4b3271e 100644 --- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc @@ -713,11 +713,11 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) { .JumpLoop(&loop_header, 0, 0) .Bind(&after_loop); 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. - builder.JumpIfNull(&after_loop) + builder.JumpIfNull(&also_after_loop) .JumpLoop(&loop_header, 0, 0) - .Bind(&after_loop); + .Bind(&also_after_loop); } // Add padding to force wide backwards jumps. diff --git a/test/unittests/wasm/module-decoder-unittest.cc b/test/unittests/wasm/module-decoder-unittest.cc index 54e9c84ebb..c632ca4414 100644 --- a/test/unittests/wasm/module-decoder-unittest.cc +++ b/test/unittests/wasm/module-decoder-unittest.cc @@ -125,35 +125,35 @@ namespace module_decoder_unittest { kWasmArrayTypeCode, type, (mutability ? 1 : 0) #define WASM_FUNCTION_DEF(...) kWasmFunctionTypeCode, __VA_ARGS__ -#define EXPECT_VERIFIES(data) \ - do { \ - ModuleResult result = DecodeModule(data, data + sizeof(data)); \ - EXPECT_OK(result); \ +#define EXPECT_VERIFIES(data) \ + do { \ + ModuleResult _result = DecodeModule(data, data + sizeof(data)); \ + EXPECT_OK(_result); \ } while (false) -#define EXPECT_FAILURE_LEN(data, length) \ - do { \ - ModuleResult result = DecodeModule(data, data + length); \ - EXPECT_FALSE(result.ok()); \ +#define EXPECT_FAILURE_LEN(data, length) \ + do { \ + ModuleResult _result = DecodeModule(data, data + length); \ + EXPECT_FALSE(_result.ok()); \ } while (false) #define EXPECT_FAILURE(data) EXPECT_FAILURE_LEN(data, sizeof(data)) -#define EXPECT_FAILURE_WITH_MSG(data, msg) \ - do { \ - ModuleResult result = DecodeModule(data, data + sizeof(data)); \ - EXPECT_FALSE(result.ok()); \ - if (!result.ok()) { \ - EXPECT_THAT(result.error().message(), HasSubstr(msg)); \ - } \ +#define EXPECT_FAILURE_WITH_MSG(data, msg) \ + do { \ + ModuleResult _result = DecodeModule(data, data + sizeof(data)); \ + EXPECT_FALSE(_result.ok()); \ + if (!_result.ok()) { \ + EXPECT_THAT(_result.error().message(), HasSubstr(msg)); \ + } \ } while (false) -#define EXPECT_OFF_END_FAILURE(data, min) \ - do { \ - STATIC_ASSERT(min < arraysize(data)); \ - for (size_t length = min; length < arraysize(data); length++) { \ - EXPECT_FAILURE_LEN(data, length); \ - } \ +#define EXPECT_OFF_END_FAILURE(data, min) \ + do { \ + STATIC_ASSERT(min < arraysize(data)); \ + for (size_t _length = min; _length < arraysize(data); _length++) { \ + EXPECT_FAILURE_LEN(data, _length); \ + } \ } while (false) #define EXPECT_OK(result) \ diff --git a/testing/gtest-support.h b/testing/gtest-support.h index ba0e2f41f9..21c8ebf4d3 100644 --- a/testing/gtest-support.h +++ b/testing/gtest-support.h @@ -36,21 +36,20 @@ GET_TYPE_NAME(double) // |var| while inside the loop body. #define TRACED_FOREACH(_type, _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); \ - !_done; _done = true) - + !_var##_done; _var##_done = true) // 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 // SCOPED_TRACE() message for the |var| while inside the loop body. // TODO(bmeurer): Migrate to C++11 once we're ready. #define TRACED_FORRANGE(_type, _var, _low, _high) \ - for (_type _i = _low; _i <= _high; ++_i) \ - for (bool _done = false; !_done;) \ - for (_type const _var = _i; !_done;) \ + for (_type _var##_i = _low; _var##_i <= _high; ++_var##_i) \ + for (bool _var##_done = false; !_var##_done;) \ + for (_type const _var = _var##_i; !_var##_done;) \ for (SCOPED_TRACE(::testing::Message() << #_var << " = " << _var); \ - !_done; _done = true) + !_var##_done; _var##_done = true) } // namespace internal } // namespace testing