Gabor Greif | 1558038 | 2010-03-16 09:55:46 +0000 | [diff] [blame] | 1 | //===- llvm/unittest/VMCore/InstructionsTest.cpp - Instructions unit tests ===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/Instructions.h" |
Gabor Greif | 86ca549 | 2010-03-16 11:24:53 +0000 | [diff] [blame] | 11 | #include "llvm/DerivedTypes.h" |
Gabor Greif | 1558038 | 2010-03-16 09:55:46 +0000 | [diff] [blame] | 12 | #include "llvm/LLVMContext.h" |
| 13 | #include "gtest/gtest.h" |
| 14 | |
| 15 | namespace llvm { |
| 16 | namespace { |
| 17 | |
Gabor Greif | 35a9b8b | 2010-03-16 10:59:48 +0000 | [diff] [blame] | 18 | TEST(InstructionsTest, ReturnInst) { |
Gabor Greif | 1558038 | 2010-03-16 09:55:46 +0000 | [diff] [blame] | 19 | LLVMContext &C(getGlobalContext()); |
| 20 | |
Gabor Greif | 35a9b8b | 2010-03-16 10:59:48 +0000 | [diff] [blame] | 21 | // test for PR6589 |
Gabor Greif | 1558038 | 2010-03-16 09:55:46 +0000 | [diff] [blame] | 22 | const ReturnInst* r0 = ReturnInst::Create(C); |
Gabor Greif | 35a9b8b | 2010-03-16 10:59:48 +0000 | [diff] [blame] | 23 | EXPECT_EQ(r0->op_begin(), r0->op_end()); |
Gabor Greif | 86ca549 | 2010-03-16 11:24:53 +0000 | [diff] [blame] | 24 | |
| 25 | const IntegerType* Int1 = IntegerType::get(C, 1); |
| 26 | Constant* One = ConstantInt::get(Int1, 1, true); |
| 27 | const ReturnInst* r1 = ReturnInst::Create(C, One); |
| 28 | User::const_op_iterator b(r1->op_begin()); |
| 29 | EXPECT_NE(b, r1->op_end()); |
| 30 | EXPECT_EQ(*b, One); |
| 31 | EXPECT_EQ(r1->getOperand(0), One); |
| 32 | ++b; |
| 33 | EXPECT_EQ(b, r1->op_end()); |
Gabor Greif | 421dd12 | 2010-03-16 12:32:03 +0000 | [diff] [blame^] | 34 | |
| 35 | // clean up |
| 36 | delete r0; |
| 37 | delete r1; |
Gabor Greif | 1558038 | 2010-03-16 09:55:46 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | } // end anonymous namespace |
| 41 | } // end namespace llvm |