1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-21 18:22:53 +01:00

[RGT] Recode more unreachable assertions and tautologies

Count iterations of zero-trip loops and assert the count is zero,
rather than asserting inside the loop.
Unreachable functions should use llvm_unreachable.
Remove tautological 'if' statements, even when they're following a
pattern of checks.

Found by the Rotten Green Tests project.
This commit is contained in:
Paul Robinson 2021-03-19 07:43:36 -07:00
parent ea4ee76d88
commit 05294a4e68
5 changed files with 17 additions and 32 deletions

View File

@ -1142,10 +1142,12 @@ TYPED_TEST(BitVectorTest, Iterators) {
TypeParam Empty;
EXPECT_EQ(Empty.set_bits_begin(), Empty.set_bits_end());
int BitCount = 0;
for (unsigned Bit : Empty.set_bits()) {
(void)Bit;
EXPECT_TRUE(false);
BitCount++;
}
ASSERT_EQ(BitCount, 0);
TypeParam ToFill(100, false);
ToFill.set(0);

View File

@ -245,7 +245,6 @@ TEST_F(ImmutableListTest, LongListOrderingTest) {
int i = 0;
for (ImmutableList<Wrapper<long>>::iterator I = L.begin(), E = L.end();
I != E; ++I) {
ASSERT_EQ(i, *I);
i++;
}
ASSERT_EQ(0, i);

View File

@ -646,12 +646,8 @@ TEST(StringRefTest, getAsInteger) {
ASSERT_TRUE(U32Success);
}
bool U64Success = StringRef(Unsigned[i].Str).getAsInteger(0, U64);
if (static_cast<uint64_t>(Unsigned[i].Expected) == Unsigned[i].Expected) {
ASSERT_FALSE(U64Success);
EXPECT_EQ(U64, Unsigned[i].Expected);
} else {
ASSERT_TRUE(U64Success);
}
ASSERT_FALSE(U64Success);
EXPECT_EQ(U64, Unsigned[i].Expected);
}
int8_t S8;
@ -682,12 +678,8 @@ TEST(StringRefTest, getAsInteger) {
ASSERT_TRUE(S32Success);
}
bool S64Success = StringRef(Signed[i].Str).getAsInteger(0, S64);
if (static_cast<int64_t>(Signed[i].Expected) == Signed[i].Expected) {
ASSERT_FALSE(S64Success);
EXPECT_EQ(S64, Signed[i].Expected);
} else {
ASSERT_TRUE(S64Success);
}
ASSERT_FALSE(S64Success);
EXPECT_EQ(S64, Signed[i].Expected);
}
}
@ -828,14 +820,9 @@ TEST(StringRefTest, consumeIntegerUnsigned) {
Str = ConsumeUnsigned[i].Str;
bool U64Success = Str.consumeInteger(0, U64);
if (static_cast<uint64_t>(ConsumeUnsigned[i].Expected) ==
ConsumeUnsigned[i].Expected) {
ASSERT_FALSE(U64Success);
EXPECT_EQ(U64, ConsumeUnsigned[i].Expected);
EXPECT_EQ(Str, ConsumeUnsigned[i].Leftover);
} else {
ASSERT_TRUE(U64Success);
}
ASSERT_FALSE(U64Success);
EXPECT_EQ(U64, ConsumeUnsigned[i].Expected);
EXPECT_EQ(Str, ConsumeUnsigned[i].Leftover);
}
}
@ -881,14 +868,9 @@ TEST(StringRefTest, consumeIntegerSigned) {
Str = ConsumeSigned[i].Str;
bool S64Success = Str.consumeInteger(0, S64);
if (static_cast<int64_t>(ConsumeSigned[i].Expected) ==
ConsumeSigned[i].Expected) {
ASSERT_FALSE(S64Success);
EXPECT_EQ(S64, ConsumeSigned[i].Expected);
EXPECT_EQ(Str, ConsumeSigned[i].Leftover);
} else {
ASSERT_TRUE(S64Success);
}
ASSERT_FALSE(S64Success);
EXPECT_EQ(S64, ConsumeSigned[i].Expected);
EXPECT_EQ(Str, ConsumeSigned[i].Leftover);
}
}

View File

@ -37,10 +37,12 @@ TEST(BasicBlockTest, PhiRange) {
BranchInst::Create(BB.get(), BB2.get());
// Make sure this doesn't crash if there are no phis.
int PhiCount = 0;
for (auto &PN : BB->phis()) {
(void)PN;
EXPECT_TRUE(false) << "empty block should have no phis";
PhiCount++;
}
ASSERT_EQ(PhiCount, 0) << "empty block should have no phis";
// Make it a cycle.
auto *BI = BranchInst::Create(BB.get(), BB.get());

View File

@ -72,7 +72,7 @@ protected:
};
static void expectNoDiags(const DiagnosticInfo &DI, void *C) {
EXPECT_TRUE(false);
llvm_unreachable("expectNoDiags called!");
}
TEST_F(LinkModuleTest, BlockAddress) {