llvm.org GIT mirror llvm / cf9e07d
Fix a bug summing two full sets. The overflow checking doesn't handle sets as large as the full set, only those one size smaller. Thanks to Daniel Dunbar who found this bug using Klee! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75443 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 10 years ago
2 changed file(s) with 3 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
532532 ConstantRange::add(const ConstantRange &Other) const {
533533 if (isEmptySet() || Other.isEmptySet())
534534 return ConstantRange(getBitWidth(), /*isFullSet=*/false);
535 if (isFullSet() || Other.isFullSet())
536 return ConstantRange(getBitWidth(), /*isFullSet=*/true);
535537
536538 APInt Spread_X = getSetSize(), Spread_Y = Other.getSetSize();
537539 APInt NewLower = getLower() + Other.getLower();
238238
239239 TEST_F(ConstantRangeTest, Add) {
240240 EXPECT_TRUE(Full.add(APInt(16, 4)).isFullSet());
241 EXPECT_EQ(Full.add(Full), Full);
241242 EXPECT_EQ(Full.add(Empty), Empty);
242243 EXPECT_EQ(Full.add(One), Full);
243244 EXPECT_EQ(Full.add(Some), Full);