aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2009-07-13 04:17:23 +0000
committerNick Lewycky <nicholas@mxc.ca>2009-07-13 04:17:23 +0000
commit5c94ac933728f491da94f1467d4cb1513f4931fc (patch)
treeac55837ffd97afa396f19f7ac992b70e0e0167bd
parent15b3932454f2777376ac500eae3999139a2c1f2e (diff)
downloadexternal_llvm-5c94ac933728f491da94f1467d4cb1513f4931fc.zip
external_llvm-5c94ac933728f491da94f1467d4cb1513f4931fc.tar.gz
external_llvm-5c94ac933728f491da94f1467d4cb1513f4931fc.tar.bz2
'i8 full-range' sign extended to i16 should equal [-128, 128) not [-128, 127).
Found by Daniel Dunbar and KLEE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75448 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Support/ConstantRange.cpp2
-rw-r--r--unittests/Support/ConstantRangeTest.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp
index d7a57bb..ca25491 100644
--- a/lib/Support/ConstantRange.cpp
+++ b/lib/Support/ConstantRange.cpp
@@ -505,7 +505,7 @@ ConstantRange ConstantRange::signExtend(uint32_t DstTySize) const {
assert(SrcTySize < DstTySize && "Not a value extension");
if (isFullSet()) {
return ConstantRange(APInt::getHighBitsSet(DstTySize,DstTySize-SrcTySize+1),
- APInt::getLowBitsSet(DstTySize, SrcTySize-1));
+ APInt::getLowBitsSet(DstTySize, SrcTySize-1) + 1);
}
APInt L = Lower; L.sext(DstTySize);
diff --git a/unittests/Support/ConstantRangeTest.cpp b/unittests/Support/ConstantRangeTest.cpp
index 2b073d8..f929425 100644
--- a/unittests/Support/ConstantRangeTest.cpp
+++ b/unittests/Support/ConstantRangeTest.cpp
@@ -175,7 +175,7 @@ TEST_F(ConstantRangeTest, SExt) {
ConstantRange SSome = Some.signExtend(20);
ConstantRange SWrap = Wrap.signExtend(20);
EXPECT_EQ(SFull, ConstantRange(APInt(20, INT16_MIN, true),
- APInt(20, INT16_MAX, true)));
+ APInt(20, INT16_MAX + 1, true)));
EXPECT_TRUE(SEmpty.isEmptySet());
EXPECT_EQ(SOne, ConstantRange(APInt(One.getLower()).sext(20),
APInt(One.getUpper()).sext(20)));