blob: 2d98cad27fb8b1ee60b459fef4d78e2f4884c41e [file] [log] [blame]
Gabor Greif15580382010-03-16 09:55:46 +00001//===- 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 Greif86ca5492010-03-16 11:24:53 +000011#include "llvm/DerivedTypes.h"
Gabor Greif15580382010-03-16 09:55:46 +000012#include "llvm/LLVMContext.h"
13#include "gtest/gtest.h"
14
15namespace llvm {
16namespace {
17
Gabor Greif35a9b8b2010-03-16 10:59:48 +000018TEST(InstructionsTest, ReturnInst) {
Gabor Greif15580382010-03-16 09:55:46 +000019 LLVMContext &C(getGlobalContext());
20
Gabor Greif35a9b8b2010-03-16 10:59:48 +000021 // test for PR6589
Gabor Greif15580382010-03-16 09:55:46 +000022 const ReturnInst* r0 = ReturnInst::Create(C);
Gabor Greif35a9b8b2010-03-16 10:59:48 +000023 EXPECT_EQ(r0->op_begin(), r0->op_end());
Gabor Greif86ca5492010-03-16 11:24:53 +000024
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 Greif421dd122010-03-16 12:32:03 +000034
35 // clean up
36 delete r0;
37 delete r1;
Gabor Greif15580382010-03-16 09:55:46 +000038}
39
40} // end anonymous namespace
41} // end namespace llvm