aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/ConstantRangeTest.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-11-07 21:21:41 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-11-07 21:22:45 +0100
commitcf71a5ea8f95be423ebd381d21d0f9a05edc5018 (patch)
tree5026d23f31b8465d0bf1971b80bfb485c34d84cb /llvm/unittests/IR/ConstantRangeTest.cpp
parentd09a21a0b378675c7f69628ce7a9cd0d54dec1da (diff)
downloadllvm-cf71a5ea8f95be423ebd381d21d0f9a05edc5018.zip
llvm-cf71a5ea8f95be423ebd381d21d0f9a05edc5018.tar.gz
llvm-cf71a5ea8f95be423ebd381d21d0f9a05edc5018.tar.bz2
[ConstantRange] Support zero size in isSizeLargerThan()
From an API perspective, it does not make a lot of sense that 0 is not a valid argument to this function. Add the exact check needed to support it.
Diffstat (limited to 'llvm/unittests/IR/ConstantRangeTest.cpp')
-rw-r--r--llvm/unittests/IR/ConstantRangeTest.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index ac5c445..2de1ae7 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2594,4 +2594,15 @@ TEST_F(ConstantRangeTest, getEquivalentPredWithFlippedSignedness) {
}
}
+TEST_F(ConstantRangeTest, isSizeLargerThan) {
+ EXPECT_FALSE(Empty.isSizeLargerThan(0));
+
+ EXPECT_TRUE(Full.isSizeLargerThan(0));
+ EXPECT_TRUE(Full.isSizeLargerThan(65535));
+ EXPECT_FALSE(Full.isSizeLargerThan(65536));
+
+ EXPECT_TRUE(One.isSizeLargerThan(0));
+ EXPECT_FALSE(One.isSizeLargerThan(1));
+}
+
} // anonymous namespace