Bug Summary

File:unittests/IR/ConstantsTest.cpp
Location:line 289, column 3
Description:Function call argument is an uninitialized value

Annotated Source Code

1//===- llvm/unittest/IR/ConstantsTest.cpp - Constants 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/AsmParser/Parser.h"
11#include "llvm/IR/Constants.h"
12#include "llvm/IR/DerivedTypes.h"
13#include "llvm/IR/InstrTypes.h"
14#include "llvm/IR/Instruction.h"
15#include "llvm/IR/LLVMContext.h"
16#include "llvm/IR/Module.h"
17#include "llvm/Support/SourceMgr.h"
18#include "gtest/gtest.h"
19
20namespace llvm {
21namespace {
22
23TEST(ConstantsTest, Integer_i1)class ConstantsTest_Integer_i1_Test : public ::testing::Test {
public: ConstantsTest_Integer_i1_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ConstantsTest_Integer_i1_Test(ConstantsTest_Integer_i1_Test
const &); void operator=(ConstantsTest_Integer_i1_Test const
&);};::testing::TestInfo* const ConstantsTest_Integer_i1_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "Integer_i1", __null, __null, (::testing::internal
::GetTestTypeId()), ::testing::Test::SetUpTestCase, ::testing
::Test::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< ConstantsTest_Integer_i1_Test>);void ConstantsTest_Integer_i1_Test
::TestBody()
{
24 IntegerType* Int1 = IntegerType::get(getGlobalContext(), 1);
25 Constant* One = ConstantInt::get(Int1, 1, true);
26 Constant* Zero = ConstantInt::get(Int1, 0);
27 Constant* NegOne = ConstantInt::get(Int1, static_cast<uint64_t>(-1), true);
28 EXPECT_EQ(NegOne, ConstantInt::getSigned(Int1, -1))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(NegOne)) == 1)>::Compare("NegOne"
, "ConstantInt::getSigned(Int1, -1)", NegOne, ConstantInt::getSigned
(Int1, -1)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 28, gtest_ar.failure_message()) = ::testing::Message()
;
29 Constant* Undef = UndefValue::get(Int1);
30
31 // Input: @b = constant i1 add(i1 1 , i1 1)
32 // Output: @b = constant i1 false
33 EXPECT_EQ(Zero, ConstantExpr::getAdd(One, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getAdd(One, One)", Zero, ConstantExpr::getAdd
(One, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 33, gtest_ar.failure_message()) = ::testing::Message()
;
34
35 // @c = constant i1 add(i1 -1, i1 1)
36 // @c = constant i1 false
37 EXPECT_EQ(Zero, ConstantExpr::getAdd(NegOne, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getAdd(NegOne, One)", Zero, ConstantExpr::getAdd
(NegOne, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 37, gtest_ar.failure_message()) = ::testing::Message()
;
38
39 // @d = constant i1 add(i1 -1, i1 -1)
40 // @d = constant i1 false
41 EXPECT_EQ(Zero, ConstantExpr::getAdd(NegOne, NegOne))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getAdd(NegOne, NegOne)", Zero, ConstantExpr::
getAdd(NegOne, NegOne)))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 41, gtest_ar.failure_message()) = ::testing::Message()
;
42
43 // @e = constant i1 sub(i1 -1, i1 1)
44 // @e = constant i1 false
45 EXPECT_EQ(Zero, ConstantExpr::getSub(NegOne, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getSub(NegOne, One)", Zero, ConstantExpr::getSub
(NegOne, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 45, gtest_ar.failure_message()) = ::testing::Message()
;
46
47 // @f = constant i1 sub(i1 1 , i1 -1)
48 // @f = constant i1 false
49 EXPECT_EQ(Zero, ConstantExpr::getSub(One, NegOne))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getSub(One, NegOne)", Zero, ConstantExpr::getSub
(One, NegOne)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 49, gtest_ar.failure_message()) = ::testing::Message()
;
50
51 // @g = constant i1 sub(i1 1 , i1 1)
52 // @g = constant i1 false
53 EXPECT_EQ(Zero, ConstantExpr::getSub(One, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getSub(One, One)", Zero, ConstantExpr::getSub
(One, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 53, gtest_ar.failure_message()) = ::testing::Message()
;
54
55 // @h = constant i1 shl(i1 1 , i1 1) ; undefined
56 // @h = constant i1 undef
57 EXPECT_EQ(Undef, ConstantExpr::getShl(One, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Undef)) == 1)>::Compare("Undef"
, "ConstantExpr::getShl(One, One)", Undef, ConstantExpr::getShl
(One, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 57, gtest_ar.failure_message()) = ::testing::Message()
;
58
59 // @i = constant i1 shl(i1 1 , i1 0)
60 // @i = constant i1 true
61 EXPECT_EQ(One, ConstantExpr::getShl(One, Zero))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(One)) == 1)>::Compare("One"
, "ConstantExpr::getShl(One, Zero)", One, ConstantExpr::getShl
(One, Zero)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 61, gtest_ar.failure_message()) = ::testing::Message()
;
62
63 // @j = constant i1 lshr(i1 1, i1 1) ; undefined
64 // @j = constant i1 undef
65 EXPECT_EQ(Undef, ConstantExpr::getLShr(One, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Undef)) == 1)>::Compare("Undef"
, "ConstantExpr::getLShr(One, One)", Undef, ConstantExpr::getLShr
(One, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 65, gtest_ar.failure_message()) = ::testing::Message()
;
66
67 // @m = constant i1 ashr(i1 1, i1 1) ; undefined
68 // @m = constant i1 undef
69 EXPECT_EQ(Undef, ConstantExpr::getAShr(One, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Undef)) == 1)>::Compare("Undef"
, "ConstantExpr::getAShr(One, One)", Undef, ConstantExpr::getAShr
(One, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 69, gtest_ar.failure_message()) = ::testing::Message()
;
70
71 // @n = constant i1 mul(i1 -1, i1 1)
72 // @n = constant i1 true
73 EXPECT_EQ(One, ConstantExpr::getMul(NegOne, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(One)) == 1)>::Compare("One"
, "ConstantExpr::getMul(NegOne, One)", One, ConstantExpr::getMul
(NegOne, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 73, gtest_ar.failure_message()) = ::testing::Message()
;
74
75 // @o = constant i1 sdiv(i1 -1, i1 1) ; overflow
76 // @o = constant i1 true
77 EXPECT_EQ(One, ConstantExpr::getSDiv(NegOne, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(One)) == 1)>::Compare("One"
, "ConstantExpr::getSDiv(NegOne, One)", One, ConstantExpr::getSDiv
(NegOne, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 77, gtest_ar.failure_message()) = ::testing::Message()
;
78
79 // @p = constant i1 sdiv(i1 1 , i1 -1); overflow
80 // @p = constant i1 true
81 EXPECT_EQ(One, ConstantExpr::getSDiv(One, NegOne))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(One)) == 1)>::Compare("One"
, "ConstantExpr::getSDiv(One, NegOne)", One, ConstantExpr::getSDiv
(One, NegOne)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 81, gtest_ar.failure_message()) = ::testing::Message()
;
82
83 // @q = constant i1 udiv(i1 -1, i1 1)
84 // @q = constant i1 true
85 EXPECT_EQ(One, ConstantExpr::getUDiv(NegOne, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(One)) == 1)>::Compare("One"
, "ConstantExpr::getUDiv(NegOne, One)", One, ConstantExpr::getUDiv
(NegOne, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 85, gtest_ar.failure_message()) = ::testing::Message()
;
86
87 // @r = constant i1 udiv(i1 1, i1 -1)
88 // @r = constant i1 true
89 EXPECT_EQ(One, ConstantExpr::getUDiv(One, NegOne))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(One)) == 1)>::Compare("One"
, "ConstantExpr::getUDiv(One, NegOne)", One, ConstantExpr::getUDiv
(One, NegOne)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 89, gtest_ar.failure_message()) = ::testing::Message()
;
90
91 // @s = constant i1 srem(i1 -1, i1 1) ; overflow
92 // @s = constant i1 false
93 EXPECT_EQ(Zero, ConstantExpr::getSRem(NegOne, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getSRem(NegOne, One)", Zero, ConstantExpr::getSRem
(NegOne, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 93, gtest_ar.failure_message()) = ::testing::Message()
;
94
95 // @t = constant i1 urem(i1 -1, i1 1)
96 // @t = constant i1 false
97 EXPECT_EQ(Zero, ConstantExpr::getURem(NegOne, One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getURem(NegOne, One)", Zero, ConstantExpr::getURem
(NegOne, One)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 97, gtest_ar.failure_message()) = ::testing::Message()
;
98
99 // @u = constant i1 srem(i1 1, i1 -1) ; overflow
100 // @u = constant i1 false
101 EXPECT_EQ(Zero, ConstantExpr::getSRem(One, NegOne))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Zero)) == 1)>::Compare("Zero"
, "ConstantExpr::getSRem(One, NegOne)", Zero, ConstantExpr::getSRem
(One, NegOne)))) ; else ::testing::internal::AssertHelper(::testing
::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 101, gtest_ar.failure_message()) = ::testing::Message()
;
102}
103
104TEST(ConstantsTest, IntSigns)class ConstantsTest_IntSigns_Test : public ::testing::Test { public
: ConstantsTest_IntSigns_Test() {} private: virtual void TestBody
(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ConstantsTest_IntSigns_Test(ConstantsTest_IntSigns_Test
const &); void operator=(ConstantsTest_IntSigns_Test const
&);};::testing::TestInfo* const ConstantsTest_IntSigns_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "IntSigns", __null, __null, (::testing::internal
::GetTestTypeId()), ::testing::Test::SetUpTestCase, ::testing
::Test::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< ConstantsTest_IntSigns_Test>);void ConstantsTest_IntSigns_Test
::TestBody()
{
105 IntegerType* Int8Ty = Type::getInt8Ty(getGlobalContext());
106 EXPECT_EQ(100, ConstantInt::get(Int8Ty, 100, false)->getSExtValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(100)) == 1)>::Compare("100"
, "ConstantInt::get(Int8Ty, 100, false)->getSExtValue()", 100
, ConstantInt::get(Int8Ty, 100, false)->getSExtValue()))) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 106, gtest_ar.failure_message()) = ::testing::Message()
;
107 EXPECT_EQ(100, ConstantInt::get(Int8Ty, 100, true)->getSExtValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(100)) == 1)>::Compare("100"
, "ConstantInt::get(Int8Ty, 100, true)->getSExtValue()", 100
, ConstantInt::get(Int8Ty, 100, true)->getSExtValue()))) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 107, gtest_ar.failure_message()) = ::testing::Message()
;
108 EXPECT_EQ(100, ConstantInt::getSigned(Int8Ty, 100)->getSExtValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(100)) == 1)>::Compare("100"
, "ConstantInt::getSigned(Int8Ty, 100)->getSExtValue()", 100
, ConstantInt::getSigned(Int8Ty, 100)->getSExtValue()))) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 108, gtest_ar.failure_message()) = ::testing::Message()
;
109 EXPECT_EQ(-50, ConstantInt::get(Int8Ty, 206)->getSExtValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(-50)) == 1)>::Compare("-50"
, "ConstantInt::get(Int8Ty, 206)->getSExtValue()", -50, ConstantInt
::get(Int8Ty, 206)->getSExtValue()))) ; else ::testing::internal
::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 109, gtest_ar.failure_message()) = ::testing::Message()
;
110 EXPECT_EQ(-50, ConstantInt::getSigned(Int8Ty, -50)->getSExtValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(-50)) == 1)>::Compare("-50"
, "ConstantInt::getSigned(Int8Ty, -50)->getSExtValue()", -
50, ConstantInt::getSigned(Int8Ty, -50)->getSExtValue())))
; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 110, gtest_ar.failure_message()) = ::testing::Message()
;
111 EXPECT_EQ(206U, ConstantInt::getSigned(Int8Ty, -50)->getZExtValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(206U)) == 1)>::Compare("206U"
, "ConstantInt::getSigned(Int8Ty, -50)->getZExtValue()", 206U
, ConstantInt::getSigned(Int8Ty, -50)->getZExtValue()))) ;
else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 111, gtest_ar.failure_message()) = ::testing::Message()
;
112
113 // Overflow is handled by truncation.
114 EXPECT_EQ(0x3b, ConstantInt::get(Int8Ty, 0x13b)->getSExtValue())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(0x3b)) == 1)>::Compare("0x3b"
, "ConstantInt::get(Int8Ty, 0x13b)->getSExtValue()", 0x3b,
ConstantInt::get(Int8Ty, 0x13b)->getSExtValue()))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 114, gtest_ar.failure_message()) = ::testing::Message()
;
115}
116
117TEST(ConstantsTest, FP128Test)class ConstantsTest_FP128Test_Test : public ::testing::Test {
public: ConstantsTest_FP128Test_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ConstantsTest_FP128Test_Test(ConstantsTest_FP128Test_Test
const &); void operator=(ConstantsTest_FP128Test_Test const
&);};::testing::TestInfo* const ConstantsTest_FP128Test_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "FP128Test", __null, __null, (::testing::internal
::GetTestTypeId()), ::testing::Test::SetUpTestCase, ::testing
::Test::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< ConstantsTest_FP128Test_Test>);void ConstantsTest_FP128Test_Test
::TestBody()
{
118 Type *FP128Ty = Type::getFP128Ty(getGlobalContext());
119
120 IntegerType *Int128Ty = Type::getIntNTy(getGlobalContext(), 128);
121 Constant *Zero128 = Constant::getNullValue(Int128Ty);
122 Constant *X = ConstantExpr::getUIToFP(Zero128, FP128Ty);
123 EXPECT_TRUE(isa<ConstantFP>(X))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(isa<ConstantFP>
(X))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 123, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "isa<ConstantFP>(X)", "false", "true").c_str()) = ::testing
::Message()
;
124}
125
126TEST(ConstantsTest, PointerCast)class ConstantsTest_PointerCast_Test : public ::testing::Test
{ public: ConstantsTest_PointerCast_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); ConstantsTest_PointerCast_Test(ConstantsTest_PointerCast_Test
const &); void operator=(ConstantsTest_PointerCast_Test const
&);};::testing::TestInfo* const ConstantsTest_PointerCast_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "PointerCast", __null, __null, (::testing::
internal::GetTestTypeId()), ::testing::Test::SetUpTestCase, ::
testing::Test::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< ConstantsTest_PointerCast_Test>);void ConstantsTest_PointerCast_Test
::TestBody()
{
127 LLVMContext &C(getGlobalContext());
128 Type *Int8PtrTy = Type::getInt8PtrTy(C);
129 Type *Int32PtrTy = Type::getInt32PtrTy(C);
130 Type *Int64Ty = Type::getInt64Ty(C);
131 VectorType *Int8PtrVecTy = VectorType::get(Int8PtrTy, 4);
132 VectorType *Int32PtrVecTy = VectorType::get(Int32PtrTy, 4);
133 VectorType *Int64VecTy = VectorType::get(Int64Ty, 4);
134
135 // ptrtoint i8* to i64
136 EXPECT_EQ(Constant::getNullValue(Int64Ty),switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int64Ty
))) == 1)>::Compare("Constant::getNullValue(Int64Ty)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrTy), Int64Ty)"
, Constant::getNullValue(Int64Ty), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrTy), Int64Ty)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 138, gtest_ar.failure_message()) = ::testing::Message()
137 ConstantExpr::getPointerCast(switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int64Ty
))) == 1)>::Compare("Constant::getNullValue(Int64Ty)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrTy), Int64Ty)"
, Constant::getNullValue(Int64Ty), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrTy), Int64Ty)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 138, gtest_ar.failure_message()) = ::testing::Message()
138 Constant::getNullValue(Int8PtrTy), Int64Ty))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int64Ty
))) == 1)>::Compare("Constant::getNullValue(Int64Ty)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrTy), Int64Ty)"
, Constant::getNullValue(Int64Ty), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrTy), Int64Ty)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 138, gtest_ar.failure_message()) = ::testing::Message()
;
139
140 // bitcast i8* to i32*
141 EXPECT_EQ(Constant::getNullValue(Int32PtrTy),switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int32PtrTy
))) == 1)>::Compare("Constant::getNullValue(Int32PtrTy)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrTy), Int32PtrTy)"
, Constant::getNullValue(Int32PtrTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrTy), Int32PtrTy)))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 143, gtest_ar.failure_message()) = ::testing::Message()
142 ConstantExpr::getPointerCast(switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int32PtrTy
))) == 1)>::Compare("Constant::getNullValue(Int32PtrTy)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrTy), Int32PtrTy)"
, Constant::getNullValue(Int32PtrTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrTy), Int32PtrTy)))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 143, gtest_ar.failure_message()) = ::testing::Message()
143 Constant::getNullValue(Int8PtrTy), Int32PtrTy))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int32PtrTy
))) == 1)>::Compare("Constant::getNullValue(Int32PtrTy)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrTy), Int32PtrTy)"
, Constant::getNullValue(Int32PtrTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrTy), Int32PtrTy)))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 143, gtest_ar.failure_message()) = ::testing::Message()
;
144
145 // ptrtoint <4 x i8*> to <4 x i64>
146 EXPECT_EQ(Constant::getNullValue(Int64VecTy),switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int64VecTy
))) == 1)>::Compare("Constant::getNullValue(Int64VecTy)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrVecTy), Int64VecTy)"
, Constant::getNullValue(Int64VecTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrVecTy), Int64VecTy)))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 148, gtest_ar.failure_message()) = ::testing::Message()
147 ConstantExpr::getPointerCast(switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int64VecTy
))) == 1)>::Compare("Constant::getNullValue(Int64VecTy)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrVecTy), Int64VecTy)"
, Constant::getNullValue(Int64VecTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrVecTy), Int64VecTy)))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 148, gtest_ar.failure_message()) = ::testing::Message()
148 Constant::getNullValue(Int8PtrVecTy), Int64VecTy))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int64VecTy
))) == 1)>::Compare("Constant::getNullValue(Int64VecTy)", "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrVecTy), Int64VecTy)"
, Constant::getNullValue(Int64VecTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrVecTy), Int64VecTy)))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 148, gtest_ar.failure_message()) = ::testing::Message()
;
149
150 // bitcast <4 x i8*> to <4 x i32*>
151 EXPECT_EQ(Constant::getNullValue(Int32PtrVecTy),switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int32PtrVecTy
))) == 1)>::Compare("Constant::getNullValue(Int32PtrVecTy)"
, "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy)"
, Constant::getNullValue(Int32PtrVecTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy)))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 153, gtest_ar.failure_message()) = ::testing::Message()
152 ConstantExpr::getPointerCast(switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int32PtrVecTy
))) == 1)>::Compare("Constant::getNullValue(Int32PtrVecTy)"
, "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy)"
, Constant::getNullValue(Int32PtrVecTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy)))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 153, gtest_ar.failure_message()) = ::testing::Message()
153 Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Constant::getNullValue(Int32PtrVecTy
))) == 1)>::Compare("Constant::getNullValue(Int32PtrVecTy)"
, "ConstantExpr::getPointerCast( Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy)"
, Constant::getNullValue(Int32PtrVecTy), ConstantExpr::getPointerCast
( Constant::getNullValue(Int8PtrVecTy), Int32PtrVecTy)))) ; else
::testing::internal::AssertHelper(::testing::TestPartResult::
kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 153, gtest_ar.failure_message()) = ::testing::Message()
;
154}
155
156#define CHECK(x, y) { \
157 std::string __s; \
158 raw_string_ostream __o(__s); \
159 Instruction *__I = cast<ConstantExpr>(x)->getAsInstruction(); \
160 __I->print(__o); \
161 delete __I; \
162 __o.flush(); \
163 EXPECT_EQ(std::string(" <badref> = " y), __s)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(std::string(" <badref> = "
y))) == 1)>::Compare("std::string(\" <badref> = \" y)"
, "__s", std::string(" <badref> = " y), __s))) ; else ::
testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 163, gtest_ar.failure_message()) = ::testing::Message()
; \
164 }
165
166TEST(ConstantsTest, AsInstructionsTest)class ConstantsTest_AsInstructionsTest_Test : public ::testing
::Test { public: ConstantsTest_AsInstructionsTest_Test() {} private
: virtual void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); ConstantsTest_AsInstructionsTest_Test
(ConstantsTest_AsInstructionsTest_Test const &); void operator
=(ConstantsTest_AsInstructionsTest_Test const &);};::testing
::TestInfo* const ConstantsTest_AsInstructionsTest_Test ::test_info_
= ::testing::internal::MakeAndRegisterTestInfo( "ConstantsTest"
, "AsInstructionsTest", __null, __null, (::testing::internal::
GetTestTypeId()), ::testing::Test::SetUpTestCase, ::testing::
Test::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< ConstantsTest_AsInstructionsTest_Test>);void ConstantsTest_AsInstructionsTest_Test
::TestBody()
{
167 std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext()));
168
169 Type *Int64Ty = Type::getInt64Ty(getGlobalContext());
170 Type *Int32Ty = Type::getInt32Ty(getGlobalContext());
171 Type *Int16Ty = Type::getInt16Ty(getGlobalContext());
172 Type *Int1Ty = Type::getInt1Ty(getGlobalContext());
173 Type *FloatTy = Type::getFloatTy(getGlobalContext());
174 Type *DoubleTy = Type::getDoubleTy(getGlobalContext());
175
176 Constant *Global = M->getOrInsertGlobal("dummy",
177 PointerType::getUnqual(Int32Ty));
178 Constant *Global2 = M->getOrInsertGlobal("dummy2",
179 PointerType::getUnqual(Int32Ty));
180
181 Constant *P0 = ConstantExpr::getPtrToInt(Global, Int32Ty);
182 Constant *P1 = ConstantExpr::getUIToFP(P0, FloatTy);
183 Constant *P2 = ConstantExpr::getUIToFP(P0, DoubleTy);
184 Constant *P3 = ConstantExpr::getTrunc(P0, Int1Ty);
185 Constant *P4 = ConstantExpr::getPtrToInt(Global2, Int32Ty);
186 Constant *P5 = ConstantExpr::getUIToFP(P4, FloatTy);
187 Constant *P6 = ConstantExpr::getBitCast(P4, VectorType::get(Int16Ty, 2));
188
189 Constant *One = ConstantInt::get(Int32Ty, 1);
190 Constant *Two = ConstantInt::get(Int64Ty, 2);
191 Constant *Big = ConstantInt::get(getGlobalContext(),
192 APInt{256, uint64_t(-1), true});
193 Constant *Elt = ConstantInt::get(Int16Ty, 2015);
194 Constant *Undef16 = UndefValue::get(Int16Ty);
195 Constant *Undef64 = UndefValue::get(Int64Ty);
196 Constant *UndefV16 = UndefValue::get(P6->getType());
197
198 #define P0STR"ptrtoint (i32** @dummy to i32)" "ptrtoint (i32** @dummy to i32)"
199 #define P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)" "uitofp (i32 ptrtoint (i32** @dummy to i32) to float)"
200 #define P2STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to double)" "uitofp (i32 ptrtoint (i32** @dummy to i32) to double)"
201 #define P3STR"ptrtoint (i32** @dummy to i1)" "ptrtoint (i32** @dummy to i1)"
202 #define P4STR"ptrtoint (i32** @dummy2 to i32)" "ptrtoint (i32** @dummy2 to i32)"
203 #define P5STR"uitofp (i32 ptrtoint (i32** @dummy2 to i32) to float)" "uitofp (i32 ptrtoint (i32** @dummy2 to i32) to float)"
204 #define P6STR"bitcast (i32 ptrtoint (i32** @dummy2 to i32) to <2 x i16>)" "bitcast (i32 ptrtoint (i32** @dummy2 to i32) to <2 x i16>)"
205
206 CHECK(ConstantExpr::getNeg(P0), "sub i32 0, " P0STR"ptrtoint (i32** @dummy to i32)");
207 CHECK(ConstantExpr::getFNeg(P1), "fsub float -0.000000e+00, " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)");
208 CHECK(ConstantExpr::getNot(P0), "xor i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", -1");
209 CHECK(ConstantExpr::getAdd(P0, P0), "add i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
210 CHECK(ConstantExpr::getAdd(P0, P0, false, true), "add nsw i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", "
211 P0STR"ptrtoint (i32** @dummy to i32)");
212 CHECK(ConstantExpr::getAdd(P0, P0, true, true), "add nuw nsw i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", "
213 P0STR"ptrtoint (i32** @dummy to i32)");
214 CHECK(ConstantExpr::getFAdd(P1, P1), "fadd float " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)" ", " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)");
215 CHECK(ConstantExpr::getSub(P0, P0), "sub i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
216 CHECK(ConstantExpr::getFSub(P1, P1), "fsub float " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)" ", " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)");
217 CHECK(ConstantExpr::getMul(P0, P0), "mul i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
218 CHECK(ConstantExpr::getFMul(P1, P1), "fmul float " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)" ", " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)");
219 CHECK(ConstantExpr::getUDiv(P0, P0), "udiv i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
220 CHECK(ConstantExpr::getSDiv(P0, P0), "sdiv i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
221 CHECK(ConstantExpr::getFDiv(P1, P1), "fdiv float " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)" ", " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)");
222 CHECK(ConstantExpr::getURem(P0, P0), "urem i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
223 CHECK(ConstantExpr::getSRem(P0, P0), "srem i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
224 CHECK(ConstantExpr::getFRem(P1, P1), "frem float " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)" ", " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)");
225 CHECK(ConstantExpr::getAnd(P0, P0), "and i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
226 CHECK(ConstantExpr::getOr(P0, P0), "or i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
227 CHECK(ConstantExpr::getXor(P0, P0), "xor i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
228 CHECK(ConstantExpr::getShl(P0, P0), "shl i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
229 CHECK(ConstantExpr::getShl(P0, P0, true), "shl nuw i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
230 CHECK(ConstantExpr::getShl(P0, P0, false, true), "shl nsw i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", "
231 P0STR"ptrtoint (i32** @dummy to i32)");
232 CHECK(ConstantExpr::getLShr(P0, P0, false), "lshr i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
233 CHECK(ConstantExpr::getLShr(P0, P0, true), "lshr exact i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
234 CHECK(ConstantExpr::getAShr(P0, P0, false), "ashr i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
235 CHECK(ConstantExpr::getAShr(P0, P0, true), "ashr exact i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
236
237 CHECK(ConstantExpr::getSExt(P0, Int64Ty), "sext i32 " P0STR"ptrtoint (i32** @dummy to i32)" " to i64");
238 CHECK(ConstantExpr::getZExt(P0, Int64Ty), "zext i32 " P0STR"ptrtoint (i32** @dummy to i32)" " to i64");
239 CHECK(ConstantExpr::getFPTrunc(P2, FloatTy), "fptrunc double " P2STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to double)"
240 " to float");
241 CHECK(ConstantExpr::getFPExtend(P1, DoubleTy), "fpext float " P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)"
242 " to double");
243
244 CHECK(ConstantExpr::getExactUDiv(P0, P0), "udiv exact i32 " P0STR"ptrtoint (i32** @dummy to i32)" ", " P0STR"ptrtoint (i32** @dummy to i32)");
245
246 CHECK(ConstantExpr::getSelect(P3, P0, P4), "select i1 " P3STR"ptrtoint (i32** @dummy to i1)" ", i32 " P0STR"ptrtoint (i32** @dummy to i32)"
247 ", i32 " P4STR"ptrtoint (i32** @dummy2 to i32)");
248 CHECK(ConstantExpr::getICmp(CmpInst::ICMP_EQ, P0, P4), "icmp eq i32 " P0STR"ptrtoint (i32** @dummy to i32)"
249 ", " P4STR"ptrtoint (i32** @dummy2 to i32)");
250 CHECK(ConstantExpr::getFCmp(CmpInst::FCMP_ULT, P1, P5), "fcmp ult float "
251 P1STR"uitofp (i32 ptrtoint (i32** @dummy to i32) to float)" ", " P5STR"uitofp (i32 ptrtoint (i32** @dummy2 to i32) to float)");
252
253 std::vector<Constant*> V;
254 V.push_back(One);
255 // FIXME: getGetElementPtr() actually creates an inbounds ConstantGEP,
256 // not a normal one!
257 //CHECK(ConstantExpr::getGetElementPtr(Global, V, false),
258 // "getelementptr i32*, i32** @dummy, i32 1");
259 CHECK(ConstantExpr::getInBoundsGetElementPtr(PointerType::getUnqual(Int32Ty),
260 Global, V),
261 "getelementptr inbounds i32*, i32** @dummy, i32 1");
262
263 CHECK(ConstantExpr::getExtractElement(P6, One), "extractelement <2 x i16> "
264 P6STR"bitcast (i32 ptrtoint (i32** @dummy2 to i32) to <2 x i16>)" ", i32 1");
265
266 EXPECT_EQ(Undef16, ConstantExpr::getExtractElement(P6, Two))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Undef16)) == 1)>::Compare(
"Undef16", "ConstantExpr::getExtractElement(P6, Two)", Undef16
, ConstantExpr::getExtractElement(P6, Two)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 266, gtest_ar.failure_message()) = ::testing::Message()
;
267 EXPECT_EQ(Undef16, ConstantExpr::getExtractElement(P6, Big))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Undef16)) == 1)>::Compare(
"Undef16", "ConstantExpr::getExtractElement(P6, Big)", Undef16
, ConstantExpr::getExtractElement(P6, Big)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 267, gtest_ar.failure_message()) = ::testing::Message()
;
268 EXPECT_EQ(Undef16, ConstantExpr::getExtractElement(P6, Undef64))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Undef16)) == 1)>::Compare(
"Undef16", "ConstantExpr::getExtractElement(P6, Undef64)", Undef16
, ConstantExpr::getExtractElement(P6, Undef64)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 268, gtest_ar.failure_message()) = ::testing::Message()
;
269
270 EXPECT_EQ(Elt, ConstantExpr::getExtractElement(switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Elt)) == 1)>::Compare("Elt"
, "ConstantExpr::getExtractElement( ConstantExpr::getInsertElement(P6, Elt, One), One)"
, Elt, ConstantExpr::getExtractElement( ConstantExpr::getInsertElement
(P6, Elt, One), One)))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 271, gtest_ar.failure_message()) = ::testing::Message()
271 ConstantExpr::getInsertElement(P6, Elt, One), One))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Elt)) == 1)>::Compare("Elt"
, "ConstantExpr::getExtractElement( ConstantExpr::getInsertElement(P6, Elt, One), One)"
, Elt, ConstantExpr::getExtractElement( ConstantExpr::getInsertElement
(P6, Elt, One), One)))) ; else ::testing::internal::AssertHelper
(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 271, gtest_ar.failure_message()) = ::testing::Message()
;
272 EXPECT_EQ(UndefV16, ConstantExpr::getInsertElement(P6, Elt, Two))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(UndefV16)) == 1)>::Compare
("UndefV16", "ConstantExpr::getInsertElement(P6, Elt, Two)", UndefV16
, ConstantExpr::getInsertElement(P6, Elt, Two)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 272, gtest_ar.failure_message()) = ::testing::Message()
;
273 EXPECT_EQ(UndefV16, ConstantExpr::getInsertElement(P6, Elt, Big))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(UndefV16)) == 1)>::Compare
("UndefV16", "ConstantExpr::getInsertElement(P6, Elt, Big)", UndefV16
, ConstantExpr::getInsertElement(P6, Elt, Big)))) ; else ::testing
::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 273, gtest_ar.failure_message()) = ::testing::Message()
;
274 EXPECT_EQ(UndefV16, ConstantExpr::getInsertElement(P6, Elt, Undef64))switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(UndefV16)) == 1)>::Compare
("UndefV16", "ConstantExpr::getInsertElement(P6, Elt, Undef64)"
, UndefV16, ConstantExpr::getInsertElement(P6, Elt, Undef64))
)) ; else ::testing::internal::AssertHelper(::testing::TestPartResult
::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 274, gtest_ar.failure_message()) = ::testing::Message()
;
275}
276
277#ifdef GTEST_HAS_DEATH_TEST1
278#ifndef NDEBUG
279TEST(ConstantsTest, ReplaceWithConstantTest)class ConstantsTest_ReplaceWithConstantTest_Test : public ::testing
::Test { public: ConstantsTest_ReplaceWithConstantTest_Test()
{} private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); ConstantsTest_ReplaceWithConstantTest_Test
(ConstantsTest_ReplaceWithConstantTest_Test const &); void
operator=(ConstantsTest_ReplaceWithConstantTest_Test const &
);};::testing::TestInfo* const ConstantsTest_ReplaceWithConstantTest_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "ReplaceWithConstantTest", __null, __null, (
::testing::internal::GetTestTypeId()), ::testing::Test::SetUpTestCase
, ::testing::Test::TearDownTestCase, new ::testing::internal::
TestFactoryImpl< ConstantsTest_ReplaceWithConstantTest_Test
>);void ConstantsTest_ReplaceWithConstantTest_Test::TestBody
()
{
280 std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext()));
281
282 Type *Int32Ty = Type::getInt32Ty(getGlobalContext());
283 Constant *One = ConstantInt::get(Int32Ty, 1);
284
285 Constant *Global =
286 M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty));
287 Constant *GEP = ConstantExpr::getGetElementPtr(
288 PointerType::getUnqual(Int32Ty), Global, One);
289 EXPECT_DEATH(Global->replaceAllUsesWith(GEP),switch (0) case 0: default: if (::testing::internal::AlwaysTrue
()) { const ::testing::internal::RE& gtest_regex = ("this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!"
); ::testing::internal::DeathTest* gtest_dt; if (!::testing::
internal::DeathTest::Create("Global->replaceAllUsesWith(GEP)"
, &gtest_regex, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 290, &gtest_dt)) { goto gtest_label_290; } if (gtest_dt
!= __null) { ::testing::internal::scoped_ptr< ::testing::
internal::DeathTest> gtest_dt_ptr(gtest_dt); switch (gtest_dt
->AssumeRole()) { case ::testing::internal::DeathTest::OVERSEE_TEST
: if (!gtest_dt->Passed(::testing::internal::ExitedUnsuccessfully
(gtest_dt->Wait()))) { goto gtest_label_290; } break; case
::testing::internal::DeathTest::EXECUTE_TEST: { ::testing::internal
::DeathTest::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing
::internal::AlwaysTrue()) { Global->replaceAllUsesWith(GEP
); }; gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE
); break; } } } } else gtest_label_290: ::testing::internal::
AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 290, ::testing::internal::DeathTest::LastMessage()) = ::testing
::Message()
Within the expansion of the macro 'EXPECT_DEATH':
a
Function call argument is an uninitialized value
290 "this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!")switch (0) case 0: default: if (::testing::internal::AlwaysTrue
()) { const ::testing::internal::RE& gtest_regex = ("this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!"
); ::testing::internal::DeathTest* gtest_dt; if (!::testing::
internal::DeathTest::Create("Global->replaceAllUsesWith(GEP)"
, &gtest_regex, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 290, &gtest_dt)) { goto gtest_label_290; } if (gtest_dt
!= __null) { ::testing::internal::scoped_ptr< ::testing::
internal::DeathTest> gtest_dt_ptr(gtest_dt); switch (gtest_dt
->AssumeRole()) { case ::testing::internal::DeathTest::OVERSEE_TEST
: if (!gtest_dt->Passed(::testing::internal::ExitedUnsuccessfully
(gtest_dt->Wait()))) { goto gtest_label_290; } break; case
::testing::internal::DeathTest::EXECUTE_TEST: { ::testing::internal
::DeathTest::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing
::internal::AlwaysTrue()) { Global->replaceAllUsesWith(GEP
); }; gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE
); break; } } } } else gtest_label_290: ::testing::internal::
AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 290, ::testing::internal::DeathTest::LastMessage()) = ::testing
::Message()
;
291}
292
293#endif
294#endif
295
296#undef CHECK
297
298TEST(ConstantsTest, ConstantArrayReplaceWithConstant)class ConstantsTest_ConstantArrayReplaceWithConstant_Test : public
::testing::Test { public: ConstantsTest_ConstantArrayReplaceWithConstant_Test
() {} private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); ConstantsTest_ConstantArrayReplaceWithConstant_Test
(ConstantsTest_ConstantArrayReplaceWithConstant_Test const &
); void operator=(ConstantsTest_ConstantArrayReplaceWithConstant_Test
const &);};::testing::TestInfo* const ConstantsTest_ConstantArrayReplaceWithConstant_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "ConstantArrayReplaceWithConstant", __null,
__null, (::testing::internal::GetTestTypeId()), ::testing::Test
::SetUpTestCase, ::testing::Test::TearDownTestCase, new ::testing
::internal::TestFactoryImpl< ConstantsTest_ConstantArrayReplaceWithConstant_Test
>);void ConstantsTest_ConstantArrayReplaceWithConstant_Test
::TestBody()
{
299 LLVMContext Context;
300 std::unique_ptr<Module> M(new Module("MyModule", Context));
301
302 Type *IntTy = Type::getInt8Ty(Context);
303 ArrayType *ArrayTy = ArrayType::get(IntTy, 2);
304 Constant *A01Vals[2] = {ConstantInt::get(IntTy, 0),
305 ConstantInt::get(IntTy, 1)};
306 Constant *A01 = ConstantArray::get(ArrayTy, A01Vals);
307
308 Constant *Global = new GlobalVariable(*M, IntTy, false,
309 GlobalValue::ExternalLinkage, nullptr);
310 Constant *GlobalInt = ConstantExpr::getPtrToInt(Global, IntTy);
311 Constant *A0GVals[2] = {ConstantInt::get(IntTy, 0), GlobalInt};
312 Constant *A0G = ConstantArray::get(ArrayTy, A0GVals);
313 ASSERT_NE(A01, A0G)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("A01", "A0G", A01
, A0G))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 313, gtest_ar.failure_message()) = ::testing::Message()
;
314
315 GlobalVariable *RefArray =
316 new GlobalVariable(*M, ArrayTy, false, GlobalValue::ExternalLinkage, A0G);
317 ASSERT_EQ(A0G, RefArray->getInitializer())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(A0G)) == 1)>::Compare("A0G"
, "RefArray->getInitializer()", A0G, RefArray->getInitializer
()))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 317, gtest_ar.failure_message()) = ::testing::Message()
;
318
319 GlobalInt->replaceAllUsesWith(ConstantInt::get(IntTy, 1));
320 ASSERT_EQ(A01, RefArray->getInitializer())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(A01)) == 1)>::Compare("A01"
, "RefArray->getInitializer()", A01, RefArray->getInitializer
()))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 320, gtest_ar.failure_message()) = ::testing::Message()
;
321}
322
323TEST(ConstantsTest, ConstantExprReplaceWithConstant)class ConstantsTest_ConstantExprReplaceWithConstant_Test : public
::testing::Test { public: ConstantsTest_ConstantExprReplaceWithConstant_Test
() {} private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); ConstantsTest_ConstantExprReplaceWithConstant_Test
(ConstantsTest_ConstantExprReplaceWithConstant_Test const &
); void operator=(ConstantsTest_ConstantExprReplaceWithConstant_Test
const &);};::testing::TestInfo* const ConstantsTest_ConstantExprReplaceWithConstant_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "ConstantExprReplaceWithConstant", __null, __null
, (::testing::internal::GetTestTypeId()), ::testing::Test::SetUpTestCase
, ::testing::Test::TearDownTestCase, new ::testing::internal::
TestFactoryImpl< ConstantsTest_ConstantExprReplaceWithConstant_Test
>);void ConstantsTest_ConstantExprReplaceWithConstant_Test
::TestBody()
{
324 LLVMContext Context;
325 std::unique_ptr<Module> M(new Module("MyModule", Context));
326
327 Type *IntTy = Type::getInt8Ty(Context);
328 Constant *G1 = new GlobalVariable(*M, IntTy, false,
329 GlobalValue::ExternalLinkage, nullptr);
330 Constant *G2 = new GlobalVariable(*M, IntTy, false,
331 GlobalValue::ExternalLinkage, nullptr);
332 ASSERT_NE(G1, G2)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("G1", "G2", G1,
G2))) ; else return ::testing::internal::AssertHelper(::testing
::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 332, gtest_ar.failure_message()) = ::testing::Message()
;
333
334 Constant *Int1 = ConstantExpr::getPtrToInt(G1, IntTy);
335 Constant *Int2 = ConstantExpr::getPtrToInt(G2, IntTy);
336 ASSERT_NE(Int1, Int2)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal::CmpHelperNE("Int1", "Int2",
Int1, Int2))) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 336, gtest_ar.failure_message()) = ::testing::Message()
;
337
338 GlobalVariable *Ref =
339 new GlobalVariable(*M, IntTy, false, GlobalValue::ExternalLinkage, Int1);
340 ASSERT_EQ(Int1, Ref->getInitializer())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Int1)) == 1)>::Compare("Int1"
, "Ref->getInitializer()", Int1, Ref->getInitializer())
)) ; else return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 340, gtest_ar.failure_message()) = ::testing::Message()
;
341
342 G1->replaceAllUsesWith(G2);
343 ASSERT_EQ(Int2, Ref->getInitializer())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(Int2)) == 1)>::Compare("Int2"
, "Ref->getInitializer()", Int2, Ref->getInitializer())
)) ; else return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 343, gtest_ar.failure_message()) = ::testing::Message()
;
344}
345
346TEST(ConstantsTest, GEPReplaceWithConstant)class ConstantsTest_GEPReplaceWithConstant_Test : public ::testing
::Test { public: ConstantsTest_GEPReplaceWithConstant_Test() {
} private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); ConstantsTest_GEPReplaceWithConstant_Test
(ConstantsTest_GEPReplaceWithConstant_Test const &); void
operator=(ConstantsTest_GEPReplaceWithConstant_Test const &
);};::testing::TestInfo* const ConstantsTest_GEPReplaceWithConstant_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "GEPReplaceWithConstant", __null, __null, (
::testing::internal::GetTestTypeId()), ::testing::Test::SetUpTestCase
, ::testing::Test::TearDownTestCase, new ::testing::internal::
TestFactoryImpl< ConstantsTest_GEPReplaceWithConstant_Test
>);void ConstantsTest_GEPReplaceWithConstant_Test::TestBody
()
{
347 LLVMContext Context;
348 std::unique_ptr<Module> M(new Module("MyModule", Context));
349
350 Type *IntTy = Type::getInt32Ty(Context);
351 Type *PtrTy = PointerType::get(IntTy, 0);
352 auto *C1 = ConstantInt::get(IntTy, 1);
353 auto *Placeholder = new GlobalVariable(
354 *M, IntTy, false, GlobalValue::ExternalWeakLinkage, nullptr);
355 auto *GEP = ConstantExpr::getGetElementPtr(IntTy, Placeholder, C1);
356 ASSERT_EQ(GEP->getOperand(0), Placeholder)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(GEP->getOperand(0))) == 1)
>::Compare("GEP->getOperand(0)", "Placeholder", GEP->
getOperand(0), Placeholder))) ; else return ::testing::internal
::AssertHelper(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 356, gtest_ar.failure_message()) = ::testing::Message()
;
357
358 auto *Ref =
359 new GlobalVariable(*M, PtrTy, false, GlobalValue::ExternalLinkage, GEP);
360 ASSERT_EQ(GEP, Ref->getInitializer())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(GEP)) == 1)>::Compare("GEP"
, "Ref->getInitializer()", GEP, Ref->getInitializer()))
) ; else return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 360, gtest_ar.failure_message()) = ::testing::Message()
;
361
362 auto *Global = new GlobalVariable(*M, PtrTy, false,
363 GlobalValue::ExternalLinkage, nullptr);
364 auto *Alias = GlobalAlias::create(IntTy, 0, GlobalValue::ExternalLinkage,
365 "alias", Global, M.get());
366 Placeholder->replaceAllUsesWith(Alias);
367 ASSERT_EQ(GEP, Ref->getInitializer())switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(GEP)) == 1)>::Compare("GEP"
, "Ref->getInitializer()", GEP, Ref->getInitializer()))
) ; else return ::testing::internal::AssertHelper(::testing::
TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 367, gtest_ar.failure_message()) = ::testing::Message()
;
368 ASSERT_EQ(GEP->getOperand(0), Alias)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(GEP->getOperand(0))) == 1)
>::Compare("GEP->getOperand(0)", "Alias", GEP->getOperand
(0), Alias))) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 368, gtest_ar.failure_message()) = ::testing::Message()
;
369}
370
371TEST(ConstantsTest, AliasCAPI)class ConstantsTest_AliasCAPI_Test : public ::testing::Test {
public: ConstantsTest_AliasCAPI_Test() {} private: virtual void
TestBody(); static ::testing::TestInfo* const test_info_ __attribute__
((unused)); ConstantsTest_AliasCAPI_Test(ConstantsTest_AliasCAPI_Test
const &); void operator=(ConstantsTest_AliasCAPI_Test const
&);};::testing::TestInfo* const ConstantsTest_AliasCAPI_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "AliasCAPI", __null, __null, (::testing::internal
::GetTestTypeId()), ::testing::Test::SetUpTestCase, ::testing
::Test::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< ConstantsTest_AliasCAPI_Test>);void ConstantsTest_AliasCAPI_Test
::TestBody()
{
372 LLVMContext Context;
373 SMDiagnostic Error;
374 std::unique_ptr<Module> M =
375 parseAssemblyString("@g = global i32 42", Error, Context);
376 GlobalVariable *G = M->getGlobalVariable("g");
377 Type *I16Ty = Type::getInt16Ty(Context);
378 Type *I16PTy = PointerType::get(I16Ty, 0);
379 Constant *Aliasee = ConstantExpr::getBitCast(G, I16PTy);
380 LLVMValueRef AliasRef =
381 LLVMAddAlias(wrap(M.get()), wrap(I16PTy), wrap(Aliasee), "a");
382 ASSERT_EQ(unwrap<GlobalAlias>(AliasRef)->getAliasee(), Aliasee)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(unwrap<GlobalAlias>(AliasRef
)->getAliasee())) == 1)>::Compare("unwrap<GlobalAlias>(AliasRef)->getAliasee()"
, "Aliasee", unwrap<GlobalAlias>(AliasRef)->getAliasee
(), Aliasee))) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 382, gtest_ar.failure_message()) = ::testing::Message()
;
383}
384
385static std::string getNameOfType(Type *T) {
386 std::string S;
387 raw_string_ostream RSOS(S);
388 T->print(RSOS);
389 return S;
390}
391
392TEST(ConstantsTest, BuildConstantDataArrays)class ConstantsTest_BuildConstantDataArrays_Test : public ::testing
::Test { public: ConstantsTest_BuildConstantDataArrays_Test()
{} private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); ConstantsTest_BuildConstantDataArrays_Test
(ConstantsTest_BuildConstantDataArrays_Test const &); void
operator=(ConstantsTest_BuildConstantDataArrays_Test const &
);};::testing::TestInfo* const ConstantsTest_BuildConstantDataArrays_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "BuildConstantDataArrays", __null, __null, (
::testing::internal::GetTestTypeId()), ::testing::Test::SetUpTestCase
, ::testing::Test::TearDownTestCase, new ::testing::internal::
TestFactoryImpl< ConstantsTest_BuildConstantDataArrays_Test
>);void ConstantsTest_BuildConstantDataArrays_Test::TestBody
()
{
393 LLVMContext Context;
394 std::unique_ptr<Module> M(new Module("MyModule", Context));
395
396 for (Type *T : {Type::getInt8Ty(Context), Type::getInt16Ty(Context),
397 Type::getInt32Ty(Context), Type::getInt64Ty(Context)}) {
398 ArrayType *ArrayTy = ArrayType::get(T, 2);
399 Constant *Vals[] = {ConstantInt::get(T, 0), ConstantInt::get(T, 1)};
400 Constant *CDV = ConstantArray::get(ArrayTy, Vals);
401 ASSERT_TRUE(dyn_cast<ConstantDataArray>(CDV) != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(dyn_cast<ConstantDataArray
>(CDV) != nullptr)) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 401, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "dyn_cast<ConstantDataArray>(CDV) != nullptr", "false"
, "true").c_str()) = ::testing::Message()
402 << " T = " << getNameOfType(T);
403 }
404
405 for (Type *T : {Type::getHalfTy(Context), Type::getFloatTy(Context),
406 Type::getDoubleTy(Context)}) {
407 ArrayType *ArrayTy = ArrayType::get(T, 2);
408 Constant *Vals[] = {ConstantFP::get(T, 0), ConstantFP::get(T, 1)};
409 Constant *CDV = ConstantArray::get(ArrayTy, Vals);
410 ASSERT_TRUE(dyn_cast<ConstantDataArray>(CDV) != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(dyn_cast<ConstantDataArray
>(CDV) != nullptr)) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 410, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "dyn_cast<ConstantDataArray>(CDV) != nullptr", "false"
, "true").c_str()) = ::testing::Message()
411 << " T = " << getNameOfType(T);
412 }
413}
414
415TEST(ConstantsTest, BuildConstantDataVectors)class ConstantsTest_BuildConstantDataVectors_Test : public ::
testing::Test { public: ConstantsTest_BuildConstantDataVectors_Test
() {} private: virtual void TestBody(); static ::testing::TestInfo
* const test_info_ __attribute__ ((unused)); ConstantsTest_BuildConstantDataVectors_Test
(ConstantsTest_BuildConstantDataVectors_Test const &); void
operator=(ConstantsTest_BuildConstantDataVectors_Test const &
);};::testing::TestInfo* const ConstantsTest_BuildConstantDataVectors_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "BuildConstantDataVectors", __null, __null,
(::testing::internal::GetTestTypeId()), ::testing::Test::SetUpTestCase
, ::testing::Test::TearDownTestCase, new ::testing::internal::
TestFactoryImpl< ConstantsTest_BuildConstantDataVectors_Test
>);void ConstantsTest_BuildConstantDataVectors_Test::TestBody
()
{
416 LLVMContext Context;
417 std::unique_ptr<Module> M(new Module("MyModule", Context));
418
419 for (Type *T : {Type::getInt8Ty(Context), Type::getInt16Ty(Context),
420 Type::getInt32Ty(Context), Type::getInt64Ty(Context)}) {
421 Constant *Vals[] = {ConstantInt::get(T, 0), ConstantInt::get(T, 1)};
422 Constant *CDV = ConstantVector::get(Vals);
423 ASSERT_TRUE(dyn_cast<ConstantDataVector>(CDV) != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(dyn_cast<ConstantDataVector
>(CDV) != nullptr)) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 423, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "dyn_cast<ConstantDataVector>(CDV) != nullptr", "false"
, "true").c_str()) = ::testing::Message()
424 << " T = " << getNameOfType(T);
425 }
426
427 for (Type *T : {Type::getHalfTy(Context), Type::getFloatTy(Context),
428 Type::getDoubleTy(Context)}) {
429 Constant *Vals[] = {ConstantFP::get(T, 0), ConstantFP::get(T, 1)};
430 Constant *CDV = ConstantVector::get(Vals);
431 ASSERT_TRUE(dyn_cast<ConstantDataVector>(CDV) != nullptr)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar_ = ::testing::AssertionResult(dyn_cast<ConstantDataVector
>(CDV) != nullptr)) ; else return ::testing::internal::AssertHelper
(::testing::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 431, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_
, "dyn_cast<ConstantDataVector>(CDV) != nullptr", "false"
, "true").c_str()) = ::testing::Message()
432 << " T = " << getNameOfType(T);
433 }
434}
435
436TEST(ConstantsTest, BitcastToGEP)class ConstantsTest_BitcastToGEP_Test : public ::testing::Test
{ public: ConstantsTest_BitcastToGEP_Test() {} private: virtual
void TestBody(); static ::testing::TestInfo* const test_info_
__attribute__ ((unused)); ConstantsTest_BitcastToGEP_Test(ConstantsTest_BitcastToGEP_Test
const &); void operator=(ConstantsTest_BitcastToGEP_Test
const &);};::testing::TestInfo* const ConstantsTest_BitcastToGEP_Test
::test_info_ = ::testing::internal::MakeAndRegisterTestInfo(
"ConstantsTest", "BitcastToGEP", __null, __null, (::testing::
internal::GetTestTypeId()), ::testing::Test::SetUpTestCase, ::
testing::Test::TearDownTestCase, new ::testing::internal::TestFactoryImpl
< ConstantsTest_BitcastToGEP_Test>);void ConstantsTest_BitcastToGEP_Test
::TestBody()
{
437 LLVMContext Context;
438 std::unique_ptr<Module> M(new Module("MyModule", Context));
439
440 auto *i32 = Type::getInt32Ty(Context);
441 auto *U = StructType::create(Context, "Unsized");
442 Type *EltTys[] = {i32, U};
443 auto *S = StructType::create(EltTys);
444
445 auto *G = new GlobalVariable(*M, S, false,
446 GlobalValue::ExternalLinkage, nullptr);
447 auto *PtrTy = PointerType::get(i32, 0);
448 auto *C = ConstantExpr::getBitCast(G, PtrTy);
449 ASSERT_EQ(dyn_cast<ConstantExpr>(C)->getOpcode(),switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(dyn_cast<ConstantExpr>(
C)->getOpcode())) == 1)>::Compare("dyn_cast<ConstantExpr>(C)->getOpcode()"
, "Instruction::BitCast", dyn_cast<ConstantExpr>(C)->
getOpcode(), Instruction::BitCast))) ; else return ::testing::
internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 450, gtest_ar.failure_message()) = ::testing::Message()
450 Instruction::BitCast)switch (0) case 0: default: if (const ::testing::AssertionResult
gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing
::internal::IsNullLiteralHelper(dyn_cast<ConstantExpr>(
C)->getOpcode())) == 1)>::Compare("dyn_cast<ConstantExpr>(C)->getOpcode()"
, "Instruction::BitCast", dyn_cast<ConstantExpr>(C)->
getOpcode(), Instruction::BitCast))) ; else return ::testing::
internal::AssertHelper(::testing::TestPartResult::kFatalFailure
, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ConstantsTest.cpp"
, 450, gtest_ar.failure_message()) = ::testing::Message()
;
451}
452
453} // end anonymous namespace
454} // end namespace llvm