summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorIgor Laevsky <igmyrj@gmail.com>2017-12-13 11:47:35 +0000
committerIgor Laevsky <igmyrj@gmail.com>2017-12-13 11:47:35 +0000
commit95edead4fe428299acc43c01526c81800aeaad4a (patch)
tree64da681433c28fc7ee679c79438d7003c575a2eb /unittests
parent033683a63fc1e74deace77962a3d79fc8040e5dc (diff)
[FuzzMutate] Avoid zero sized aggregates
Differential Revision: https://reviews.llvm.org/D41110 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/FuzzMutate/OperationsTest.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/unittests/FuzzMutate/OperationsTest.cpp b/unittests/FuzzMutate/OperationsTest.cpp
index be1789e9475..0fc6b2c2aeb 100644
--- a/unittests/FuzzMutate/OperationsTest.cpp
+++ b/unittests/FuzzMutate/OperationsTest.cpp
@@ -336,6 +336,7 @@ TEST(OperationsTest, ExtractAndInsertValue) {
Type *StructTy = StructType::create(Ctx, {Int8PtrTy, Int32Ty});
Type *OpaqueTy = StructType::create(Ctx, "OpaqueStruct");
+ Type *ZeroSizedArrayTy = ArrayType::get(Int64Ty, 0);
Type *ArrayTy = ArrayType::get(Int64Ty, 4);
Type *VectorTy = VectorType::get(Int32Ty, 2);
@@ -346,17 +347,22 @@ TEST(OperationsTest, ExtractAndInsertValue) {
Constant *SVal = UndefValue::get(StructTy);
Constant *OVal = UndefValue::get(OpaqueTy);
Constant *AVal = UndefValue::get(ArrayTy);
+ Constant *ZAVal = UndefValue::get(ZeroSizedArrayTy);
Constant *VVal = UndefValue::get(VectorTy);
EXPECT_TRUE(EVOp.SourcePreds[0].matches({}, SVal));
- EXPECT_TRUE(EVOp.SourcePreds[0].matches({}, OVal));
+ EXPECT_FALSE(EVOp.SourcePreds[0].matches({}, OVal));
EXPECT_TRUE(EVOp.SourcePreds[0].matches({}, AVal));
EXPECT_FALSE(EVOp.SourcePreds[0].matches({}, VVal));
EXPECT_TRUE(IVOp.SourcePreds[0].matches({}, SVal));
- EXPECT_TRUE(IVOp.SourcePreds[0].matches({}, OVal));
+ EXPECT_FALSE(IVOp.SourcePreds[0].matches({}, OVal));
EXPECT_TRUE(IVOp.SourcePreds[0].matches({}, AVal));
EXPECT_FALSE(IVOp.SourcePreds[0].matches({}, VVal));
+ // Don't consider zero sized arrays as viable sources
+ EXPECT_FALSE(EVOp.SourcePreds[0].matches({}, ZAVal));
+ EXPECT_FALSE(IVOp.SourcePreds[0].matches({}, ZAVal));
+
// Make sure we're range checking appropriately.
EXPECT_TRUE(
EVOp.SourcePreds[1].matches({SVal}, ConstantInt::get(Int32Ty, 0)));