aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/StringRefTest.cpp
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2021-03-19 07:43:36 -0700
committerPaul Robinson <paul.robinson@sony.com>2021-03-19 09:17:22 -0700
commitfb4f6057a637cabc687f7457d20a29da2c890ec0 (patch)
tree3072b0cd71ad56bf613f01a333288def689ac0cf /llvm/unittests/ADT/StringRefTest.cpp
parent9d2df964070700ae0d244e84572ac2275050e49a (diff)
downloadllvm-fb4f6057a637cabc687f7457d20a29da2c890ec0.zip
llvm-fb4f6057a637cabc687f7457d20a29da2c890ec0.tar.gz
llvm-fb4f6057a637cabc687f7457d20a29da2c890ec0.tar.bz2
[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.
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r--llvm/unittests/ADT/StringRefTest.cpp38
1 files changed, 10 insertions, 28 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp
index 50e38c5..e3f943b 100644
--- a/llvm/unittests/ADT/StringRefTest.cpp
+++ b/llvm/unittests/ADT/StringRefTest.cpp
@@ -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);
}
}