diff options
author | Devang Patel <dpatel@apple.com> | 2009-10-27 22:16:29 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-10-27 22:16:29 +0000 |
commit | 50b6e33584f4e4cf75c7795b1f1a90731861c825 (patch) | |
tree | 1ae76dc6ddfc8b31bfd97e7f273756780cb7cdb4 /unittests/Transforms/Utils | |
parent | eef55dc3fdebf915128e5d3848f372c7db6c38e8 (diff) | |
download | external_llvm-50b6e33584f4e4cf75c7795b1f1a90731861c825.zip external_llvm-50b6e33584f4e4cf75c7795b1f1a90731861c825.tar.gz external_llvm-50b6e33584f4e4cf75c7795b1f1a90731861c825.tar.bz2 |
Factor out redundancy from clone() implementations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Transforms/Utils')
-rw-r--r-- | unittests/Transforms/Utils/Cloning.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp index 3aa796c..17047e7 100644 --- a/unittests/Transforms/Utils/Cloning.cpp +++ b/unittests/Transforms/Utils/Cloning.cpp @@ -22,45 +22,45 @@ TEST(CloneInstruction, OverflowBits) { BinaryOperator *Sub = BinaryOperator::Create(Instruction::Sub, V, V); BinaryOperator *Mul = BinaryOperator::Create(Instruction::Mul, V, V); - EXPECT_FALSE(Add->clone()->hasNoUnsignedWrap()); - EXPECT_FALSE(Add->clone()->hasNoSignedWrap()); - EXPECT_FALSE(Sub->clone()->hasNoUnsignedWrap()); - EXPECT_FALSE(Sub->clone()->hasNoSignedWrap()); - EXPECT_FALSE(Mul->clone()->hasNoUnsignedWrap()); - EXPECT_FALSE(Mul->clone()->hasNoSignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Add->clone())->hasNoUnsignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Add->clone())->hasNoSignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Sub->clone())->hasNoUnsignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Sub->clone())->hasNoSignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Mul->clone())->hasNoUnsignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Mul->clone())->hasNoSignedWrap()); Add->setHasNoUnsignedWrap(); Sub->setHasNoUnsignedWrap(); Mul->setHasNoUnsignedWrap(); - EXPECT_TRUE(Add->clone()->hasNoUnsignedWrap()); - EXPECT_FALSE(Add->clone()->hasNoSignedWrap()); - EXPECT_TRUE(Sub->clone()->hasNoUnsignedWrap()); - EXPECT_FALSE(Sub->clone()->hasNoSignedWrap()); - EXPECT_TRUE(Mul->clone()->hasNoUnsignedWrap()); - EXPECT_FALSE(Mul->clone()->hasNoSignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Add->clone())->hasNoUnsignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Add->clone())->hasNoSignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Sub->clone())->hasNoUnsignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Sub->clone())->hasNoSignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Mul->clone())->hasNoUnsignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Mul->clone())->hasNoSignedWrap()); Add->setHasNoSignedWrap(); Sub->setHasNoSignedWrap(); Mul->setHasNoSignedWrap(); - EXPECT_TRUE(Add->clone()->hasNoUnsignedWrap()); - EXPECT_TRUE(Add->clone()->hasNoSignedWrap()); - EXPECT_TRUE(Sub->clone()->hasNoUnsignedWrap()); - EXPECT_TRUE(Sub->clone()->hasNoSignedWrap()); - EXPECT_TRUE(Mul->clone()->hasNoUnsignedWrap()); - EXPECT_TRUE(Mul->clone()->hasNoSignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Add->clone())->hasNoUnsignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Add->clone())->hasNoSignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Sub->clone())->hasNoUnsignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Sub->clone())->hasNoSignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Mul->clone())->hasNoUnsignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Mul->clone())->hasNoSignedWrap()); Add->setHasNoUnsignedWrap(false); Sub->setHasNoUnsignedWrap(false); Mul->setHasNoUnsignedWrap(false); - EXPECT_FALSE(Add->clone()->hasNoUnsignedWrap()); - EXPECT_TRUE(Add->clone()->hasNoSignedWrap()); - EXPECT_FALSE(Sub->clone()->hasNoUnsignedWrap()); - EXPECT_TRUE(Sub->clone()->hasNoSignedWrap()); - EXPECT_FALSE(Mul->clone()->hasNoUnsignedWrap()); - EXPECT_TRUE(Mul->clone()->hasNoSignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Add->clone())->hasNoUnsignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Add->clone())->hasNoSignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Sub->clone())->hasNoUnsignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Sub->clone())->hasNoSignedWrap()); + EXPECT_FALSE(cast<BinaryOperator>(Mul->clone())->hasNoUnsignedWrap()); + EXPECT_TRUE(cast<BinaryOperator>(Mul->clone())->hasNoSignedWrap()); } TEST(CloneInstruction, Inbounds) { @@ -70,10 +70,10 @@ TEST(CloneInstruction, Inbounds) { std::vector<Value *> ops; ops.push_back(Z); GetElementPtrInst *GEP = GetElementPtrInst::Create(V, ops.begin(), ops.end()); - EXPECT_FALSE(GEP->clone()->isInBounds()); + EXPECT_FALSE(cast<GetElementPtrInst>(GEP->clone())->isInBounds()); GEP->setIsInBounds(); - EXPECT_TRUE(GEP->clone()->isInBounds()); + EXPECT_TRUE(cast<GetElementPtrInst>(GEP->clone())->isInBounds()); } TEST(CloneInstruction, Exact) { @@ -81,8 +81,8 @@ TEST(CloneInstruction, Exact) { Value *V = new Argument(Type::getInt32Ty(context)); BinaryOperator *SDiv = BinaryOperator::Create(Instruction::SDiv, V, V); - EXPECT_FALSE(SDiv->clone()->isExact()); + EXPECT_FALSE(cast<BinaryOperator>(SDiv->clone())->isExact()); SDiv->setIsExact(true); - EXPECT_TRUE(SDiv->clone()->isExact()); + EXPECT_TRUE(cast<BinaryOperator>(SDiv->clone())->isExact()); } |