Fix an error in ConstantRange::getSignedMax on wrapped ranges. Thanks once

again to Daniel Dunbar and KLEE!

llvm-svn: 75449
This commit is contained in:
Nick Lewycky 2009-07-13 04:50:21 +00:00
parent 41a9bdab7b
commit 0cc1d245c4
2 changed files with 7 additions and 7 deletions

View File

@ -159,14 +159,10 @@ APInt ConstantRange::getSignedMax() const {
else
return SignedMax;
} else {
if ((getUpper() - 1).slt(getLower())) {
if (getLower() != SignedMax)
return SignedMax;
else
return getUpper() - 1;
} else {
if (getLower().isNegative() == getUpper().isNegative())
return SignedMax;
else
return getUpper() - 1;
}
}
}

View File

@ -137,6 +137,10 @@ TEST_F(ConstantRangeTest, GetMinsAndMaxes) {
EXPECT_EQ(One.getSignedMin(), APInt(16, 0xa));
EXPECT_EQ(Some.getSignedMin(), APInt(16, 0xa));
EXPECT_EQ(Wrap.getSignedMin(), APInt(16, INT16_MIN));
// Found by Klee
EXPECT_EQ(ConstantRange(APInt(4, 7), APInt(4, 0)).getSignedMax(),
APInt(4, 7));
}
TEST_F(ConstantRangeTest, Trunc) {