[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:
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);

View File

@ -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());

View File

@ -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));
}
}

View File

@ -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());
}

View File

@ -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<int32_t>(RandomInt(r1.AsRange()));
int32_t x2 = static_cast<int32_t>(RandomInt(r2.AsRange()));
double result_value = opfun(x1, x2);

View File

@ -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(

View File

@ -132,8 +132,8 @@ class BackgroundThreadForGCEpilogue final : public v8::base::Thread {
unparked_scope.emplace(&lh);
}
{
base::Optional<UnparkedScope> unparked_scope;
if (parked_) unparked_scope.emplace(&lh);
base::Optional<UnparkedScope> 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<UnparkedScope> unparked_scope;
if (parked_) unparked_scope.emplace(&lh);
base::Optional<UnparkedScope> nested_unparked_scope;
if (parked_) nested_unparked_scope.emplace(&lh);
lh.RemoveGCEpilogueCallback(&GCEpilogue::Callback, epilogue_);
}
}

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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) \

View File

@ -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