2010-03-16 09:55:46 +00:00
|
|
|
//===- llvm/unittest/VMCore/InstructionsTest.cpp - Instructions unit tests ===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Instructions.h"
|
2010-03-16 11:24:53 +00:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2010-03-16 09:55:46 +00:00
|
|
|
#include "llvm/LLVMContext.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace {
|
|
|
|
|
2010-03-16 10:59:48 +00:00
|
|
|
TEST(InstructionsTest, ReturnInst) {
|
2010-03-16 09:55:46 +00:00
|
|
|
LLVMContext &C(getGlobalContext());
|
|
|
|
|
2010-03-16 10:59:48 +00:00
|
|
|
// test for PR6589
|
2010-03-16 09:55:46 +00:00
|
|
|
const ReturnInst* r0 = ReturnInst::Create(C);
|
2010-03-16 10:59:48 +00:00
|
|
|
EXPECT_EQ(r0->op_begin(), r0->op_end());
|
2010-03-16 11:24:53 +00:00
|
|
|
|
|
|
|
const IntegerType* Int1 = IntegerType::get(C, 1);
|
|
|
|
Constant* One = ConstantInt::get(Int1, 1, true);
|
|
|
|
const ReturnInst* r1 = ReturnInst::Create(C, One);
|
|
|
|
User::const_op_iterator b(r1->op_begin());
|
|
|
|
EXPECT_NE(b, r1->op_end());
|
|
|
|
EXPECT_EQ(*b, One);
|
|
|
|
EXPECT_EQ(r1->getOperand(0), One);
|
|
|
|
++b;
|
|
|
|
EXPECT_EQ(b, r1->op_end());
|
2010-03-16 12:32:03 +00:00
|
|
|
|
|
|
|
// clean up
|
|
|
|
delete r0;
|
|
|
|
delete r1;
|
2010-03-16 09:55:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end anonymous namespace
|
|
|
|
} // end namespace llvm
|