[NFC] Remove dead code

This commit is contained in:
Guillaume Chatelet 2022-06-25 17:18:29 +00:00
parent 303b214699
commit 1baf1fc276
3 changed files with 6 additions and 25 deletions

View File

@ -260,14 +260,6 @@ inline bool operator>(Align Lhs, uint64_t Rhs) {
return Lhs.value() > Rhs;
}
/// Comparisons between MaybeAlign and scalars.
inline bool operator==(MaybeAlign Lhs, uint64_t Rhs) {
return Lhs ? (*Lhs).value() == Rhs : Rhs == 0;
}
inline bool operator!=(MaybeAlign Lhs, uint64_t Rhs) {
return Lhs ? (*Lhs).value() != Rhs : Rhs != 0;
}
/// Comparisons operators between Align.
inline bool operator==(Align Lhs, Align Rhs) {
return Lhs.ShiftValue == Rhs.ShiftValue;

View File

@ -90,14 +90,14 @@ TEST(Attributes, RemoveAlign) {
B_stackalign.addAttribute(StackAlignAttr);
AttributeSet AS = AttributeSet::get(C, B_align_readonly);
EXPECT_TRUE(AS.getAlignment() == 8);
EXPECT_TRUE(AS.getAlignment() == MaybeAlign(8));
EXPECT_TRUE(AS.hasAttribute(Attribute::ReadOnly));
AS = AS.removeAttribute(C, Attribute::Alignment);
EXPECT_FALSE(AS.hasAttribute(Attribute::Alignment));
EXPECT_TRUE(AS.hasAttribute(Attribute::ReadOnly));
AS = AttributeSet::get(C, B_align_readonly);
AS = AS.removeAttributes(C, B_align);
EXPECT_TRUE(AS.getAlignment() == 0);
EXPECT_TRUE(AS.getAlignment() == None);
EXPECT_TRUE(AS.hasAttribute(Attribute::ReadOnly));
AttributeList AL;
@ -106,18 +106,18 @@ TEST(Attributes, RemoveAlign) {
EXPECT_TRUE(AL.hasRetAttrs());
EXPECT_TRUE(AL.hasRetAttr(Attribute::StackAlignment));
EXPECT_TRUE(AL.hasRetAttr(Attribute::OptimizeNone));
EXPECT_TRUE(AL.getRetStackAlignment() == 32);
EXPECT_TRUE(AL.getRetStackAlignment() == MaybeAlign(32));
EXPECT_TRUE(AL.hasParamAttrs(0));
EXPECT_TRUE(AL.hasParamAttr(0, Attribute::Alignment));
EXPECT_TRUE(AL.hasParamAttr(0, Attribute::ReadOnly));
EXPECT_TRUE(AL.getParamAlignment(0) == 8);
EXPECT_TRUE(AL.getParamAlignment(0) == MaybeAlign(8));
AL = AL.removeParamAttribute(C, 0, Attribute::Alignment);
EXPECT_FALSE(AL.hasParamAttr(0, Attribute::Alignment));
EXPECT_TRUE(AL.hasParamAttr(0, Attribute::ReadOnly));
EXPECT_TRUE(AL.hasRetAttr(Attribute::StackAlignment));
EXPECT_TRUE(AL.hasRetAttr(Attribute::OptimizeNone));
EXPECT_TRUE(AL.getRetStackAlignment() == 32);
EXPECT_TRUE(AL.getRetStackAlignment() == MaybeAlign(32));
AL = AL.removeRetAttribute(C, Attribute::StackAlignment);
EXPECT_FALSE(AL.hasParamAttr(0, Attribute::Alignment));
@ -134,7 +134,7 @@ TEST(Attributes, RemoveAlign) {
EXPECT_TRUE(AL2.hasParamAttr(0, Attribute::ReadOnly));
EXPECT_TRUE(AL2.hasRetAttr(Attribute::StackAlignment));
EXPECT_TRUE(AL2.hasRetAttr(Attribute::OptimizeNone));
EXPECT_TRUE(AL2.getRetStackAlignment() == 32);
EXPECT_TRUE(AL2.getRetStackAlignment() == MaybeAlign(32));
AL2 = AL2.removeRetAttributes(C, B_stackalign);
EXPECT_FALSE(AL2.hasParamAttr(0, Attribute::Alignment));

View File

@ -227,9 +227,6 @@ TEST(AlignmentTest, AlignComparisons) {
EXPECT_EQ(MA, MA);
EXPECT_NE(MA, MB);
EXPECT_EQ(MA, MA ? (*MA).value() : 0);
EXPECT_NE(MA, MB ? (*MB).value() : 0);
EXPECT_EQ(std::max(A, B), B);
EXPECT_EQ(std::min(A, B), A);
}
@ -277,14 +274,6 @@ TEST(AlignmentDeathTest, ComparisonsWithZero) {
}
}
TEST(AlignmentDeathTest, CompareMaybeAlignToZero) {
for (uint64_t Value : getValidAlignmentsForDeathTest()) {
// MaybeAlign is allowed to be == or != 0
(void)(MaybeAlign(Value) == 0);
(void)(MaybeAlign(Value) != 0);
}
}
TEST(AlignmentDeathTest, AlignAddr) {
const void *const unaligned_high_ptr =
reinterpret_cast<const void *>(std::numeric_limits<uintptr_t>::max() - 1);