diff options
author | Stephen Hines <srhines@google.com> | 2014-07-21 00:45:20 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-07-21 00:45:20 -0700 |
commit | c6a4f5e819217e1e12c458aed8e7b122e23a3a58 (patch) | |
tree | 81b7dd2bb4370a392f31d332a566c903b5744764 /unittests/IR | |
parent | 19c6fbb3e8aaf74093afa08013134b61fa08f245 (diff) | |
download | external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.zip external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.gz external_llvm-c6a4f5e819217e1e12c458aed8e7b122e23a3a58.tar.bz2 |
Update LLVM for rebase to r212749.
Includes a cherry-pick of:
r212948 - fixes a small issue with atomic calls
Change-Id: Ib97bd980b59f18142a69506400911a6009d9df18
Diffstat (limited to 'unittests/IR')
-rw-r--r-- | unittests/IR/ConstantRangeTest.cpp | 8 | ||||
-rw-r--r-- | unittests/IR/ConstantsTest.cpp | 10 | ||||
-rw-r--r-- | unittests/IR/DominatorTreeTest.cpp | 2 | ||||
-rw-r--r-- | unittests/IR/IRBuilderTest.cpp | 10 | ||||
-rw-r--r-- | unittests/IR/InstructionsTest.cpp | 16 | ||||
-rw-r--r-- | unittests/IR/LegacyPassManagerTest.cpp | 14 | ||||
-rw-r--r-- | unittests/IR/MDBuilderTest.cpp | 14 | ||||
-rw-r--r-- | unittests/IR/MetadataTest.cpp | 2 | ||||
-rw-r--r-- | unittests/IR/PassManagerTest.cpp | 2 | ||||
-rw-r--r-- | unittests/IR/PatternMatch.cpp | 12 | ||||
-rw-r--r-- | unittests/IR/TypeBuilderTest.cpp | 6 | ||||
-rw-r--r-- | unittests/IR/UserTest.cpp | 2 | ||||
-rw-r--r-- | unittests/IR/ValueHandleTest.cpp | 32 | ||||
-rw-r--r-- | unittests/IR/ValueMapTest.cpp | 38 | ||||
-rw-r--r-- | unittests/IR/ValueTest.cpp | 6 | ||||
-rw-r--r-- | unittests/IR/VerifierTest.cpp | 17 | ||||
-rw-r--r-- | unittests/IR/WaymarkTest.cpp | 2 |
17 files changed, 83 insertions, 110 deletions
diff --git a/unittests/IR/ConstantRangeTest.cpp b/unittests/IR/ConstantRangeTest.cpp index cdf7378..fa03302 100644 --- a/unittests/IR/ConstantRangeTest.cpp +++ b/unittests/IR/ConstantRangeTest.cpp @@ -99,11 +99,11 @@ TEST_F(ConstantRangeTest, Equality) { } TEST_F(ConstantRangeTest, SingleElement) { - EXPECT_EQ(Full.getSingleElement(), static_cast<APInt *>(NULL)); - EXPECT_EQ(Empty.getSingleElement(), static_cast<APInt *>(NULL)); + EXPECT_EQ(Full.getSingleElement(), static_cast<APInt *>(nullptr)); + EXPECT_EQ(Empty.getSingleElement(), static_cast<APInt *>(nullptr)); EXPECT_EQ(*One.getSingleElement(), APInt(16, 0xa)); - EXPECT_EQ(Some.getSingleElement(), static_cast<APInt *>(NULL)); - EXPECT_EQ(Wrap.getSingleElement(), static_cast<APInt *>(NULL)); + EXPECT_EQ(Some.getSingleElement(), static_cast<APInt *>(nullptr)); + EXPECT_EQ(Wrap.getSingleElement(), static_cast<APInt *>(nullptr)); EXPECT_FALSE(Full.isSingleElement()); EXPECT_FALSE(Empty.isSingleElement()); diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp index c11729c..0cd8549 100644 --- a/unittests/IR/ConstantsTest.cpp +++ b/unittests/IR/ConstantsTest.cpp @@ -269,16 +269,6 @@ TEST(ConstantsTest, ReplaceWithConstantTest) { "this->replaceAllUsesWith\\(expr\\(this\\)\\) is NOT valid!"); } -TEST(ConstantsTest, ReplaceInAliasTest) { - std::unique_ptr<Module> M(new Module("MyModule", getGlobalContext())); - - Type *Int32Ty = Type::getInt32Ty(getGlobalContext()); - auto *Global = cast<GlobalObject>(M->getOrInsertGlobal("dummy", Int32Ty)); - auto *GA = GlobalAlias::create(GlobalValue::ExternalLinkage, "alias", Global); - EXPECT_DEATH(Global->replaceAllUsesWith(GA), - "replaceAliasUseWith cannot form an alias cycle"); -} - #endif #endif diff --git a/unittests/IR/DominatorTreeTest.cpp b/unittests/IR/DominatorTreeTest.cpp index 98c2317..ab43d1c 100644 --- a/unittests/IR/DominatorTreeTest.cpp +++ b/unittests/IR/DominatorTreeTest.cpp @@ -213,7 +213,7 @@ namespace llvm { "}\n"; LLVMContext &C = getGlobalContext(); SMDiagnostic Err; - return ParseAssemblyString(ModuleStrig, NULL, Err, C); + return ParseAssemblyString(ModuleStrig, nullptr, Err, C); } TEST(DominatorTree, Unreachable) { diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp index 9796e44..2108575 100644 --- a/unittests/IR/IRBuilderTest.cpp +++ b/unittests/IR/IRBuilderTest.cpp @@ -31,11 +31,11 @@ protected: F = Function::Create(FTy, Function::ExternalLinkage, "", M.get()); BB = BasicBlock::Create(Ctx, "", F); GV = new GlobalVariable(*M, Type::getFloatTy(Ctx), true, - GlobalValue::ExternalLinkage, 0); + GlobalValue::ExternalLinkage, nullptr); } virtual void TearDown() { - BB = 0; + BB = nullptr; M.reset(); } @@ -71,9 +71,9 @@ TEST_F(IRBuilderTest, Lifetime) { IntrinsicInst *II_Start1 = dyn_cast<IntrinsicInst>(Start1); IntrinsicInst *II_End1 = dyn_cast<IntrinsicInst>(End1); - ASSERT_TRUE(II_Start1 != NULL); + ASSERT_TRUE(II_Start1 != nullptr); EXPECT_EQ(II_Start1->getIntrinsicID(), Intrinsic::lifetime_start); - ASSERT_TRUE(II_End1 != NULL); + ASSERT_TRUE(II_End1 != nullptr); EXPECT_EQ(II_End1->getIntrinsicID(), Intrinsic::lifetime_end); } @@ -203,7 +203,7 @@ TEST_F(IRBuilderTest, WrapFlags) { // Test instructions. GlobalVariable *G = new GlobalVariable(*M, Builder.getInt32Ty(), true, - GlobalValue::ExternalLinkage, 0); + GlobalValue::ExternalLinkage, nullptr); Value *V = Builder.CreateLoad(G); EXPECT_TRUE( cast<BinaryOperator>(Builder.CreateNSWAdd(V, V))->hasNoSignedWrap()); diff --git a/unittests/IR/InstructionsTest.cpp b/unittests/IR/InstructionsTest.cpp index 336f5a2..7ec9b62 100644 --- a/unittests/IR/InstructionsTest.cpp +++ b/unittests/IR/InstructionsTest.cpp @@ -415,7 +415,7 @@ TEST(InstructionsTest, isEliminableCastPair) { EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt, CastInst::IntToPtr, Int64PtrTy, Int64Ty, Int64PtrTy, - Int32Ty, 0, Int32Ty), + Int32Ty, nullptr, Int32Ty), CastInst::BitCast); // Source and destination have unknown sizes, but the same address space and @@ -423,7 +423,7 @@ TEST(InstructionsTest, isEliminableCastPair) { EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt, CastInst::IntToPtr, Int64PtrTy, Int64Ty, Int64PtrTy, - 0, 0, 0), + nullptr, nullptr, nullptr), CastInst::BitCast); // Source and destination have unknown sizes, but the same address space and @@ -431,21 +431,21 @@ TEST(InstructionsTest, isEliminableCastPair) { EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt, CastInst::IntToPtr, Int64PtrTy, Int32Ty, Int64PtrTy, - 0, 0, 0), + nullptr, nullptr, nullptr), 0U); // Middle pointer big enough -> bitcast. EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr, CastInst::PtrToInt, Int64Ty, Int64PtrTy, Int64Ty, - 0, Int64Ty, 0), + nullptr, Int64Ty, nullptr), CastInst::BitCast); // Middle pointer too small -> fail. EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr, CastInst::PtrToInt, Int64Ty, Int64PtrTy, Int64Ty, - 0, Int32Ty, 0), + nullptr, Int32Ty, nullptr), 0U); // Test that we don't eliminate bitcasts between different address spaces, @@ -464,21 +464,21 @@ TEST(InstructionsTest, isEliminableCastPair) { EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr, CastInst::AddrSpaceCast, Int16Ty, Int64PtrTyAS1, Int64PtrTyAS2, - 0, Int16SizePtr, Int64SizePtr), + nullptr, Int16SizePtr, Int64SizePtr), 0U); // Cannot simplify addrspacecast, ptrtoint EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::AddrSpaceCast, CastInst::PtrToInt, Int64PtrTyAS1, Int64PtrTyAS2, Int16Ty, - Int64SizePtr, Int16SizePtr, 0), + Int64SizePtr, Int16SizePtr, nullptr), 0U); // Pass since the bitcast address spaces are the same EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr, CastInst::BitCast, Int16Ty, Int64PtrTyAS1, Int64PtrTyAS1, - 0, 0, 0), + nullptr, nullptr, nullptr), CastInst::IntToPtr); } diff --git a/unittests/IR/LegacyPassManagerTest.cpp b/unittests/IR/LegacyPassManagerTest.cpp index df6f460..9c2a835 100644 --- a/unittests/IR/LegacyPassManagerTest.cpp +++ b/unittests/IR/LegacyPassManagerTest.cpp @@ -476,7 +476,7 @@ namespace llvm { // Function: test1 (func_test1) { - BasicBlock* label_entry = BasicBlock::Create(getGlobalContext(), "entry",func_test1,0); + BasicBlock* label_entry = BasicBlock::Create(getGlobalContext(), "entry",func_test1,nullptr); // Block entry (label_entry) CallInst* int32_3 = CallInst::Create(func_test2, "", label_entry); @@ -491,7 +491,7 @@ namespace llvm { // Function: test2 (func_test2) { - BasicBlock* label_entry_5 = BasicBlock::Create(getGlobalContext(), "entry",func_test2,0); + BasicBlock* label_entry_5 = BasicBlock::Create(getGlobalContext(), "entry",func_test2,nullptr); // Block entry (label_entry_5) CallInst* int32_6 = CallInst::Create(func_test3, "", label_entry_5); @@ -506,7 +506,7 @@ namespace llvm { // Function: test3 (func_test3) { - BasicBlock* label_entry_8 = BasicBlock::Create(getGlobalContext(), "entry",func_test3,0); + BasicBlock* label_entry_8 = BasicBlock::Create(getGlobalContext(), "entry",func_test3,nullptr); // Block entry (label_entry_8) CallInst* int32_9 = CallInst::Create(func_test1, "", label_entry_8); @@ -524,10 +524,10 @@ namespace llvm { Value* int1_f = args++; int1_f->setName("f"); - BasicBlock* label_entry_11 = BasicBlock::Create(getGlobalContext(), "entry",func_test4,0); - BasicBlock* label_bb = BasicBlock::Create(getGlobalContext(), "bb",func_test4,0); - BasicBlock* label_bb1 = BasicBlock::Create(getGlobalContext(), "bb1",func_test4,0); - BasicBlock* label_return = BasicBlock::Create(getGlobalContext(), "return",func_test4,0); + BasicBlock* label_entry_11 = BasicBlock::Create(getGlobalContext(), "entry",func_test4,nullptr); + BasicBlock* label_bb = BasicBlock::Create(getGlobalContext(), "bb",func_test4,nullptr); + BasicBlock* label_bb1 = BasicBlock::Create(getGlobalContext(), "bb1",func_test4,nullptr); + BasicBlock* label_return = BasicBlock::Create(getGlobalContext(), "return",func_test4,nullptr); // Block entry (label_entry_11) BranchInst::Create(label_bb, label_entry_11); diff --git a/unittests/IR/MDBuilderTest.cpp b/unittests/IR/MDBuilderTest.cpp index c8b5a09..fc4674e 100644 --- a/unittests/IR/MDBuilderTest.cpp +++ b/unittests/IR/MDBuilderTest.cpp @@ -33,8 +33,8 @@ TEST_F(MDBuilderTest, createFPMath) { MDBuilder MDHelper(Context); MDNode *MD0 = MDHelper.createFPMath(0.0); MDNode *MD1 = MDHelper.createFPMath(1.0); - EXPECT_EQ(MD0, (MDNode *)0); - EXPECT_NE(MD1, (MDNode *)0); + EXPECT_EQ(MD0, (MDNode *)nullptr); + EXPECT_NE(MD1, (MDNode *)nullptr); EXPECT_EQ(MD1->getNumOperands(), 1U); Value *Op = MD1->getOperand(0); EXPECT_TRUE(isa<ConstantFP>(Op)); @@ -47,8 +47,8 @@ TEST_F(MDBuilderTest, createRangeMetadata) { APInt A(8, 1), B(8, 2); MDNode *R0 = MDHelper.createRange(A, A); MDNode *R1 = MDHelper.createRange(A, B); - EXPECT_EQ(R0, (MDNode *)0); - EXPECT_NE(R1, (MDNode *)0); + EXPECT_EQ(R0, (MDNode *)nullptr); + EXPECT_NE(R1, (MDNode *)nullptr); EXPECT_EQ(R1->getNumOperands(), 2U); EXPECT_TRUE(isa<ConstantInt>(R1->getOperand(0))); EXPECT_TRUE(isa<ConstantInt>(R1->getOperand(1))); @@ -66,8 +66,8 @@ TEST_F(MDBuilderTest, createAnonymousTBAARoot) { EXPECT_GE(R1->getNumOperands(), 1U); EXPECT_EQ(R0->getOperand(0), R0); EXPECT_EQ(R1->getOperand(0), R1); - EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == 0); - EXPECT_TRUE(R1->getNumOperands() == 1 || R1->getOperand(1) == 0); + EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == nullptr); + EXPECT_TRUE(R1->getNumOperands() == 1 || R1->getOperand(1) == nullptr); } TEST_F(MDBuilderTest, createTBAARoot) { MDBuilder MDHelper(Context); @@ -77,7 +77,7 @@ TEST_F(MDBuilderTest, createTBAARoot) { EXPECT_GE(R0->getNumOperands(), 1U); EXPECT_TRUE(isa<MDString>(R0->getOperand(0))); EXPECT_EQ(cast<MDString>(R0->getOperand(0))->getString(), "Root"); - EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == 0); + EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == nullptr); } TEST_F(MDBuilderTest, createTBAANode) { MDBuilder MDHelper(Context); diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index 00a2783..4f7bd72 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -103,7 +103,7 @@ TEST_F(MDNodeTest, Simple) { #endif EXPECT_EQ(n4, n1); EXPECT_EQ(n5, n2); - EXPECT_EQ(n6, (Value*)0); + EXPECT_EQ(n6, (Value*)nullptr); EXPECT_EQ(3u, n1->getNumOperands()); EXPECT_EQ(s1, n1->getOperand(0)); diff --git a/unittests/IR/PassManagerTest.cpp b/unittests/IR/PassManagerTest.cpp index 310e48f..25037a7 100644 --- a/unittests/IR/PassManagerTest.cpp +++ b/unittests/IR/PassManagerTest.cpp @@ -168,7 +168,7 @@ struct TestInvalidationFunctionPass { Module *parseIR(const char *IR) { LLVMContext &C = getGlobalContext(); SMDiagnostic Err; - return ParseAssemblyString(IR, 0, Err, C); + return ParseAssemblyString(IR, nullptr, Err, C); } class PassManagerTest : public ::testing::Test { diff --git a/unittests/IR/PatternMatch.cpp b/unittests/IR/PatternMatch.cpp index bebee15..f3a27b8 100644 --- a/unittests/IR/PatternMatch.cpp +++ b/unittests/IR/PatternMatch.cpp @@ -230,17 +230,17 @@ TEST_F(PatternMatchTest, OverflowingBinOps) { m_NSWAdd(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNSWAdd(L, R))); EXPECT_EQ(L, MatchL); EXPECT_EQ(R, MatchR); - MatchL = MatchR = 0; + MatchL = MatchR = nullptr; EXPECT_TRUE( m_NSWSub(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNSWSub(L, R))); EXPECT_EQ(L, MatchL); EXPECT_EQ(R, MatchR); - MatchL = MatchR = 0; + MatchL = MatchR = nullptr; EXPECT_TRUE( m_NSWMul(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNSWMul(L, R))); EXPECT_EQ(L, MatchL); EXPECT_EQ(R, MatchR); - MatchL = MatchR = 0; + MatchL = MatchR = nullptr; EXPECT_TRUE(m_NSWShl(m_Value(MatchL), m_Value(MatchR)).match( IRB.CreateShl(L, R, "", /* NUW */ false, /* NSW */ true))); EXPECT_EQ(L, MatchL); @@ -250,17 +250,17 @@ TEST_F(PatternMatchTest, OverflowingBinOps) { m_NUWAdd(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNUWAdd(L, R))); EXPECT_EQ(L, MatchL); EXPECT_EQ(R, MatchR); - MatchL = MatchR = 0; + MatchL = MatchR = nullptr; EXPECT_TRUE( m_NUWSub(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNUWSub(L, R))); EXPECT_EQ(L, MatchL); EXPECT_EQ(R, MatchR); - MatchL = MatchR = 0; + MatchL = MatchR = nullptr; EXPECT_TRUE( m_NUWMul(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNUWMul(L, R))); EXPECT_EQ(L, MatchL); EXPECT_EQ(R, MatchR); - MatchL = MatchR = 0; + MatchL = MatchR = nullptr; EXPECT_TRUE(m_NUWShl(m_Value(MatchL), m_Value(MatchR)).match( IRB.CreateShl(L, R, "", /* NUW */ true, /* NSW */ false))); EXPECT_EQ(L, MatchL); diff --git a/unittests/IR/TypeBuilderTest.cpp b/unittests/IR/TypeBuilderTest.cpp index be493cd..b7b3e45 100644 --- a/unittests/IR/TypeBuilderTest.cpp +++ b/unittests/IR/TypeBuilderTest.cpp @@ -234,19 +234,19 @@ TEST(TypeBuilderTest, Extensions) { TypeBuilder<int, false>::get(getGlobalContext()), TypeBuilder<int*, false>::get(getGlobalContext()), TypeBuilder<void*[], false>::get(getGlobalContext()), - (void*)0)), + (void*)nullptr)), (TypeBuilder<MyType*, false>::get(getGlobalContext()))); EXPECT_EQ(PointerType::getUnqual(StructType::get( TypeBuilder<types::i<32>, false>::get(getGlobalContext()), TypeBuilder<types::i<32>*, false>::get(getGlobalContext()), TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()), - (void*)0)), + (void*)nullptr)), (TypeBuilder<MyPortableType*, false>::get(getGlobalContext()))); EXPECT_EQ(PointerType::getUnqual(StructType::get( TypeBuilder<types::i<32>, false>::get(getGlobalContext()), TypeBuilder<types::i<32>*, false>::get(getGlobalContext()), TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()), - (void*)0)), + (void*)nullptr)), (TypeBuilder<MyPortableType*, true>::get(getGlobalContext()))); } diff --git a/unittests/IR/UserTest.cpp b/unittests/IR/UserTest.cpp index 9c0e7b2..eb07e82 100644 --- a/unittests/IR/UserTest.cpp +++ b/unittests/IR/UserTest.cpp @@ -65,7 +65,7 @@ TEST(UserTest, ValueOpIteration) { " ret void\n" "}\n"; SMDiagnostic Err; - Module *M = ParseAssemblyString(ModuleString, NULL, Err, C); + Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C); Function *F = M->getFunction("f"); BasicBlock &ExitBB = F->back(); diff --git a/unittests/IR/ValueHandleTest.cpp b/unittests/IR/ValueHandleTest.cpp index 15a0c22..403d2bc 100644 --- a/unittests/IR/ValueHandleTest.cpp +++ b/unittests/IR/ValueHandleTest.cpp @@ -94,7 +94,7 @@ TEST_F(ValueHandle, WeakVH_NullOnDeletion) { WeakVH WVH_Copy(WVH); WeakVH WVH_Recreated(BitcastV.get()); BitcastV.reset(); - Value *null_value = NULL; + Value *null_value = nullptr; EXPECT_EQ(null_value, WVH); EXPECT_EQ(null_value, WVH_Copy); EXPECT_EQ(null_value, WVH_Recreated); @@ -178,10 +178,10 @@ TEST_F(ValueHandle, AssertingVH_Asserts) { EXPECT_DEATH({BitcastV.reset();}, "An asserting value handle still pointed to this value!"); AssertingVH<Value> Copy(AVH); - AVH = NULL; + AVH = nullptr; EXPECT_DEATH({BitcastV.reset();}, "An asserting value handle still pointed to this value!"); - Copy = NULL; + Copy = nullptr; BitcastV.reset(); } @@ -263,14 +263,14 @@ TEST_F(ValueHandle, CallbackVH_CallbackOnRAUW) { int DeletedCalls; Value *AURWArgument; - RecordingVH() : DeletedCalls(0), AURWArgument(NULL) {} + RecordingVH() : DeletedCalls(0), AURWArgument(nullptr) {} RecordingVH(Value *V) - : CallbackVH(V), DeletedCalls(0), AURWArgument(NULL) {} + : CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr) {} private: virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); } virtual void allUsesReplacedWith(Value *new_value) { - EXPECT_EQ(NULL, AURWArgument); + EXPECT_EQ(nullptr, AURWArgument); AURWArgument = new_value; } }; @@ -278,7 +278,7 @@ TEST_F(ValueHandle, CallbackVH_CallbackOnRAUW) { RecordingVH RVH; RVH = BitcastV.get(); EXPECT_EQ(0, RVH.DeletedCalls); - EXPECT_EQ(NULL, RVH.AURWArgument); + EXPECT_EQ(nullptr, RVH.AURWArgument); BitcastV->replaceAllUsesWith(ConstantV); EXPECT_EQ(0, RVH.DeletedCalls); EXPECT_EQ(ConstantV, RVH.AURWArgument); @@ -291,21 +291,21 @@ TEST_F(ValueHandle, CallbackVH_DeletionCanRAUW) { Value *AURWArgument; LLVMContext *Context; - RecoveringVH() : DeletedCalls(0), AURWArgument(NULL), + RecoveringVH() : DeletedCalls(0), AURWArgument(nullptr), Context(&getGlobalContext()) {} RecoveringVH(Value *V) - : CallbackVH(V), DeletedCalls(0), AURWArgument(NULL), + : CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr), Context(&getGlobalContext()) {} private: virtual void deleted() { getValPtr()->replaceAllUsesWith(Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))); - setValPtr(NULL); + setValPtr(nullptr); } virtual void allUsesReplacedWith(Value *new_value) { - ASSERT_TRUE(NULL != getValPtr()); + ASSERT_TRUE(nullptr != getValPtr()); EXPECT_EQ(1U, getValPtr()->getNumUses()); - EXPECT_EQ(NULL, AURWArgument); + EXPECT_EQ(nullptr, AURWArgument); AURWArgument = new_value; } }; @@ -368,8 +368,8 @@ TEST_F(ValueHandle, DestroyingOtherVHOnSameValueDoesntBreakIteration) { WeakVH ShouldBeVisited2(BitcastV.get()); BitcastV.reset(); - EXPECT_EQ(NULL, static_cast<Value*>(ShouldBeVisited1)); - EXPECT_EQ(NULL, static_cast<Value*>(ShouldBeVisited2)); + EXPECT_EQ(nullptr, static_cast<Value*>(ShouldBeVisited1)); + EXPECT_EQ(nullptr, static_cast<Value*>(ShouldBeVisited2)); } } @@ -389,8 +389,8 @@ TEST_F(ValueHandle, AssertingVHCheckedLast) { } virtual void deleted() { - *ToClear[0] = 0; - *ToClear[1] = 0; + *ToClear[0] = nullptr; + *ToClear[1] = nullptr; CallbackVH::deleted(); } }; diff --git a/unittests/IR/ValueMapTest.cpp b/unittests/IR/ValueMapTest.cpp index 6fd87b1..0b7198f 100644 --- a/unittests/IR/ValueMapTest.cpp +++ b/unittests/IR/ValueMapTest.cpp @@ -40,21 +40,21 @@ TYPED_TEST_CASE(ValueMapTest, KeyTypes); TYPED_TEST(ValueMapTest, Null) { ValueMap<TypeParam*, int> VM1; - VM1[NULL] = 7; - EXPECT_EQ(7, VM1.lookup(NULL)); + VM1[nullptr] = 7; + EXPECT_EQ(7, VM1.lookup(nullptr)); } TYPED_TEST(ValueMapTest, FollowsValue) { ValueMap<TypeParam*, int> VM; VM[this->BitcastV.get()] = 7; EXPECT_EQ(7, VM.lookup(this->BitcastV.get())); - EXPECT_EQ(0, VM.count(this->AddV.get())); + EXPECT_EQ(0u, VM.count(this->AddV.get())); this->BitcastV->replaceAllUsesWith(this->AddV.get()); EXPECT_EQ(7, VM.lookup(this->AddV.get())); - EXPECT_EQ(0, VM.count(this->BitcastV.get())); + EXPECT_EQ(0u, VM.count(this->BitcastV.get())); this->AddV.reset(); - EXPECT_EQ(0, VM.count(this->AddV.get())); - EXPECT_EQ(0, VM.count(this->BitcastV.get())); + EXPECT_EQ(0u, VM.count(this->AddV.get())); + EXPECT_EQ(0u, VM.count(this->BitcastV.get())); EXPECT_EQ(0U, VM.size()); } @@ -90,7 +90,7 @@ TYPED_TEST(ValueMapTest, OperationsWork) { EXPECT_EQ(this->AddV.get(), InsertResult1.first->first); EXPECT_EQ(3, InsertResult1.first->second); EXPECT_TRUE(InsertResult1.second); - EXPECT_EQ(true, VM.count(this->AddV.get())); + EXPECT_EQ(1u, VM.count(this->AddV.get())); std::pair<typename ValueMap<TypeParam*, int>::iterator, bool> InsertResult2 = VM.insert(std::make_pair(this->AddV.get(), 5)); EXPECT_EQ(this->AddV.get(), InsertResult2.first->first); @@ -169,7 +169,7 @@ TYPED_TEST(ValueMapTest, DefaultCollisionBehavior) { VM[this->BitcastV.get()] = 7; VM[this->AddV.get()] = 9; this->BitcastV->replaceAllUsesWith(this->AddV.get()); - EXPECT_EQ(0, VM.count(this->BitcastV.get())); + EXPECT_EQ(0u, VM.count(this->BitcastV.get())); EXPECT_EQ(9, VM.lookup(this->AddV.get())); } @@ -177,10 +177,10 @@ TYPED_TEST(ValueMapTest, ConfiguredCollisionBehavior) { // TODO: Implement this when someone needs it. } -template<typename KeyT> -struct LockMutex : ValueMapConfig<KeyT> { +template<typename KeyT, typename MutexT> +struct LockMutex : ValueMapConfig<KeyT, MutexT> { struct ExtraData { - sys::Mutex *M; + MutexT *M; bool *CalledRAUW; bool *CalledDeleted; }; @@ -192,15 +192,15 @@ struct LockMutex : ValueMapConfig<KeyT> { *Data.CalledDeleted = true; EXPECT_FALSE(Data.M->tryacquire()) << "Mutex should already be locked."; } - static sys::Mutex *getMutex(const ExtraData &Data) { return Data.M; } + static MutexT *getMutex(const ExtraData &Data) { return Data.M; } }; #if LLVM_ENABLE_THREADS TYPED_TEST(ValueMapTest, LocksMutex) { sys::Mutex M(false); // Not recursive. bool CalledRAUW = false, CalledDeleted = false; - typename LockMutex<TypeParam*>::ExtraData Data = - {&M, &CalledRAUW, &CalledDeleted}; - ValueMap<TypeParam*, int, LockMutex<TypeParam*> > VM(Data); + typedef LockMutex<TypeParam*, sys::Mutex> ConfigType; + typename ConfigType::ExtraData Data = {&M, &CalledRAUW, &CalledDeleted}; + ValueMap<TypeParam*, int, ConfigType> VM(Data); VM[this->BitcastV.get()] = 7; this->BitcastV->replaceAllUsesWith(this->AddV.get()); this->AddV.reset(); @@ -218,7 +218,7 @@ TYPED_TEST(ValueMapTest, NoFollowRAUW) { ValueMap<TypeParam*, int, NoFollow<TypeParam*> > VM; VM[this->BitcastV.get()] = 7; EXPECT_EQ(7, VM.lookup(this->BitcastV.get())); - EXPECT_EQ(0, VM.count(this->AddV.get())); + EXPECT_EQ(0u, VM.count(this->AddV.get())); this->BitcastV->replaceAllUsesWith(this->AddV.get()); EXPECT_EQ(7, VM.lookup(this->BitcastV.get())); EXPECT_EQ(0, VM.lookup(this->AddV.get())); @@ -284,11 +284,11 @@ TYPED_TEST(ValueMapTest, SurvivesModificationByConfig) { // Now the ModifyingConfig can modify the Map inside a callback. VM[this->BitcastV.get()] = 7; this->BitcastV->replaceAllUsesWith(this->AddV.get()); - EXPECT_FALSE(VM.count(this->BitcastV.get())); - EXPECT_FALSE(VM.count(this->AddV.get())); + EXPECT_EQ(0u, VM.count(this->BitcastV.get())); + EXPECT_EQ(0u, VM.count(this->AddV.get())); VM[this->AddV.get()] = 7; this->AddV.reset(); - EXPECT_FALSE(VM.count(this->AddV.get())); + EXPECT_EQ(0u, VM.count(this->AddV.get())); } } diff --git a/unittests/IR/ValueTest.cpp b/unittests/IR/ValueTest.cpp index d92bc82..61e44a9 100644 --- a/unittests/IR/ValueTest.cpp +++ b/unittests/IR/ValueTest.cpp @@ -34,7 +34,7 @@ TEST(ValueTest, UsedInBasicBlock) { " ret void\n" "}\n"; SMDiagnostic Err; - Module *M = ParseAssemblyString(ModuleString, NULL, Err, C); + Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C); Function *F = M->getFunction("f"); @@ -56,7 +56,7 @@ TEST(GlobalTest, CreateAddressSpace) { GlobalValue::ExternalLinkage, Constant::getAllOnesValue(Int32Ty), "dummy", - 0, + nullptr, GlobalVariable::NotThreadLocal, 1); @@ -74,7 +74,7 @@ TEST(GlobalTest, CreateAddressSpace) { GlobalValue::ExternalLinkage, Constant::getAllOnesValue(Int32Ty), "dummy_cast", - 0, + nullptr, GlobalVariable::NotThreadLocal, 1); diff --git a/unittests/IR/VerifierTest.cpp b/unittests/IR/VerifierTest.cpp index 252bdd3..71e3168 100644 --- a/unittests/IR/VerifierTest.cpp +++ b/unittests/IR/VerifierTest.cpp @@ -44,23 +44,6 @@ TEST(VerifierTest, Branch_i1) { EXPECT_TRUE(verifyFunction(*F)); } -TEST(VerifierTest, AliasUnnamedAddr) { - LLVMContext &C = getGlobalContext(); - Module M("M", C); - Type *Ty = Type::getInt8Ty(C); - Constant *Init = Constant::getNullValue(Ty); - GlobalVariable *Aliasee = new GlobalVariable(M, Ty, true, - GlobalValue::ExternalLinkage, - Init, "foo"); - auto *GA = GlobalAlias::create(GlobalValue::ExternalLinkage, "bar", Aliasee); - GA->setUnnamedAddr(true); - std::string Error; - raw_string_ostream ErrorOS(Error); - EXPECT_TRUE(verifyModule(M, &ErrorOS)); - EXPECT_TRUE( - StringRef(ErrorOS.str()).startswith("Alias cannot have unnamed_addr")); -} - TEST(VerifierTest, InvalidRetAttribute) { LLVMContext &C = getGlobalContext(); Module M("M", C); diff --git a/unittests/IR/WaymarkTest.cpp b/unittests/IR/WaymarkTest.cpp index 9a9b4a2..8e3cd45 100644 --- a/unittests/IR/WaymarkTest.cpp +++ b/unittests/IR/WaymarkTest.cpp @@ -31,7 +31,7 @@ TEST(WaymarkTest, NativeArray) { FunctionType *FT = FunctionType::get(Type::getVoidTy(getGlobalContext()), true); Function *F = Function::Create(FT, GlobalValue::ExternalLinkage); const CallInst *A = CallInst::Create(F, makeArrayRef(values)); - ASSERT_NE(A, (const CallInst*)NULL); + ASSERT_NE(A, (const CallInst*)nullptr); ASSERT_EQ(1U + 22, A->getNumOperands()); const Use *U = &A->getOperandUse(0); const Use *Ue = &A->getOperandUse(22); |