File: | unittests/IR/ValueHandleTest.cpp |
Location: | line 182, column 3 |
Description: | Function call argument is an uninitialized value |
1 | //===- ValueHandleTest.cpp - ValueHandle 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/IR/ValueHandle.h" | ||
11 | #include "llvm/IR/Constants.h" | ||
12 | #include "llvm/IR/Instructions.h" | ||
13 | #include "llvm/IR/LLVMContext.h" | ||
14 | #include "gtest/gtest.h" | ||
15 | #include <memory> | ||
16 | |||
17 | using namespace llvm; | ||
18 | |||
19 | namespace { | ||
20 | |||
21 | class ValueHandle : public testing::Test { | ||
22 | protected: | ||
23 | Constant *ConstantV; | ||
24 | std::unique_ptr<BitCastInst> BitcastV; | ||
25 | |||
26 | ValueHandle() : | ||
27 | ConstantV(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 0)), | ||
28 | BitcastV(new BitCastInst(ConstantV, Type::getInt32Ty(getGlobalContext()))) { | ||
29 | } | ||
30 | }; | ||
31 | |||
32 | class ConcreteCallbackVH final : public CallbackVH { | ||
33 | public: | ||
34 | ConcreteCallbackVH(Value *V) : CallbackVH(V) {} | ||
35 | }; | ||
36 | |||
37 | TEST_F(ValueHandle, WeakVH_BasicOperation)class ValueHandle_WeakVH_BasicOperation_Test : public ValueHandle { public: ValueHandle_WeakVH_BasicOperation_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_WeakVH_BasicOperation_Test (ValueHandle_WeakVH_BasicOperation_Test const &); void operator =(ValueHandle_WeakVH_BasicOperation_Test const &);};::testing ::TestInfo* const ValueHandle_WeakVH_BasicOperation_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "WeakVH_BasicOperation", __null, __null, (::testing::internal ::GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase , ValueHandle::TearDownTestCase, new ::testing::internal::TestFactoryImpl < ValueHandle_WeakVH_BasicOperation_Test>);void ValueHandle_WeakVH_BasicOperation_Test ::TestBody() { | ||
38 | WeakVH WVH(BitcastV.get()); | ||
39 | EXPECT_EQ(BitcastV.get(), WVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BitcastV.get())) == 1)>::Compare ("BitcastV.get()", "WVH", BitcastV.get(), WVH))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 39, gtest_ar.failure_message()) = ::testing::Message(); | ||
40 | WVH = ConstantV; | ||
41 | EXPECT_EQ(ConstantV, WVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "WVH", ConstantV, WVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 41, gtest_ar.failure_message()) = ::testing::Message(); | ||
42 | |||
43 | // Make sure I can call a method on the underlying Value. It | ||
44 | // doesn't matter which method. | ||
45 | EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), WVH->getType())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(Type::getInt32Ty(getGlobalContext ()))) == 1)>::Compare("Type::getInt32Ty(getGlobalContext())" , "WVH->getType()", Type::getInt32Ty(getGlobalContext()), WVH ->getType()))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 45, gtest_ar.failure_message()) = ::testing::Message(); | ||
46 | EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), (*WVH).getType())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(Type::getInt32Ty(getGlobalContext ()))) == 1)>::Compare("Type::getInt32Ty(getGlobalContext())" , "(*WVH).getType()", Type::getInt32Ty(getGlobalContext()), ( *WVH).getType()))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 46, gtest_ar.failure_message()) = ::testing::Message(); | ||
47 | } | ||
48 | |||
49 | TEST_F(ValueHandle, WeakVH_Comparisons)class ValueHandle_WeakVH_Comparisons_Test : public ValueHandle { public: ValueHandle_WeakVH_Comparisons_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_WeakVH_Comparisons_Test (ValueHandle_WeakVH_Comparisons_Test const &); void operator =(ValueHandle_WeakVH_Comparisons_Test const &);};::testing ::TestInfo* const ValueHandle_WeakVH_Comparisons_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "WeakVH_Comparisons", __null, __null, (::testing::internal:: GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase, ValueHandle ::TearDownTestCase, new ::testing::internal::TestFactoryImpl< ValueHandle_WeakVH_Comparisons_Test>);void ValueHandle_WeakVH_Comparisons_Test ::TestBody() { | ||
50 | WeakVH BitcastWVH(BitcastV.get()); | ||
51 | WeakVH ConstantWVH(ConstantV); | ||
52 | |||
53 | EXPECT_TRUE(BitcastWVH == BitcastWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastWVH == BitcastWVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 53, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastWVH == BitcastWVH", "false", "true").c_str()) = ::testing ::Message(); | ||
54 | EXPECT_TRUE(BitcastV.get() == BitcastWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastV.get() == BitcastWVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 54, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastV.get() == BitcastWVH", "false", "true").c_str()) = ::testing::Message(); | ||
55 | EXPECT_TRUE(BitcastWVH == BitcastV.get())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastWVH == BitcastV .get())) ; else ::testing::internal::AssertHelper(::testing:: TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 55, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastWVH == BitcastV.get()", "false", "true").c_str()) = ::testing::Message(); | ||
56 | EXPECT_FALSE(BitcastWVH == ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(BitcastWVH == ConstantWVH ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 56, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastWVH == ConstantWVH", "true", "false").c_str()) = :: testing::Message(); | ||
57 | |||
58 | EXPECT_TRUE(BitcastWVH != ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastWVH != ConstantWVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 58, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastWVH != ConstantWVH", "false", "true").c_str()) = :: testing::Message(); | ||
59 | EXPECT_TRUE(BitcastV.get() != ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastV.get() != ConstantWVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 59, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastV.get() != ConstantWVH", "false", "true").c_str()) = ::testing::Message(); | ||
60 | EXPECT_TRUE(BitcastWVH != ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastWVH != ConstantV )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 60, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastWVH != ConstantV", "false", "true").c_str()) = ::testing ::Message(); | ||
61 | EXPECT_FALSE(BitcastWVH != BitcastWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(BitcastWVH != BitcastWVH ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 61, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastWVH != BitcastWVH", "true", "false").c_str()) = ::testing ::Message(); | ||
62 | |||
63 | // Cast to Value* so comparisons work. | ||
64 | Value *BV = BitcastV.get(); | ||
65 | Value *CV = ConstantV; | ||
66 | EXPECT_EQ(BV < CV, BitcastWVH < ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastWVH < ConstantWVH", BV < CV, BitcastWVH < ConstantWVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 66, gtest_ar.failure_message()) = ::testing::Message(); | ||
67 | EXPECT_EQ(BV <= CV, BitcastWVH <= ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastWVH <= ConstantWVH", BV <= CV, BitcastWVH <= ConstantWVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 67, gtest_ar.failure_message()) = ::testing::Message(); | ||
68 | EXPECT_EQ(BV > CV, BitcastWVH > ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastWVH > ConstantWVH", BV > CV, BitcastWVH > ConstantWVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 68, gtest_ar.failure_message()) = ::testing::Message(); | ||
69 | EXPECT_EQ(BV >= CV, BitcastWVH >= ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastWVH >= ConstantWVH", BV >= CV, BitcastWVH >= ConstantWVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 69, gtest_ar.failure_message()) = ::testing::Message(); | ||
70 | |||
71 | EXPECT_EQ(BV < CV, BitcastV.get() < ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastV.get() < ConstantWVH", BV < CV, BitcastV.get() < ConstantWVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 71, gtest_ar.failure_message()) = ::testing::Message(); | ||
72 | EXPECT_EQ(BV <= CV, BitcastV.get() <= ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastV.get() <= ConstantWVH", BV <= CV , BitcastV.get() <= ConstantWVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 72, gtest_ar.failure_message()) = ::testing::Message(); | ||
73 | EXPECT_EQ(BV > CV, BitcastV.get() > ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastV.get() > ConstantWVH", BV > CV, BitcastV.get() > ConstantWVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 73, gtest_ar.failure_message()) = ::testing::Message(); | ||
74 | EXPECT_EQ(BV >= CV, BitcastV.get() >= ConstantWVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastV.get() >= ConstantWVH", BV >= CV , BitcastV.get() >= ConstantWVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 74, gtest_ar.failure_message()) = ::testing::Message(); | ||
75 | |||
76 | EXPECT_EQ(BV < CV, BitcastWVH < ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastWVH < ConstantV", BV < CV, BitcastWVH < ConstantV))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 76, gtest_ar.failure_message()) = ::testing::Message(); | ||
77 | EXPECT_EQ(BV <= CV, BitcastWVH <= ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastWVH <= ConstantV", BV <= CV, BitcastWVH <= ConstantV))) ; else ::testing::internal::AssertHelper( ::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 77, gtest_ar.failure_message()) = ::testing::Message(); | ||
78 | EXPECT_EQ(BV > CV, BitcastWVH > ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastWVH > ConstantV", BV > CV, BitcastWVH > ConstantV))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 78, gtest_ar.failure_message()) = ::testing::Message(); | ||
79 | EXPECT_EQ(BV >= CV, BitcastWVH >= ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastWVH >= ConstantV", BV >= CV, BitcastWVH >= ConstantV))) ; else ::testing::internal::AssertHelper( ::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 79, gtest_ar.failure_message()) = ::testing::Message(); | ||
80 | } | ||
81 | |||
82 | TEST_F(ValueHandle, WeakVH_FollowsRAUW)class ValueHandle_WeakVH_FollowsRAUW_Test : public ValueHandle { public: ValueHandle_WeakVH_FollowsRAUW_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_WeakVH_FollowsRAUW_Test (ValueHandle_WeakVH_FollowsRAUW_Test const &); void operator =(ValueHandle_WeakVH_FollowsRAUW_Test const &);};::testing ::TestInfo* const ValueHandle_WeakVH_FollowsRAUW_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "WeakVH_FollowsRAUW", __null, __null, (::testing::internal:: GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase, ValueHandle ::TearDownTestCase, new ::testing::internal::TestFactoryImpl< ValueHandle_WeakVH_FollowsRAUW_Test>);void ValueHandle_WeakVH_FollowsRAUW_Test ::TestBody() { | ||
83 | WeakVH WVH(BitcastV.get()); | ||
84 | WeakVH WVH_Copy(WVH); | ||
85 | WeakVH WVH_Recreated(BitcastV.get()); | ||
86 | BitcastV->replaceAllUsesWith(ConstantV); | ||
87 | EXPECT_EQ(ConstantV, WVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "WVH", ConstantV, WVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 87, gtest_ar.failure_message()) = ::testing::Message(); | ||
88 | EXPECT_EQ(ConstantV, WVH_Copy)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "WVH_Copy", ConstantV, WVH_Copy))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 88, gtest_ar.failure_message()) = ::testing::Message(); | ||
89 | EXPECT_EQ(ConstantV, WVH_Recreated)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "WVH_Recreated", ConstantV, WVH_Recreated))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult:: kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 89, gtest_ar.failure_message()) = ::testing::Message(); | ||
90 | } | ||
91 | |||
92 | TEST_F(ValueHandle, WeakVH_NullOnDeletion)class ValueHandle_WeakVH_NullOnDeletion_Test : public ValueHandle { public: ValueHandle_WeakVH_NullOnDeletion_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_WeakVH_NullOnDeletion_Test (ValueHandle_WeakVH_NullOnDeletion_Test const &); void operator =(ValueHandle_WeakVH_NullOnDeletion_Test const &);};::testing ::TestInfo* const ValueHandle_WeakVH_NullOnDeletion_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "WeakVH_NullOnDeletion", __null, __null, (::testing::internal ::GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase , ValueHandle::TearDownTestCase, new ::testing::internal::TestFactoryImpl < ValueHandle_WeakVH_NullOnDeletion_Test>);void ValueHandle_WeakVH_NullOnDeletion_Test ::TestBody() { | ||
93 | WeakVH WVH(BitcastV.get()); | ||
94 | WeakVH WVH_Copy(WVH); | ||
95 | WeakVH WVH_Recreated(BitcastV.get()); | ||
96 | BitcastV.reset(); | ||
97 | Value *null_value = nullptr; | ||
98 | EXPECT_EQ(null_value, WVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(null_value)) == 1)>::Compare ("null_value", "WVH", null_value, WVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 98, gtest_ar.failure_message()) = ::testing::Message(); | ||
99 | EXPECT_EQ(null_value, WVH_Copy)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(null_value)) == 1)>::Compare ("null_value", "WVH_Copy", null_value, WVH_Copy))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 99, gtest_ar.failure_message()) = ::testing::Message(); | ||
100 | EXPECT_EQ(null_value, WVH_Recreated)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(null_value)) == 1)>::Compare ("null_value", "WVH_Recreated", null_value, WVH_Recreated))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 100, gtest_ar.failure_message()) = ::testing::Message(); | ||
101 | } | ||
102 | |||
103 | |||
104 | TEST_F(ValueHandle, AssertingVH_BasicOperation)class ValueHandle_AssertingVH_BasicOperation_Test : public ValueHandle { public: ValueHandle_AssertingVH_BasicOperation_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_AssertingVH_BasicOperation_Test (ValueHandle_AssertingVH_BasicOperation_Test const &); void operator=(ValueHandle_AssertingVH_BasicOperation_Test const & );};::testing::TestInfo* const ValueHandle_AssertingVH_BasicOperation_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "AssertingVH_BasicOperation", __null, __null, (::testing::internal::GetTypeId<ValueHandle>()), ValueHandle ::SetUpTestCase, ValueHandle::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< ValueHandle_AssertingVH_BasicOperation_Test >);void ValueHandle_AssertingVH_BasicOperation_Test::TestBody () { | ||
105 | AssertingVH<CastInst> AVH(BitcastV.get()); | ||
106 | CastInst *implicit_to_exact_type = AVH; | ||
107 | (void)implicit_to_exact_type; // Avoid warning. | ||
108 | |||
109 | AssertingVH<Value> GenericAVH(BitcastV.get()); | ||
110 | EXPECT_EQ(BitcastV.get(), GenericAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BitcastV.get())) == 1)>::Compare ("BitcastV.get()", "GenericAVH", BitcastV.get(), GenericAVH)) ) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 110, gtest_ar.failure_message()) = ::testing::Message(); | ||
111 | GenericAVH = ConstantV; | ||
112 | EXPECT_EQ(ConstantV, GenericAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "GenericAVH", ConstantV, GenericAVH))) ; else :: testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 112, gtest_ar.failure_message()) = ::testing::Message(); | ||
113 | |||
114 | // Make sure I can call a method on the underlying CastInst. It | ||
115 | // doesn't matter which method. | ||
116 | EXPECT_FALSE(AVH->mayWriteToMemory())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(AVH->mayWriteToMemory ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 116, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "AVH->mayWriteToMemory()", "true", "false").c_str()) = :: testing::Message(); | ||
117 | EXPECT_FALSE((*AVH).mayWriteToMemory())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!((*AVH).mayWriteToMemory ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 117, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "(*AVH).mayWriteToMemory()", "true", "false").c_str()) = :: testing::Message(); | ||
118 | } | ||
119 | |||
120 | TEST_F(ValueHandle, AssertingVH_Const)class ValueHandle_AssertingVH_Const_Test : public ValueHandle { public: ValueHandle_AssertingVH_Const_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_AssertingVH_Const_Test (ValueHandle_AssertingVH_Const_Test const &); void operator =(ValueHandle_AssertingVH_Const_Test const &);};::testing ::TestInfo* const ValueHandle_AssertingVH_Const_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "AssertingVH_Const", __null, __null, (::testing::internal:: GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase, ValueHandle ::TearDownTestCase, new ::testing::internal::TestFactoryImpl< ValueHandle_AssertingVH_Const_Test>);void ValueHandle_AssertingVH_Const_Test ::TestBody() { | ||
121 | const CastInst *ConstBitcast = BitcastV.get(); | ||
122 | AssertingVH<const CastInst> AVH(ConstBitcast); | ||
123 | const CastInst *implicit_to_exact_type = AVH; | ||
124 | (void)implicit_to_exact_type; // Avoid warning. | ||
125 | } | ||
126 | |||
127 | TEST_F(ValueHandle, AssertingVH_Comparisons)class ValueHandle_AssertingVH_Comparisons_Test : public ValueHandle { public: ValueHandle_AssertingVH_Comparisons_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_AssertingVH_Comparisons_Test (ValueHandle_AssertingVH_Comparisons_Test const &); void operator =(ValueHandle_AssertingVH_Comparisons_Test const &);};::testing ::TestInfo* const ValueHandle_AssertingVH_Comparisons_Test :: test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "AssertingVH_Comparisons", __null, __null, (::testing::internal ::GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase , ValueHandle::TearDownTestCase, new ::testing::internal::TestFactoryImpl < ValueHandle_AssertingVH_Comparisons_Test>);void ValueHandle_AssertingVH_Comparisons_Test ::TestBody() { | ||
128 | AssertingVH<Value> BitcastAVH(BitcastV.get()); | ||
129 | AssertingVH<Value> ConstantAVH(ConstantV); | ||
130 | |||
131 | EXPECT_TRUE(BitcastAVH == BitcastAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastAVH == BitcastAVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 131, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastAVH == BitcastAVH", "false", "true").c_str()) = ::testing ::Message(); | ||
132 | EXPECT_TRUE(BitcastV.get() == BitcastAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastV.get() == BitcastAVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 132, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastV.get() == BitcastAVH", "false", "true").c_str()) = ::testing::Message(); | ||
133 | EXPECT_TRUE(BitcastAVH == BitcastV.get())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastAVH == BitcastV .get())) ; else ::testing::internal::AssertHelper(::testing:: TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 133, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastAVH == BitcastV.get()", "false", "true").c_str()) = ::testing::Message(); | ||
134 | EXPECT_FALSE(BitcastAVH == ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(BitcastAVH == ConstantAVH ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 134, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastAVH == ConstantAVH", "true", "false").c_str()) = :: testing::Message(); | ||
135 | |||
136 | EXPECT_TRUE(BitcastAVH != ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastAVH != ConstantAVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 136, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastAVH != ConstantAVH", "false", "true").c_str()) = :: testing::Message(); | ||
137 | EXPECT_TRUE(BitcastV.get() != ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastV.get() != ConstantAVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 137, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastV.get() != ConstantAVH", "false", "true").c_str()) = ::testing::Message(); | ||
138 | EXPECT_TRUE(BitcastAVH != ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastAVH != ConstantV )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 138, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastAVH != ConstantV", "false", "true").c_str()) = ::testing ::Message(); | ||
139 | EXPECT_FALSE(BitcastAVH != BitcastAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(BitcastAVH != BitcastAVH ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 139, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastAVH != BitcastAVH", "true", "false").c_str()) = ::testing ::Message(); | ||
140 | |||
141 | // Cast to Value* so comparisons work. | ||
142 | Value *BV = BitcastV.get(); | ||
143 | Value *CV = ConstantV; | ||
144 | EXPECT_EQ(BV < CV, BitcastAVH < ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastAVH < ConstantAVH", BV < CV, BitcastAVH < ConstantAVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 144, gtest_ar.failure_message()) = ::testing::Message(); | ||
145 | EXPECT_EQ(BV <= CV, BitcastAVH <= ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastAVH <= ConstantAVH", BV <= CV, BitcastAVH <= ConstantAVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 145, gtest_ar.failure_message()) = ::testing::Message(); | ||
146 | EXPECT_EQ(BV > CV, BitcastAVH > ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastAVH > ConstantAVH", BV > CV, BitcastAVH > ConstantAVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 146, gtest_ar.failure_message()) = ::testing::Message(); | ||
147 | EXPECT_EQ(BV >= CV, BitcastAVH >= ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastAVH >= ConstantAVH", BV >= CV, BitcastAVH >= ConstantAVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 147, gtest_ar.failure_message()) = ::testing::Message(); | ||
148 | |||
149 | EXPECT_EQ(BV < CV, BitcastV.get() < ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastV.get() < ConstantAVH", BV < CV, BitcastV.get() < ConstantAVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 149, gtest_ar.failure_message()) = ::testing::Message(); | ||
150 | EXPECT_EQ(BV <= CV, BitcastV.get() <= ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastV.get() <= ConstantAVH", BV <= CV , BitcastV.get() <= ConstantAVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 150, gtest_ar.failure_message()) = ::testing::Message(); | ||
151 | EXPECT_EQ(BV > CV, BitcastV.get() > ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastV.get() > ConstantAVH", BV > CV, BitcastV.get() > ConstantAVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 151, gtest_ar.failure_message()) = ::testing::Message(); | ||
152 | EXPECT_EQ(BV >= CV, BitcastV.get() >= ConstantAVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastV.get() >= ConstantAVH", BV >= CV , BitcastV.get() >= ConstantAVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 152, gtest_ar.failure_message()) = ::testing::Message(); | ||
153 | |||
154 | EXPECT_EQ(BV < CV, BitcastAVH < ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastAVH < ConstantV", BV < CV, BitcastAVH < ConstantV))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 154, gtest_ar.failure_message()) = ::testing::Message(); | ||
155 | EXPECT_EQ(BV <= CV, BitcastAVH <= ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastAVH <= ConstantV", BV <= CV, BitcastAVH <= ConstantV))) ; else ::testing::internal::AssertHelper( ::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 155, gtest_ar.failure_message()) = ::testing::Message(); | ||
156 | EXPECT_EQ(BV > CV, BitcastAVH > ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastAVH > ConstantV", BV > CV, BitcastAVH > ConstantV))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 156, gtest_ar.failure_message()) = ::testing::Message(); | ||
157 | EXPECT_EQ(BV >= CV, BitcastAVH >= ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastAVH >= ConstantV", BV >= CV, BitcastAVH >= ConstantV))) ; else ::testing::internal::AssertHelper( ::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 157, gtest_ar.failure_message()) = ::testing::Message(); | ||
158 | } | ||
159 | |||
160 | TEST_F(ValueHandle, AssertingVH_DoesNotFollowRAUW)class ValueHandle_AssertingVH_DoesNotFollowRAUW_Test : public ValueHandle { public: ValueHandle_AssertingVH_DoesNotFollowRAUW_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); ValueHandle_AssertingVH_DoesNotFollowRAUW_Test (ValueHandle_AssertingVH_DoesNotFollowRAUW_Test const &); void operator=(ValueHandle_AssertingVH_DoesNotFollowRAUW_Test const &);};::testing::TestInfo* const ValueHandle_AssertingVH_DoesNotFollowRAUW_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "AssertingVH_DoesNotFollowRAUW", __null, __null , (::testing::internal::GetTypeId<ValueHandle>()), ValueHandle ::SetUpTestCase, ValueHandle::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< ValueHandle_AssertingVH_DoesNotFollowRAUW_Test >);void ValueHandle_AssertingVH_DoesNotFollowRAUW_Test::TestBody () { | ||
161 | AssertingVH<Value> AVH(BitcastV.get()); | ||
162 | BitcastV->replaceAllUsesWith(ConstantV); | ||
163 | EXPECT_EQ(BitcastV.get(), AVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BitcastV.get())) == 1)>::Compare ("BitcastV.get()", "AVH", BitcastV.get(), AVH))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 163, gtest_ar.failure_message()) = ::testing::Message(); | ||
164 | } | ||
165 | |||
166 | #ifdef NDEBUG | ||
167 | |||
168 | TEST_F(ValueHandle, AssertingVH_ReducesToPointer)class ValueHandle_AssertingVH_ReducesToPointer_Test : public ValueHandle { public: ValueHandle_AssertingVH_ReducesToPointer_Test() {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); ValueHandle_AssertingVH_ReducesToPointer_Test (ValueHandle_AssertingVH_ReducesToPointer_Test const &); void operator=(ValueHandle_AssertingVH_ReducesToPointer_Test const &);};::testing::TestInfo* const ValueHandle_AssertingVH_ReducesToPointer_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "AssertingVH_ReducesToPointer", __null, __null , (::testing::internal::GetTypeId<ValueHandle>()), ValueHandle ::SetUpTestCase, ValueHandle::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< ValueHandle_AssertingVH_ReducesToPointer_Test >);void ValueHandle_AssertingVH_ReducesToPointer_Test::TestBody () { | ||
169 | EXPECT_EQ(sizeof(CastInst *), sizeof(AssertingVH<CastInst>))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(sizeof(CastInst *))) == 1)> ::Compare("sizeof(CastInst *)", "sizeof(AssertingVH<CastInst>)" , sizeof(CastInst *), sizeof(AssertingVH<CastInst>)))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 169, gtest_ar.failure_message()) = ::testing::Message(); | ||
170 | } | ||
171 | |||
172 | #else // !NDEBUG | ||
173 | |||
174 | #ifdef GTEST_HAS_DEATH_TEST1 | ||
175 | |||
176 | TEST_F(ValueHandle, AssertingVH_Asserts)class ValueHandle_AssertingVH_Asserts_Test : public ValueHandle { public: ValueHandle_AssertingVH_Asserts_Test() {} private: virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_AssertingVH_Asserts_Test (ValueHandle_AssertingVH_Asserts_Test const &); void operator =(ValueHandle_AssertingVH_Asserts_Test const &);};::testing ::TestInfo* const ValueHandle_AssertingVH_Asserts_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "AssertingVH_Asserts", __null, __null, (::testing::internal ::GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase , ValueHandle::TearDownTestCase, new ::testing::internal::TestFactoryImpl < ValueHandle_AssertingVH_Asserts_Test>);void ValueHandle_AssertingVH_Asserts_Test ::TestBody() { | ||
177 | AssertingVH<Value> AVH(BitcastV.get()); | ||
178 | EXPECT_DEATH({BitcastV.reset();},switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { const ::testing::internal::RE& gtest_regex = ("An asserting value handle still pointed to this value!" ); ::testing::internal::DeathTest* gtest_dt; if (!::testing:: internal::DeathTest::Create("{BitcastV.reset();}", >est_regex , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 179, >est_dt)) { goto gtest_label_179; } 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_179; } break; case ::testing::internal::DeathTest::EXECUTE_TEST: { ::testing::internal ::DeathTest::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing ::internal::AlwaysTrue()) { {BitcastV.reset();}; }; gtest_dt-> Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); break ; } } } } else gtest_label_179: ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 179, ::testing::internal::DeathTest::LastMessage()) = ::testing ::Message() | ||
179 | "An asserting value handle still pointed to this value!")switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { const ::testing::internal::RE& gtest_regex = ("An asserting value handle still pointed to this value!" ); ::testing::internal::DeathTest* gtest_dt; if (!::testing:: internal::DeathTest::Create("{BitcastV.reset();}", >est_regex , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 179, >est_dt)) { goto gtest_label_179; } 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_179; } break; case ::testing::internal::DeathTest::EXECUTE_TEST: { ::testing::internal ::DeathTest::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing ::internal::AlwaysTrue()) { {BitcastV.reset();}; }; gtest_dt-> Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); break ; } } } } else gtest_label_179: ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 179, ::testing::internal::DeathTest::LastMessage()) = ::testing ::Message(); | ||
180 | AssertingVH<Value> Copy(AVH); | ||
181 | AVH = nullptr; | ||
182 | EXPECT_DEATH({BitcastV.reset();},switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { const ::testing::internal::RE& gtest_regex = ("An asserting value handle still pointed to this value!" ); ::testing::internal::DeathTest* gtest_dt; if (!::testing:: internal::DeathTest::Create("{BitcastV.reset();}", >est_regex , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 183, >est_dt)) { goto gtest_label_183; } 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_183; } break; case ::testing::internal::DeathTest::EXECUTE_TEST: { ::testing::internal ::DeathTest::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing ::internal::AlwaysTrue()) { {BitcastV.reset();}; }; gtest_dt-> Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); break ; } } } } else gtest_label_183: ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 183, ::testing::internal::DeathTest::LastMessage()) = ::testing ::Message() | ||
Within the expansion of the macro 'EXPECT_DEATH':
| |||
183 | "An asserting value handle still pointed to this value!")switch (0) case 0: default: if (::testing::internal::AlwaysTrue ()) { const ::testing::internal::RE& gtest_regex = ("An asserting value handle still pointed to this value!" ); ::testing::internal::DeathTest* gtest_dt; if (!::testing:: internal::DeathTest::Create("{BitcastV.reset();}", >est_regex , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 183, >est_dt)) { goto gtest_label_183; } 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_183; } break; case ::testing::internal::DeathTest::EXECUTE_TEST: { ::testing::internal ::DeathTest::ReturnSentinel gtest_sentinel(gtest_dt); if (::testing ::internal::AlwaysTrue()) { {BitcastV.reset();}; }; gtest_dt-> Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); break ; } } } } else gtest_label_183: ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 183, ::testing::internal::DeathTest::LastMessage()) = ::testing ::Message(); | ||
184 | Copy = nullptr; | ||
185 | BitcastV.reset(); | ||
186 | } | ||
187 | |||
188 | #endif // GTEST_HAS_DEATH_TEST | ||
189 | |||
190 | #endif // NDEBUG | ||
191 | |||
192 | TEST_F(ValueHandle, CallbackVH_BasicOperation)class ValueHandle_CallbackVH_BasicOperation_Test : public ValueHandle { public: ValueHandle_CallbackVH_BasicOperation_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_CallbackVH_BasicOperation_Test (ValueHandle_CallbackVH_BasicOperation_Test const &); void operator=(ValueHandle_CallbackVH_BasicOperation_Test const & );};::testing::TestInfo* const ValueHandle_CallbackVH_BasicOperation_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "CallbackVH_BasicOperation", __null, __null, ( ::testing::internal::GetTypeId<ValueHandle>()), ValueHandle ::SetUpTestCase, ValueHandle::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< ValueHandle_CallbackVH_BasicOperation_Test >);void ValueHandle_CallbackVH_BasicOperation_Test::TestBody () { | ||
193 | ConcreteCallbackVH CVH(BitcastV.get()); | ||
194 | EXPECT_EQ(BitcastV.get(), CVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BitcastV.get())) == 1)>::Compare ("BitcastV.get()", "CVH", BitcastV.get(), CVH))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 194, gtest_ar.failure_message()) = ::testing::Message(); | ||
195 | CVH = ConstantV; | ||
196 | EXPECT_EQ(ConstantV, CVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "CVH", ConstantV, CVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 196, gtest_ar.failure_message()) = ::testing::Message(); | ||
197 | |||
198 | // Make sure I can call a method on the underlying Value. It | ||
199 | // doesn't matter which method. | ||
200 | EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), CVH->getType())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(Type::getInt32Ty(getGlobalContext ()))) == 1)>::Compare("Type::getInt32Ty(getGlobalContext())" , "CVH->getType()", Type::getInt32Ty(getGlobalContext()), CVH ->getType()))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 200, gtest_ar.failure_message()) = ::testing::Message(); | ||
201 | EXPECT_EQ(Type::getInt32Ty(getGlobalContext()), (*CVH).getType())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(Type::getInt32Ty(getGlobalContext ()))) == 1)>::Compare("Type::getInt32Ty(getGlobalContext())" , "(*CVH).getType()", Type::getInt32Ty(getGlobalContext()), ( *CVH).getType()))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 201, gtest_ar.failure_message()) = ::testing::Message(); | ||
202 | } | ||
203 | |||
204 | TEST_F(ValueHandle, CallbackVH_Comparisons)class ValueHandle_CallbackVH_Comparisons_Test : public ValueHandle { public: ValueHandle_CallbackVH_Comparisons_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_CallbackVH_Comparisons_Test (ValueHandle_CallbackVH_Comparisons_Test const &); void operator =(ValueHandle_CallbackVH_Comparisons_Test const &);};::testing ::TestInfo* const ValueHandle_CallbackVH_Comparisons_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "CallbackVH_Comparisons", __null, __null, (::testing::internal ::GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase , ValueHandle::TearDownTestCase, new ::testing::internal::TestFactoryImpl < ValueHandle_CallbackVH_Comparisons_Test>);void ValueHandle_CallbackVH_Comparisons_Test ::TestBody() { | ||
205 | ConcreteCallbackVH BitcastCVH(BitcastV.get()); | ||
206 | ConcreteCallbackVH ConstantCVH(ConstantV); | ||
207 | |||
208 | EXPECT_TRUE(BitcastCVH == BitcastCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastCVH == BitcastCVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 208, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastCVH == BitcastCVH", "false", "true").c_str()) = ::testing ::Message(); | ||
209 | EXPECT_TRUE(BitcastV.get() == BitcastCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastV.get() == BitcastCVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 209, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastV.get() == BitcastCVH", "false", "true").c_str()) = ::testing::Message(); | ||
210 | EXPECT_TRUE(BitcastCVH == BitcastV.get())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastCVH == BitcastV .get())) ; else ::testing::internal::AssertHelper(::testing:: TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 210, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastCVH == BitcastV.get()", "false", "true").c_str()) = ::testing::Message(); | ||
211 | EXPECT_FALSE(BitcastCVH == ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(BitcastCVH == ConstantCVH ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 211, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastCVH == ConstantCVH", "true", "false").c_str()) = :: testing::Message(); | ||
212 | |||
213 | EXPECT_TRUE(BitcastCVH != ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastCVH != ConstantCVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 213, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastCVH != ConstantCVH", "false", "true").c_str()) = :: testing::Message(); | ||
214 | EXPECT_TRUE(BitcastV.get() != ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastV.get() != ConstantCVH )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 214, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastV.get() != ConstantCVH", "false", "true").c_str()) = ::testing::Message(); | ||
215 | EXPECT_TRUE(BitcastCVH != ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(BitcastCVH != ConstantV )) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 215, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastCVH != ConstantV", "false", "true").c_str()) = ::testing ::Message(); | ||
216 | EXPECT_FALSE(BitcastCVH != BitcastCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(!(BitcastCVH != BitcastCVH ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 216, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "BitcastCVH != BitcastCVH", "true", "false").c_str()) = ::testing ::Message(); | ||
217 | |||
218 | // Cast to Value* so comparisons work. | ||
219 | Value *BV = BitcastV.get(); | ||
220 | Value *CV = ConstantV; | ||
221 | EXPECT_EQ(BV < CV, BitcastCVH < ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastCVH < ConstantCVH", BV < CV, BitcastCVH < ConstantCVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 221, gtest_ar.failure_message()) = ::testing::Message(); | ||
222 | EXPECT_EQ(BV <= CV, BitcastCVH <= ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastCVH <= ConstantCVH", BV <= CV, BitcastCVH <= ConstantCVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 222, gtest_ar.failure_message()) = ::testing::Message(); | ||
223 | EXPECT_EQ(BV > CV, BitcastCVH > ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastCVH > ConstantCVH", BV > CV, BitcastCVH > ConstantCVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 223, gtest_ar.failure_message()) = ::testing::Message(); | ||
224 | EXPECT_EQ(BV >= CV, BitcastCVH >= ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastCVH >= ConstantCVH", BV >= CV, BitcastCVH >= ConstantCVH))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 224, gtest_ar.failure_message()) = ::testing::Message(); | ||
225 | |||
226 | EXPECT_EQ(BV < CV, BitcastV.get() < ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastV.get() < ConstantCVH", BV < CV, BitcastV.get() < ConstantCVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 226, gtest_ar.failure_message()) = ::testing::Message(); | ||
227 | EXPECT_EQ(BV <= CV, BitcastV.get() <= ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastV.get() <= ConstantCVH", BV <= CV , BitcastV.get() <= ConstantCVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 227, gtest_ar.failure_message()) = ::testing::Message(); | ||
228 | EXPECT_EQ(BV > CV, BitcastV.get() > ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastV.get() > ConstantCVH", BV > CV, BitcastV.get() > ConstantCVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 228, gtest_ar.failure_message()) = ::testing::Message(); | ||
229 | EXPECT_EQ(BV >= CV, BitcastV.get() >= ConstantCVH)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastV.get() >= ConstantCVH", BV >= CV , BitcastV.get() >= ConstantCVH))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 229, gtest_ar.failure_message()) = ::testing::Message(); | ||
230 | |||
231 | EXPECT_EQ(BV < CV, BitcastCVH < ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV < CV)) == 1)>::Compare ("BV < CV", "BitcastCVH < ConstantV", BV < CV, BitcastCVH < ConstantV))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 231, gtest_ar.failure_message()) = ::testing::Message(); | ||
232 | EXPECT_EQ(BV <= CV, BitcastCVH <= ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV <= CV)) == 1)>::Compare ("BV <= CV", "BitcastCVH <= ConstantV", BV <= CV, BitcastCVH <= ConstantV))) ; else ::testing::internal::AssertHelper( ::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 232, gtest_ar.failure_message()) = ::testing::Message(); | ||
233 | EXPECT_EQ(BV > CV, BitcastCVH > ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV > CV)) == 1)>::Compare ("BV > CV", "BitcastCVH > ConstantV", BV > CV, BitcastCVH > ConstantV))) ; else ::testing::internal::AssertHelper(:: testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 233, gtest_ar.failure_message()) = ::testing::Message(); | ||
234 | EXPECT_EQ(BV >= CV, BitcastCVH >= ConstantV)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BV >= CV)) == 1)>::Compare ("BV >= CV", "BitcastCVH >= ConstantV", BV >= CV, BitcastCVH >= ConstantV))) ; else ::testing::internal::AssertHelper( ::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 234, gtest_ar.failure_message()) = ::testing::Message(); | ||
235 | } | ||
236 | |||
237 | TEST_F(ValueHandle, CallbackVH_CallbackOnDeletion)class ValueHandle_CallbackVH_CallbackOnDeletion_Test : public ValueHandle { public: ValueHandle_CallbackVH_CallbackOnDeletion_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); ValueHandle_CallbackVH_CallbackOnDeletion_Test (ValueHandle_CallbackVH_CallbackOnDeletion_Test const &); void operator=(ValueHandle_CallbackVH_CallbackOnDeletion_Test const &);};::testing::TestInfo* const ValueHandle_CallbackVH_CallbackOnDeletion_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "CallbackVH_CallbackOnDeletion", __null, __null , (::testing::internal::GetTypeId<ValueHandle>()), ValueHandle ::SetUpTestCase, ValueHandle::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< ValueHandle_CallbackVH_CallbackOnDeletion_Test >);void ValueHandle_CallbackVH_CallbackOnDeletion_Test::TestBody () { | ||
238 | class RecordingVH final : public CallbackVH { | ||
239 | public: | ||
240 | int DeletedCalls; | ||
241 | int AURWCalls; | ||
242 | |||
243 | RecordingVH() : DeletedCalls(0), AURWCalls(0) {} | ||
244 | RecordingVH(Value *V) : CallbackVH(V), DeletedCalls(0), AURWCalls(0) {} | ||
245 | |||
246 | private: | ||
247 | void deleted() override { | ||
248 | DeletedCalls++; | ||
249 | CallbackVH::deleted(); | ||
250 | } | ||
251 | void allUsesReplacedWith(Value *) override { AURWCalls++; } | ||
252 | }; | ||
253 | |||
254 | RecordingVH RVH; | ||
255 | RVH = BitcastV.get(); | ||
256 | EXPECT_EQ(0, RVH.DeletedCalls)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "RVH.DeletedCalls" , 0, RVH.DeletedCalls))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 256, gtest_ar.failure_message()) = ::testing::Message(); | ||
257 | EXPECT_EQ(0, RVH.AURWCalls)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "RVH.AURWCalls" , 0, RVH.AURWCalls))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 257, gtest_ar.failure_message()) = ::testing::Message(); | ||
258 | BitcastV.reset(); | ||
259 | EXPECT_EQ(1, RVH.DeletedCalls)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(1)) == 1)>::Compare("1", "RVH.DeletedCalls" , 1, RVH.DeletedCalls))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 259, gtest_ar.failure_message()) = ::testing::Message(); | ||
260 | EXPECT_EQ(0, RVH.AURWCalls)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "RVH.AURWCalls" , 0, RVH.AURWCalls))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 260, gtest_ar.failure_message()) = ::testing::Message(); | ||
261 | } | ||
262 | |||
263 | TEST_F(ValueHandle, CallbackVH_CallbackOnRAUW)class ValueHandle_CallbackVH_CallbackOnRAUW_Test : public ValueHandle { public: ValueHandle_CallbackVH_CallbackOnRAUW_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_CallbackVH_CallbackOnRAUW_Test (ValueHandle_CallbackVH_CallbackOnRAUW_Test const &); void operator=(ValueHandle_CallbackVH_CallbackOnRAUW_Test const & );};::testing::TestInfo* const ValueHandle_CallbackVH_CallbackOnRAUW_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "CallbackVH_CallbackOnRAUW", __null, __null, ( ::testing::internal::GetTypeId<ValueHandle>()), ValueHandle ::SetUpTestCase, ValueHandle::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< ValueHandle_CallbackVH_CallbackOnRAUW_Test >);void ValueHandle_CallbackVH_CallbackOnRAUW_Test::TestBody () { | ||
264 | class RecordingVH final : public CallbackVH { | ||
265 | public: | ||
266 | int DeletedCalls; | ||
267 | Value *AURWArgument; | ||
268 | |||
269 | RecordingVH() : DeletedCalls(0), AURWArgument(nullptr) {} | ||
270 | RecordingVH(Value *V) | ||
271 | : CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr) {} | ||
272 | |||
273 | private: | ||
274 | void deleted() override { | ||
275 | DeletedCalls++; | ||
276 | CallbackVH::deleted(); | ||
277 | } | ||
278 | void allUsesReplacedWith(Value *new_value) override { | ||
279 | EXPECT_EQ(nullptr, AURWArgument)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(nullptr)) == 1)>::Compare( "nullptr", "AURWArgument", nullptr, AURWArgument))) ; else :: testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 279, gtest_ar.failure_message()) = ::testing::Message(); | ||
280 | AURWArgument = new_value; | ||
281 | } | ||
282 | }; | ||
283 | |||
284 | RecordingVH RVH; | ||
285 | RVH = BitcastV.get(); | ||
286 | EXPECT_EQ(0, RVH.DeletedCalls)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "RVH.DeletedCalls" , 0, RVH.DeletedCalls))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 286, gtest_ar.failure_message()) = ::testing::Message(); | ||
287 | EXPECT_EQ(nullptr, RVH.AURWArgument)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(nullptr)) == 1)>::Compare( "nullptr", "RVH.AURWArgument", nullptr, RVH.AURWArgument))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 287, gtest_ar.failure_message()) = ::testing::Message(); | ||
288 | BitcastV->replaceAllUsesWith(ConstantV); | ||
289 | EXPECT_EQ(0, RVH.DeletedCalls)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(0)) == 1)>::Compare("0", "RVH.DeletedCalls" , 0, RVH.DeletedCalls))) ; else ::testing::internal::AssertHelper (::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 289, gtest_ar.failure_message()) = ::testing::Message(); | ||
290 | EXPECT_EQ(ConstantV, RVH.AURWArgument)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "RVH.AURWArgument", ConstantV, RVH.AURWArgument ))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 290, gtest_ar.failure_message()) = ::testing::Message(); | ||
291 | } | ||
292 | |||
293 | TEST_F(ValueHandle, CallbackVH_DeletionCanRAUW)class ValueHandle_CallbackVH_DeletionCanRAUW_Test : public ValueHandle { public: ValueHandle_CallbackVH_DeletionCanRAUW_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_CallbackVH_DeletionCanRAUW_Test (ValueHandle_CallbackVH_DeletionCanRAUW_Test const &); void operator=(ValueHandle_CallbackVH_DeletionCanRAUW_Test const & );};::testing::TestInfo* const ValueHandle_CallbackVH_DeletionCanRAUW_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "CallbackVH_DeletionCanRAUW", __null, __null, (::testing::internal::GetTypeId<ValueHandle>()), ValueHandle ::SetUpTestCase, ValueHandle::TearDownTestCase, new ::testing ::internal::TestFactoryImpl< ValueHandle_CallbackVH_DeletionCanRAUW_Test >);void ValueHandle_CallbackVH_DeletionCanRAUW_Test::TestBody () { | ||
294 | class RecoveringVH final : public CallbackVH { | ||
295 | public: | ||
296 | int DeletedCalls; | ||
297 | Value *AURWArgument; | ||
298 | LLVMContext *Context; | ||
299 | |||
300 | RecoveringVH() : DeletedCalls(0), AURWArgument(nullptr), | ||
301 | Context(&getGlobalContext()) {} | ||
302 | RecoveringVH(Value *V) | ||
303 | : CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr), | ||
304 | Context(&getGlobalContext()) {} | ||
305 | |||
306 | private: | ||
307 | void deleted() override { | ||
308 | getValPtr()->replaceAllUsesWith(Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))); | ||
309 | setValPtr(nullptr); | ||
310 | } | ||
311 | void allUsesReplacedWith(Value *new_value) override { | ||
312 | ASSERT_TRUE(nullptr != getValPtr())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar_ = ::testing::AssertionResult(nullptr != getValPtr( ))) ; else return ::testing::internal::AssertHelper(::testing ::TestPartResult::kFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 312, ::testing::internal::GetBoolAssertionFailureMessage( gtest_ar_ , "nullptr != getValPtr()", "false", "true").c_str()) = ::testing ::Message(); | ||
313 | EXPECT_EQ(1U, getValPtr()->getNumUses())switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(1U)) == 1)>::Compare("1U", "getValPtr()->getNumUses()", 1U, getValPtr()->getNumUses ()))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 313, gtest_ar.failure_message()) = ::testing::Message(); | ||
314 | EXPECT_EQ(nullptr, AURWArgument)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(nullptr)) == 1)>::Compare( "nullptr", "AURWArgument", nullptr, AURWArgument))) ; else :: testing::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 314, gtest_ar.failure_message()) = ::testing::Message(); | ||
315 | AURWArgument = new_value; | ||
316 | } | ||
317 | }; | ||
318 | |||
319 | // Normally, if a value has uses, deleting it will crash. However, we can use | ||
320 | // a CallbackVH to remove the uses before the check for no uses. | ||
321 | RecoveringVH RVH; | ||
322 | RVH = BitcastV.get(); | ||
323 | std::unique_ptr<BinaryOperator> BitcastUser( | ||
324 | BinaryOperator::CreateAdd(RVH, | ||
325 | Constant::getNullValue(Type::getInt32Ty(getGlobalContext())))); | ||
326 | EXPECT_EQ(BitcastV.get(), BitcastUser->getOperand(0))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(BitcastV.get())) == 1)>::Compare ("BitcastV.get()", "BitcastUser->getOperand(0)", BitcastV. get(), BitcastUser->getOperand(0)))) ; else ::testing::internal ::AssertHelper(::testing::TestPartResult::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 326, gtest_ar.failure_message()) = ::testing::Message(); | ||
327 | BitcastV.reset(); // Would crash without the ValueHandler. | ||
328 | EXPECT_EQ(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())), RVH.AURWArgument)switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(Constant::getNullValue(Type:: getInt32Ty(getGlobalContext())))) == 1)>::Compare("Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))" , "RVH.AURWArgument", Constant::getNullValue(Type::getInt32Ty (getGlobalContext())), RVH.AURWArgument))) ; else ::testing:: internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 328, gtest_ar.failure_message()) = ::testing::Message(); | ||
329 | EXPECT_EQ(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())),switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(Constant::getNullValue(Type:: getInt32Ty(getGlobalContext())))) == 1)>::Compare("Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))" , "BitcastUser->getOperand(0)", Constant::getNullValue(Type ::getInt32Ty(getGlobalContext())), BitcastUser->getOperand (0)))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 330, gtest_ar.failure_message()) = ::testing::Message() | ||
330 | BitcastUser->getOperand(0))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(Constant::getNullValue(Type:: getInt32Ty(getGlobalContext())))) == 1)>::Compare("Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))" , "BitcastUser->getOperand(0)", Constant::getNullValue(Type ::getInt32Ty(getGlobalContext())), BitcastUser->getOperand (0)))) ; else ::testing::internal::AssertHelper(::testing::TestPartResult ::kNonFatalFailure, "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 330, gtest_ar.failure_message()) = ::testing::Message(); | ||
331 | } | ||
332 | |||
333 | TEST_F(ValueHandle, DestroyingOtherVHOnSameValueDoesntBreakIteration)class ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test : public ValueHandle { public: ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test () {} private: virtual void TestBody(); static ::testing::TestInfo * const test_info_ __attribute__ ((unused)); ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test (ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test const &); void operator=(ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test const &);};::testing::TestInfo* const ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle", "DestroyingOtherVHOnSameValueDoesntBreakIteration" , __null, __null, (::testing::internal::GetTypeId<ValueHandle >()), ValueHandle::SetUpTestCase, ValueHandle::TearDownTestCase , new ::testing::internal::TestFactoryImpl< ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test >);void ValueHandle_DestroyingOtherVHOnSameValueDoesntBreakIteration_Test ::TestBody() { | ||
334 | // When a CallbackVH modifies other ValueHandles in its callbacks, | ||
335 | // that shouldn't interfere with non-modified ValueHandles receiving | ||
336 | // their appropriate callbacks. | ||
337 | // | ||
338 | // We create the active CallbackVH in the middle of a palindromic | ||
339 | // arrangement of other VHs so that the bad behavior would be | ||
340 | // triggered in whichever order callbacks run. | ||
341 | |||
342 | class DestroyingVH final : public CallbackVH { | ||
343 | public: | ||
344 | std::unique_ptr<WeakVH> ToClear[2]; | ||
345 | DestroyingVH(Value *V) { | ||
346 | ToClear[0].reset(new WeakVH(V)); | ||
347 | setValPtr(V); | ||
348 | ToClear[1].reset(new WeakVH(V)); | ||
349 | } | ||
350 | void deleted() override { | ||
351 | ToClear[0].reset(); | ||
352 | ToClear[1].reset(); | ||
353 | CallbackVH::deleted(); | ||
354 | } | ||
355 | void allUsesReplacedWith(Value *) override { | ||
356 | ToClear[0].reset(); | ||
357 | ToClear[1].reset(); | ||
358 | } | ||
359 | }; | ||
360 | |||
361 | { | ||
362 | WeakVH ShouldBeVisited1(BitcastV.get()); | ||
363 | DestroyingVH C(BitcastV.get()); | ||
364 | WeakVH ShouldBeVisited2(BitcastV.get()); | ||
365 | |||
366 | BitcastV->replaceAllUsesWith(ConstantV); | ||
367 | EXPECT_EQ(ConstantV, static_cast<Value*>(ShouldBeVisited1))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "static_cast<Value*>(ShouldBeVisited1)", ConstantV , static_cast<Value*>(ShouldBeVisited1)))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 367, gtest_ar.failure_message()) = ::testing::Message(); | ||
368 | EXPECT_EQ(ConstantV, static_cast<Value*>(ShouldBeVisited2))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(ConstantV)) == 1)>::Compare ("ConstantV", "static_cast<Value*>(ShouldBeVisited2)", ConstantV , static_cast<Value*>(ShouldBeVisited2)))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 368, gtest_ar.failure_message()) = ::testing::Message(); | ||
369 | } | ||
370 | |||
371 | { | ||
372 | WeakVH ShouldBeVisited1(BitcastV.get()); | ||
373 | DestroyingVH C(BitcastV.get()); | ||
374 | WeakVH ShouldBeVisited2(BitcastV.get()); | ||
375 | |||
376 | BitcastV.reset(); | ||
377 | EXPECT_EQ(nullptr, static_cast<Value*>(ShouldBeVisited1))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(nullptr)) == 1)>::Compare( "nullptr", "static_cast<Value*>(ShouldBeVisited1)", nullptr , static_cast<Value*>(ShouldBeVisited1)))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 377, gtest_ar.failure_message()) = ::testing::Message(); | ||
378 | EXPECT_EQ(nullptr, static_cast<Value*>(ShouldBeVisited2))switch (0) case 0: default: if (const ::testing::AssertionResult gtest_ar = (::testing::internal:: EqHelper<(sizeof(::testing ::internal::IsNullLiteralHelper(nullptr)) == 1)>::Compare( "nullptr", "static_cast<Value*>(ShouldBeVisited2)", nullptr , static_cast<Value*>(ShouldBeVisited2)))) ; else ::testing ::internal::AssertHelper(::testing::TestPartResult::kNonFatalFailure , "/tmp/buildd/llvm-toolchain-snapshot-3.8~svn255820/unittests/IR/ValueHandleTest.cpp" , 378, gtest_ar.failure_message()) = ::testing::Message(); | ||
379 | } | ||
380 | } | ||
381 | |||
382 | TEST_F(ValueHandle, AssertingVHCheckedLast)class ValueHandle_AssertingVHCheckedLast_Test : public ValueHandle { public: ValueHandle_AssertingVHCheckedLast_Test() {} private : virtual void TestBody(); static ::testing::TestInfo* const test_info_ __attribute__ ((unused)); ValueHandle_AssertingVHCheckedLast_Test (ValueHandle_AssertingVHCheckedLast_Test const &); void operator =(ValueHandle_AssertingVHCheckedLast_Test const &);};::testing ::TestInfo* const ValueHandle_AssertingVHCheckedLast_Test ::test_info_ = ::testing::internal::MakeAndRegisterTestInfo( "ValueHandle" , "AssertingVHCheckedLast", __null, __null, (::testing::internal ::GetTypeId<ValueHandle>()), ValueHandle::SetUpTestCase , ValueHandle::TearDownTestCase, new ::testing::internal::TestFactoryImpl < ValueHandle_AssertingVHCheckedLast_Test>);void ValueHandle_AssertingVHCheckedLast_Test ::TestBody() { | ||
383 | // If a CallbackVH exists to clear out a group of AssertingVHs on | ||
384 | // Value deletion, the CallbackVH should get a chance to do so | ||
385 | // before the AssertingVHs assert. | ||
386 | |||
387 | class ClearingVH final : public CallbackVH { | ||
388 | public: | ||
389 | AssertingVH<Value> *ToClear[2]; | ||
390 | ClearingVH(Value *V, | ||
391 | AssertingVH<Value> &A0, AssertingVH<Value> &A1) | ||
392 | : CallbackVH(V) { | ||
393 | ToClear[0] = &A0; | ||
394 | ToClear[1] = &A1; | ||
395 | } | ||
396 | |||
397 | void deleted() override { | ||
398 | *ToClear[0] = nullptr; | ||
399 | *ToClear[1] = nullptr; | ||
400 | CallbackVH::deleted(); | ||
401 | } | ||
402 | }; | ||
403 | |||
404 | AssertingVH<Value> A1, A2; | ||
405 | A1 = BitcastV.get(); | ||
406 | ClearingVH C(BitcastV.get(), A1, A2); | ||
407 | A2 = BitcastV.get(); | ||
408 | // C.deleted() should run first, clearing the two AssertingVHs, | ||
409 | // which should prevent them from asserting. | ||
410 | BitcastV.reset(); | ||
411 | } | ||
412 | |||
413 | } |