summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-06-08 22:29:17 +0000
committerCraig Topper <craig.topper@gmail.com>2014-06-08 22:29:17 +0000
commitb177041dfaaabbbb8f97e256572125c42d35bbff (patch)
tree2fa3317226283039c40bb5e46c56ab2a2d4952bc /unittests
parentd8fdbb2ea84afd9be849e4237634ec09879a2d36 (diff)
downloadllvm-b177041dfaaabbbb8f97e256572125c42d35bbff.tar.gz
llvm-b177041dfaaabbbb8f97e256572125c42d35bbff.tar.bz2
llvm-b177041dfaaabbbb8f97e256572125c42d35bbff.tar.xz
[C++11] Use 'nullptr'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/APFloatTest.cpp6
-rw-r--r--unittests/ADT/DenseMapTest.cpp4
-rw-r--r--unittests/ADT/HashingTest.cpp2
-rw-r--r--unittests/ADT/ImmutableMapTest.cpp4
-rw-r--r--unittests/ADT/OwningPtrTest.cpp4
-rw-r--r--unittests/ADT/PointerUnionTest.cpp2
-rw-r--r--unittests/ADT/SCCIteratorTest.cpp2
-rw-r--r--unittests/ADT/ilistTest.cpp4
-rw-r--r--unittests/Analysis/CFGTest.cpp17
-rw-r--r--unittests/Analysis/MixedTBAATest.cpp2
-rw-r--r--unittests/Analysis/ScalarEvolutionTest.cpp4
-rw-r--r--unittests/ExecutionEngine/ExecutionEngineTest.cpp22
-rw-r--r--unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp12
-rw-r--r--unittests/ExecutionEngine/JIT/JITTest.cpp14
-rw-r--r--unittests/ExecutionEngine/JIT/MultiJITTest.cpp26
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp22
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITMemoryManagerTest.cpp24
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp18
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITTest.cpp2
-rw-r--r--unittests/IR/ConstantRangeTest.cpp8
-rw-r--r--unittests/IR/DominatorTreeTest.cpp2
-rw-r--r--unittests/IR/IRBuilderTest.cpp10
-rw-r--r--unittests/IR/InstructionsTest.cpp16
-rw-r--r--unittests/IR/LegacyPassManagerTest.cpp14
-rw-r--r--unittests/IR/MDBuilderTest.cpp14
-rw-r--r--unittests/IR/MetadataTest.cpp2
-rw-r--r--unittests/IR/PassManagerTest.cpp2
-rw-r--r--unittests/IR/PatternMatch.cpp12
-rw-r--r--unittests/IR/TypeBuilderTest.cpp6
-rw-r--r--unittests/IR/UserTest.cpp2
-rw-r--r--unittests/IR/ValueHandleTest.cpp32
-rw-r--r--unittests/IR/ValueMapTest.cpp4
-rw-r--r--unittests/IR/ValueTest.cpp6
-rw-r--r--unittests/IR/WaymarkTest.cpp2
-rw-r--r--unittests/Linker/LinkModulesTest.cpp10
-rw-r--r--unittests/Support/Casting.cpp8
-rw-r--r--unittests/Support/CommandLineTest.cpp2
-rw-r--r--unittests/Support/DataExtractorTest.cpp2
-rw-r--r--unittests/Support/ErrorOrTest.cpp8
-rw-r--r--unittests/Support/ManagedStatic.cpp10
-rw-r--r--unittests/Support/MemoryBufferTest.cpp20
-rw-r--r--unittests/Support/MemoryTest.cpp93
-rw-r--r--unittests/Support/ProgramTest.cpp36
-rw-r--r--unittests/Support/ThreadLocalTest.cpp4
-rw-r--r--unittests/Support/TimeValueTest.cpp2
-rw-r--r--unittests/Support/YAMLIOTest.cpp48
-rw-r--r--unittests/Support/raw_ostream_test.cpp4
-rw-r--r--unittests/Transforms/DebugIR/DebugIR.cpp2
-rw-r--r--unittests/Transforms/Utils/Cloning.cpp4
-rw-r--r--unittests/Transforms/Utils/SpecialCaseList.cpp12
50 files changed, 298 insertions, 290 deletions
diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp
index 86a48bf6c8..8f298cdfed 100644
--- a/unittests/ADT/APFloatTest.cpp
+++ b/unittests/ADT/APFloatTest.cpp
@@ -1173,11 +1173,11 @@ TEST(APFloatTest, exactInverse) {
EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(8.5070592e+37f)));
// Large float, inverse is a denormal.
- EXPECT_FALSE(APFloat(1.7014118e38f).getExactInverse(0));
+ EXPECT_FALSE(APFloat(1.7014118e38f).getExactInverse(nullptr));
// Zero
- EXPECT_FALSE(APFloat(0.0).getExactInverse(0));
+ EXPECT_FALSE(APFloat(0.0).getExactInverse(nullptr));
// Denormalized float
- EXPECT_FALSE(APFloat(1.40129846e-45f).getExactInverse(0));
+ EXPECT_FALSE(APFloat(1.40129846e-45f).getExactInverse(nullptr));
}
TEST(APFloatTest, roundToIntegral) {
diff --git a/unittests/ADT/DenseMapTest.cpp b/unittests/ADT/DenseMapTest.cpp
index dd4907104d..bb7797cf14 100644
--- a/unittests/ADT/DenseMapTest.cpp
+++ b/unittests/ADT/DenseMapTest.cpp
@@ -92,9 +92,9 @@ protected:
};
template <typename T>
-typename T::key_type *const DenseMapTest<T>::dummy_key_ptr = 0;
+typename T::key_type *const DenseMapTest<T>::dummy_key_ptr = nullptr;
template <typename T>
-typename T::mapped_type *const DenseMapTest<T>::dummy_value_ptr = 0;
+typename T::mapped_type *const DenseMapTest<T>::dummy_value_ptr = nullptr;
// Register these types for testing.
typedef ::testing::Types<DenseMap<uint32_t, uint32_t>,
diff --git a/unittests/ADT/HashingTest.cpp b/unittests/ADT/HashingTest.cpp
index 60917ae424..acaa83cddd 100644
--- a/unittests/ADT/HashingTest.cpp
+++ b/unittests/ADT/HashingTest.cpp
@@ -58,7 +58,7 @@ enum TestEnumeration {
TEST(HashingTest, HashValueBasicTest) {
int x = 42, y = 43, c = 'x';
- void *p = 0;
+ void *p = nullptr;
uint64_t i = 71;
const unsigned ci = 71;
volatile int vi = 71;
diff --git a/unittests/ADT/ImmutableMapTest.cpp b/unittests/ADT/ImmutableMapTest.cpp
index 774581ca4e..6a99884bfb 100644
--- a/unittests/ADT/ImmutableMapTest.cpp
+++ b/unittests/ADT/ImmutableMapTest.cpp
@@ -36,8 +36,8 @@ TEST(ImmutableMapTest, MultiElemIntMapTest) {
EXPECT_TRUE(S.isEmpty());
EXPECT_FALSE(S2.isEmpty());
- EXPECT_EQ(0, S.lookup(3));
- EXPECT_EQ(0, S.lookup(9));
+ EXPECT_EQ(nullptr, S.lookup(3));
+ EXPECT_EQ(nullptr, S.lookup(9));
EXPECT_EQ(10, *S2.lookup(3));
EXPECT_EQ(11, *S2.lookup(4));
diff --git a/unittests/ADT/OwningPtrTest.cpp b/unittests/ADT/OwningPtrTest.cpp
index aee955bf40..d83a9471cc 100644
--- a/unittests/ADT/OwningPtrTest.cpp
+++ b/unittests/ADT/OwningPtrTest.cpp
@@ -74,7 +74,7 @@ TEST_F(OwningPtrTest, Reset) {
TEST_F(OwningPtrTest, Take) {
TrackDestructor::ResetCounts();
- TrackDestructor *T = 0;
+ TrackDestructor *T = nullptr;
{
OwningPtr<TrackDestructor> O(new TrackDestructor(3));
T = O.take();
@@ -92,7 +92,7 @@ TEST_F(OwningPtrTest, Take) {
TEST_F(OwningPtrTest, Release) {
TrackDestructor::ResetCounts();
- TrackDestructor *T = 0;
+ TrackDestructor *T = nullptr;
{
OwningPtr<TrackDestructor> O(new TrackDestructor(3));
T = O.release();
diff --git a/unittests/ADT/PointerUnionTest.cpp b/unittests/ADT/PointerUnionTest.cpp
index 3bfb79cee4..a592784ae0 100644
--- a/unittests/ADT/PointerUnionTest.cpp
+++ b/unittests/ADT/PointerUnionTest.cpp
@@ -66,7 +66,7 @@ TEST_F(PointerUnionTest, Is) {
TEST_F(PointerUnionTest, Get) {
EXPECT_EQ(a.get<float *>(), &f);
EXPECT_EQ(b.get<int *>(), &i);
- EXPECT_EQ(n.get<int *>(), (int *)0);
+ EXPECT_EQ(n.get<int *>(), (int *)nullptr);
}
} // end anonymous namespace
diff --git a/unittests/ADT/SCCIteratorTest.cpp b/unittests/ADT/SCCIteratorTest.cpp
index 8609732fda..3f1ba1c584 100644
--- a/unittests/ADT/SCCIteratorTest.cpp
+++ b/unittests/ADT/SCCIteratorTest.cpp
@@ -213,7 +213,7 @@ public:
// Return a pointer to it.
return FirstNode + i;
assert(false && "Dereferencing end iterator!");
- return 0; // Avoid compiler warning.
+ return nullptr; // Avoid compiler warning.
}
};
diff --git a/unittests/ADT/ilistTest.cpp b/unittests/ADT/ilistTest.cpp
index 134607c2fd..44442ebf75 100644
--- a/unittests/ADT/ilistTest.cpp
+++ b/unittests/ADT/ilistTest.cpp
@@ -29,8 +29,8 @@ TEST(ilistTest, Basic) {
ilist<Node> List;
List.push_back(Node(1));
EXPECT_EQ(1, List.back().Value);
- EXPECT_EQ(0, List.back().getPrevNode());
- EXPECT_EQ(0, List.back().getNextNode());
+ EXPECT_EQ(nullptr, List.back().getPrevNode());
+ EXPECT_EQ(nullptr, List.back().getNextNode());
List.push_back(Node(2));
EXPECT_EQ(2, List.back().Value);
diff --git a/unittests/Analysis/CFGTest.cpp b/unittests/Analysis/CFGTest.cpp
index 8d8c560d9e..ac5e71061d 100644
--- a/unittests/Analysis/CFGTest.cpp
+++ b/unittests/Analysis/CFGTest.cpp
@@ -46,10 +46,10 @@ protected:
}
Function *F = M->getFunction("test");
- if (F == NULL)
+ if (F == nullptr)
report_fatal_error("Test must have a function named @test");
- A = B = NULL;
+ A = B = nullptr;
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
if (I->hasName()) {
if (I->getName() == "A")
@@ -58,9 +58,9 @@ protected:
B = &*I;
}
}
- if (A == NULL)
+ if (A == nullptr)
report_fatal_error("@test must have an instruction %A");
- if (B == NULL)
+ if (B == nullptr)
report_fatal_error("@test must have an instruction %B");
}
@@ -74,7 +74,7 @@ protected:
static int initialize() {
PassInfo *PI = new PassInfo("isPotentiallyReachable testing pass",
- "", &ID, 0, true, true);
+ "", &ID, nullptr, true, true);
PassRegistry::getPassRegistry()->registerPass(*PI, false);
initializeLoopInfoPass(*PassRegistry::getPassRegistry());
initializeDominatorTreeWrapperPassPass(
@@ -95,9 +95,10 @@ protected:
LoopInfo *LI = &getAnalysis<LoopInfo>();
DominatorTree *DT =
&getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- EXPECT_EQ(isPotentiallyReachable(A, B, 0, 0), ExpectedResult);
- EXPECT_EQ(isPotentiallyReachable(A, B, DT, 0), ExpectedResult);
- EXPECT_EQ(isPotentiallyReachable(A, B, 0, LI), ExpectedResult);
+ EXPECT_EQ(isPotentiallyReachable(A, B, nullptr, nullptr),
+ ExpectedResult);
+ EXPECT_EQ(isPotentiallyReachable(A, B, DT, nullptr), ExpectedResult);
+ EXPECT_EQ(isPotentiallyReachable(A, B, nullptr, LI), ExpectedResult);
EXPECT_EQ(isPotentiallyReachable(A, B, DT, LI), ExpectedResult);
return false;
}
diff --git a/unittests/Analysis/MixedTBAATest.cpp b/unittests/Analysis/MixedTBAATest.cpp
index 2cf7c734dc..142e04789d 100644
--- a/unittests/Analysis/MixedTBAATest.cpp
+++ b/unittests/Analysis/MixedTBAATest.cpp
@@ -43,7 +43,7 @@ TEST_F(MixedTBAATest, MixedTBAA) {
auto *Store1 = new StoreInst(Value, Addr, BB);
auto *Store2 = new StoreInst(Value, Addr, BB);
- ReturnInst::Create(C, 0, BB);
+ ReturnInst::Create(C, nullptr, BB);
// New TBAA metadata
{
diff --git a/unittests/Analysis/ScalarEvolutionTest.cpp b/unittests/Analysis/ScalarEvolutionTest.cpp
index 398d09e5a8..90f6997e98 100644
--- a/unittests/Analysis/ScalarEvolutionTest.cpp
+++ b/unittests/Analysis/ScalarEvolutionTest.cpp
@@ -41,7 +41,7 @@ TEST_F(ScalarEvolutionsTest, SCEVUnknownRAUW) {
std::vector<Type *>(), false);
Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
- ReturnInst::Create(Context, 0, BB);
+ ReturnInst::Create(Context, nullptr, BB);
Type *Ty = Type::getInt1Ty(Context);
Constant *Init = Constant::getNullValue(Ty);
@@ -94,7 +94,7 @@ TEST_F(ScalarEvolutionsTest, SCEVMultiplyAddRecs) {
FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), Types, false);
Function *F = cast<Function>(M.getOrInsertFunction("f", FTy));
BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
- ReturnInst::Create(Context, 0, BB);
+ ReturnInst::Create(Context, nullptr, BB);
// Create a ScalarEvolution and "run" it so that it gets initialized.
PM.add(&SE);
diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp
index e6f07dce1e..f23745c19d 100644
--- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp
+++ b/unittests/ExecutionEngine/ExecutionEngineTest.cpp
@@ -26,13 +26,13 @@ protected:
}
virtual void SetUp() {
- ASSERT_TRUE(Engine.get() != NULL) << "EngineBuilder returned error: '"
+ ASSERT_TRUE(Engine.get() != nullptr) << "EngineBuilder returned error: '"
<< Error << "'";
}
GlobalVariable *NewExtGlobal(Type *T, const Twine &Name) {
return new GlobalVariable(*M, T, false, // Not constant.
- GlobalValue::ExternalLinkage, NULL, Name);
+ GlobalValue::ExternalLinkage, nullptr, Name);
}
Module *const M;
@@ -49,14 +49,14 @@ TEST_F(ExecutionEngineTest, ForwardGlobalMapping) {
int32_t Mem2 = 4;
Engine->updateGlobalMapping(G1, &Mem2);
EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1));
- Engine->updateGlobalMapping(G1, NULL);
- EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G1));
+ Engine->updateGlobalMapping(G1, nullptr);
+ EXPECT_EQ(nullptr, Engine->getPointerToGlobalIfAvailable(G1));
Engine->updateGlobalMapping(G1, &Mem2);
EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1));
GlobalVariable *G2 =
NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
- EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G2))
+ EXPECT_EQ(nullptr, Engine->getPointerToGlobalIfAvailable(G2))
<< "The NULL return shouldn't depend on having called"
<< " updateGlobalMapping(..., NULL)";
// Check that update...() can be called before add...().
@@ -75,7 +75,7 @@ TEST_F(ExecutionEngineTest, ReverseGlobalMapping) {
EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1));
int32_t Mem2 = 4;
Engine->updateGlobalMapping(G1, &Mem2);
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
+ EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2));
GlobalVariable *G2 =
@@ -83,12 +83,12 @@ TEST_F(ExecutionEngineTest, ReverseGlobalMapping) {
Engine->updateGlobalMapping(G2, &Mem1);
EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1));
EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2));
- Engine->updateGlobalMapping(G1, NULL);
+ Engine->updateGlobalMapping(G1, nullptr);
EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1))
<< "Removing one mapping doesn't affect a different one.";
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem2));
+ EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem2));
Engine->updateGlobalMapping(G2, &Mem2);
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
+ EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem2))
<< "Once a mapping is removed, we can point another GV at the"
<< " now-free address.";
@@ -104,7 +104,7 @@ TEST_F(ExecutionEngineTest, ClearModuleMappings) {
Engine->clearGlobalMappingsFromModule(M);
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
+ EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
GlobalVariable *G2 =
NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global2");
@@ -124,7 +124,7 @@ TEST_F(ExecutionEngineTest, DestructionRemovesGlobalMapping) {
// When the GV goes away, the ExecutionEngine should remove any
// mappings that refer to it.
G1->eraseFromParent();
- EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
+ EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
}
}
diff --git a/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp b/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
index ab308844f2..296838de61 100644
--- a/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
+++ b/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
@@ -267,12 +267,12 @@ TEST(JITMemoryManagerTest, TestManyStubs) {
// After allocating a bunch of stubs, we should have two.
for (int I = 0; I < Iters; ++I)
- MemMgr->allocateStub(NULL, Size, 8);
+ MemMgr->allocateStub(nullptr, Size, 8);
EXPECT_EQ(2U, MemMgr->GetNumStubSlabs());
// And after much more, we should have three.
for (int I = 0; I < Iters; ++I)
- MemMgr->allocateStub(NULL, Size, 8);
+ MemMgr->allocateStub(nullptr, Size, 8);
EXPECT_EQ(3U, MemMgr->GetNumStubSlabs());
}
@@ -286,10 +286,10 @@ TEST(JITMemoryManagerTest, AllocateSection) {
uint8_t *data2 = MemMgr->allocateDataSection(256, 64, 4, StringRef(), false);
uint8_t *code3 = MemMgr->allocateCodeSection(258, 64, 5, StringRef());
- EXPECT_NE((uint8_t*)0, code1);
- EXPECT_NE((uint8_t*)0, code2);
- EXPECT_NE((uint8_t*)0, data1);
- EXPECT_NE((uint8_t*)0, data2);
+ EXPECT_NE((uint8_t*)nullptr, code1);
+ EXPECT_NE((uint8_t*)nullptr, code2);
+ EXPECT_NE((uint8_t*)nullptr, data1);
+ EXPECT_NE((uint8_t*)nullptr, data2);
// Check alignment
EXPECT_EQ((uint64_t)code1 & 0xf, 0u);
diff --git a/unittests/ExecutionEngine/JIT/JITTest.cpp b/unittests/ExecutionEngine/JIT/JITTest.cpp
index f438286f31..5eb52c6f01 100644
--- a/unittests/ExecutionEngine/JIT/JITTest.cpp
+++ b/unittests/ExecutionEngine/JIT/JITTest.cpp
@@ -169,7 +169,7 @@ public:
bool LoadAssemblyInto(Module *M, const char *assembly) {
SMDiagnostic Error;
bool success =
- NULL != ParseAssemblyString(assembly, M, Error, M->getContext());
+ nullptr != ParseAssemblyString(assembly, M, Error, M->getContext());
std::string errMsg;
raw_string_ostream os(errMsg);
Error.print("", os);
@@ -193,7 +193,7 @@ class JITTest : public testing::Test {
.setJITMemoryManager(RJMM)
.setErrorStr(&Error)
.setTargetOptions(Options).create());
- ASSERT_TRUE(TheJIT.get() != NULL) << Error;
+ ASSERT_TRUE(TheJIT.get() != nullptr) << Error;
}
void LoadAssembly(const char *assembly) {
@@ -249,7 +249,7 @@ TEST(JIT, GlobalInFunction) {
// Since F1 was codegen'd, a pointer to G should be available.
int32_t *GPtr = (int32_t*)JIT->getPointerToGlobalIfAvailable(G);
- ASSERT_NE((int32_t*)NULL, GPtr);
+ ASSERT_NE((int32_t*)nullptr, GPtr);
EXPECT_EQ(0, *GPtr);
// F1() should increment G.
@@ -636,7 +636,7 @@ ExecutionEngine *getJITFromBitcode(
if (error_code EC = ModuleOrErr.getError()) {
ADD_FAILURE() << EC.message();
delete BitcodeBuffer;
- return NULL;
+ return nullptr;
}
M = ModuleOrErr.get();
std::string errMsg;
@@ -644,11 +644,11 @@ ExecutionEngine *getJITFromBitcode(
.setEngineKind(EngineKind::JIT)
.setErrorStr(&errMsg)
.create();
- if (TheJIT == NULL) {
+ if (TheJIT == nullptr) {
ADD_FAILURE() << errMsg;
delete M;
- M = NULL;
- return NULL;
+ M = nullptr;
+ return nullptr;
}
return TheJIT;
}
diff --git a/unittests/ExecutionEngine/JIT/MultiJITTest.cpp b/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
index 5016532eef..f530e0de5d 100644
--- a/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
+++ b/unittests/ExecutionEngine/JIT/MultiJITTest.cpp
@@ -27,7 +27,7 @@ namespace {
bool LoadAssemblyInto(Module *M, const char *assembly) {
SMDiagnostic Error;
bool success =
- NULL != ParseAssemblyString(assembly, M, Error, M->getContext());
+ nullptr != ParseAssemblyString(assembly, M, Error, M->getContext());
std::string errMsg;
raw_string_ostream os(errMsg);
Error.print("", os);
@@ -71,13 +71,13 @@ void createModule2(LLVMContext &Context2, Module *&M2, Function *&FooF2) {
TEST(MultiJitTest, EagerMode) {
LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
+ Module *M1 = nullptr;
+ Function *FooF1 = nullptr;
createModule1(Context1, M1, FooF1);
LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
+ Module *M2 = nullptr;
+ Function *FooF2 = nullptr;
createModule2(Context2, M2, FooF2);
// Now we create the JIT in eager mode
@@ -101,13 +101,13 @@ TEST(MultiJitTest, EagerMode) {
TEST(MultiJitTest, LazyMode) {
LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
+ Module *M1 = nullptr;
+ Function *FooF1 = nullptr;
createModule1(Context1, M1, FooF1);
LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
+ Module *M2 = nullptr;
+ Function *FooF2 = nullptr;
createModule2(Context2, M2, FooF2);
// Now we create the JIT in lazy mode
@@ -135,13 +135,13 @@ extern "C" {
TEST(MultiJitTest, JitPool) {
LLVMContext Context1;
- Module *M1 = 0;
- Function *FooF1 = 0;
+ Module *M1 = nullptr;
+ Function *FooF1 = nullptr;
createModule1(Context1, M1, FooF1);
LLVMContext Context2;
- Module *M2 = 0;
- Function *FooF2 = 0;
+ Module *M2 = nullptr;
+ Function *FooF2 = nullptr;
createModule2(Context2, M2, FooF2);
// Now we create two JITs
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
index 20d3f139b4..d03de898b4 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
@@ -148,10 +148,10 @@ protected:
didCallAllocateCodeSection = false;
didAllocateCompactUnwindSection = false;
didCallYield = false;
- Module = 0;
- Function = 0;
- Engine = 0;
- Error = 0;
+ Module = nullptr;
+ Function = nullptr;
+ Engine = nullptr;
+ Error = nullptr;
}
virtual void TearDown() {
@@ -166,8 +166,8 @@ protected:
LLVMSetTarget(Module, HostTriple.c_str());
- Function = LLVMAddFunction(
- Module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0));
+ Function = LLVMAddFunction(Module, "simple_function",
+ LLVMFunctionType(LLVMInt32Type(), nullptr,0, 0));
LLVMSetFunctionCallConv(Function, LLVMCCallConv);
LLVMBasicBlockRef entry = LLVMAppendBasicBlock(Function, "entry");
@@ -192,8 +192,8 @@ protected:
LLVMFunctionType(LLVMVoidType(), stackmapParamTypes, 2, 1));
LLVMSetLinkage(stackmap, LLVMExternalLinkage);
- Function = LLVMAddFunction(
- Module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0));
+ Function = LLVMAddFunction(Module, "simple_function",
+ LLVMFunctionType(LLVMInt32Type(), nullptr, 0, 0));
LLVMBasicBlockRef entry = LLVMAppendBasicBlock(Function, "entry");
LLVMBuilderRef builder = LLVMCreateBuilder();
@@ -221,8 +221,8 @@ protected:
LLVMSetInitializer(GlobalVar, LLVMConstInt(LLVMInt32Type(), 42, 0));
{
- Function = LLVMAddFunction(
- Module, "getGlobal", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0));
+ Function = LLVMAddFunction(Module, "getGlobal",
+ LLVMFunctionType(LLVMInt32Type(), nullptr, 0, 0));
LLVMSetFunctionCallConv(Function, LLVMCCallConv);
LLVMBasicBlockRef Entry = LLVMAppendBasicBlock(Function, "entry");
@@ -443,7 +443,7 @@ TEST_F(MCJITCAPITest, yield) {
buildMCJITOptions();
buildMCJITEngine();
LLVMContextRef C = LLVMGetGlobalContext();
- LLVMContextSetYieldCallback(C, yield, NULL);
+ LLVMContextSetYieldCallback(C, yield, nullptr);
buildAndRunPasses();
union {
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITMemoryManagerTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITMemoryManagerTest.cpp
index f862999da8..98587f7e85 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITMemoryManagerTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITMemoryManagerTest.cpp
@@ -23,10 +23,10 @@ TEST(MCJITMemoryManagerTest, BasicAllocations) {
uint8_t *code2 = MemMgr->allocateCodeSection(256, 0, 3, "");
uint8_t *data2 = MemMgr->allocateDataSection(256, 0, 4, "", false);
- EXPECT_NE((uint8_t*)0, code1);
- EXPECT_NE((uint8_t*)0, code2);
- EXPECT_NE((uint8_t*)0, data1);
- EXPECT_NE((uint8_t*)0, data2);
+ EXPECT_NE((uint8_t*)nullptr, code1);
+ EXPECT_NE((uint8_t*)nullptr, code2);
+ EXPECT_NE((uint8_t*)nullptr, data1);
+ EXPECT_NE((uint8_t*)nullptr, data2);
// Initialize the data
for (unsigned i = 0; i < 256; ++i) {
@@ -56,10 +56,10 @@ TEST(MCJITMemoryManagerTest, LargeAllocations) {
uint8_t *code2 = MemMgr->allocateCodeSection(0x100000, 0, 3, "");
uint8_t *data2 = MemMgr->allocateDataSection(0x100000, 0, 4, "", false);
- EXPECT_NE((uint8_t*)0, code1);
- EXPECT_NE((uint8_t*)0, code2);
- EXPECT_NE((uint8_t*)0, data1);
- EXPECT_NE((uint8_t*)0, data2);
+ EXPECT_NE((uint8_t*)nullptr, code1);
+ EXPECT_NE((uint8_t*)nullptr, code2);
+ EXPECT_NE((uint8_t*)nullptr, data1);
+ EXPECT_NE((uint8_t*)nullptr, data2);
// Initialize the data
for (unsigned i = 0; i < 0x100000; ++i) {
@@ -98,8 +98,8 @@ TEST(MCJITMemoryManagerTest, ManyAllocations) {
data[i][j] = 2 + (i % 254);
}
- EXPECT_NE((uint8_t *)0, code[i]);
- EXPECT_NE((uint8_t *)0, data[i]);
+ EXPECT_NE((uint8_t *)nullptr, code[i]);
+ EXPECT_NE((uint8_t *)nullptr, data[i]);
}
// Verify the data (this is checking for overlaps in the addresses)
@@ -141,8 +141,8 @@ TEST(MCJITMemoryManagerTest, ManyVariedAllocations) {
data[i][j] = 2 + (i % 254);
}
- EXPECT_NE((uint8_t *)0, code[i]);
- EXPECT_NE((uint8_t *)0, data[i]);
+ EXPECT_NE((uint8_t *)nullptr, code[i]);
+ EXPECT_NE((uint8_t *)nullptr, data[i]);
uintptr_t CodeAlign = Align ? (uintptr_t)code[i] % Align : 0;
uintptr_t DataAlign = Align ? (uintptr_t)data[i] % Align : 0;
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
index 46847d3e51..fbbab42dbb 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
@@ -48,7 +48,7 @@ public:
const MemoryBuffer* BufferFound = getObjectInternal(M);
ModulesLookedUp.insert(M->getModuleIdentifier());
if (!BufferFound)
- return NULL;
+ return nullptr;
// Our test cache wants to maintain ownership of its object buffers
// so we make a copy here for the execution engine.
return MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer());
@@ -67,7 +67,7 @@ public:
const std::string ModuleID = M->getModuleIdentifier();
StringMap<const MemoryBuffer *>::iterator it = ObjMap.find(ModuleID);
if (it == ObjMap.end())
- return 0;
+ return nullptr;
return it->second;
}
@@ -101,13 +101,13 @@ protected:
void compileAndRun(int ExpectedRC = OriginalRC) {
// This function shouldn't be called until after SetUp.
ASSERT_TRUE(bool(TheJIT));
- ASSERT_TRUE(0 != Main);
+ ASSERT_TRUE(nullptr != Main);
// We may be using a null cache, so ensure compilation is valid.
TheJIT->finalizeObject();
void *vPtr = TheJIT->getPointerToFunction(Main);
- EXPECT_TRUE(0 != vPtr)
+ EXPECT_TRUE(nullptr != vPtr)
<< "Unable to get pointer to main() from JIT";
int (*FuncPtr)(void) = (int(*)(void))(intptr_t)vPtr;
@@ -123,7 +123,7 @@ TEST_F(MCJITObjectCacheTest, SetNullObjectCache) {
createJIT(M.release());
- TheJIT->setObjectCache(NULL);
+ TheJIT->setObjectCache(nullptr);
compileAndRun();
}
@@ -143,7 +143,7 @@ TEST_F(MCJITObjectCacheTest, VerifyBasicObjectCaching) {
// Verify that our object cache does not contain the module yet.
const MemoryBuffer *ObjBuffer = Cache->getObjectInternal(SavedModulePointer);
- EXPECT_EQ(0, ObjBuffer);
+ EXPECT_EQ(nullptr, ObjBuffer);
compileAndRun();
@@ -152,7 +152,7 @@ TEST_F(MCJITObjectCacheTest, VerifyBasicObjectCaching) {
// Verify that our object cache now contains the module.
ObjBuffer = Cache->getObjectInternal(SavedModulePointer);
- EXPECT_TRUE(0 != ObjBuffer);
+ EXPECT_TRUE(nullptr != ObjBuffer);
// Verify that the cache was only notified once.
EXPECT_FALSE(Cache->wereDuplicatesInserted());
@@ -221,7 +221,7 @@ TEST_F(MCJITObjectCacheTest, VerifyNonLoadFromCache) {
// Verify that our object cache does not contain the module yet.
const MemoryBuffer *ObjBuffer = Cache->getObjectInternal(SecondModulePointer);
- EXPECT_EQ(0, ObjBuffer);
+ EXPECT_EQ(nullptr, ObjBuffer);
// Run the function and look for the replacement return code.
compileAndRun(ReplacementRC);
@@ -231,7 +231,7 @@ TEST_F(MCJITObjectCacheTest, VerifyNonLoadFromCache) {
// Verify that our object cache now contains the module.
ObjBuffer = Cache->getObjectInternal(SecondModulePointer);
- EXPECT_TRUE(0 != ObjBuffer);
+ EXPECT_TRUE(nullptr != ObjBuffer);
// Verify that MCJIT didn't try to cache this again.
EXPECT_FALSE(Cache->wereDuplicatesInserted());
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
index a439508af0..c37c1d1d59 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
@@ -51,7 +51,7 @@ TEST_F(MCJITTest, global_variable) {
GlobalValue *Global = insertGlobalInt32(M.get(), "test_global", initialValue);
createJIT(M.release());
void *globalPtr = TheJIT->getPointerToGlobal(Global);
- EXPECT_TRUE(0 != globalPtr)
+ EXPECT_TRUE(nullptr != globalPtr)
<< "Unable to get pointer to global value from JIT";
EXPECT_EQ(initialValue, *(int32_t*)globalPtr)
diff --git a/unittests/IR/ConstantRangeTest.cpp b/unittests/IR/ConstantRangeTest.cpp
index cdf7378c17..fa03302ad2 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/DominatorTreeTest.cpp b/unittests/IR/DominatorTreeTest.cpp
index 98c2317f2c..ab43d1c91f 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 9796e44599..21085755fb 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 336f5a2dcd..7ec9b62207 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 df6f460df9..9c2a835ca0 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 c8b5a09e49..fc4674ea13 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 00a2783fbf..4f7bd720d1 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 310e48fc3b..25037a773c 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 bebee15366..f3a27b8d25 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 be493cdc63..b7b3e45e35 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 9c0e7b2750..eb07e824d8 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 15a0c226f7..403d2bcbda 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 6fd87b1e0c..3427c91332 100644
--- a/unittests/IR/ValueMapTest.cpp
+++ b/unittests/IR/ValueMapTest.cpp
@@ -40,8 +40,8 @@ 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) {
diff --git a/unittests/IR/ValueTest.cpp b/unittests/IR/ValueTest.cpp
index d92bc82768..61e44a908d 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/WaymarkTest.cpp b/unittests/IR/WaymarkTest.cpp
index 9a9b4a2ad4..8e3cd45808 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);
diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp
index 1d5db3641d..4ccced195d 100644
--- a/unittests/Linker/LinkModulesTest.cpp
+++ b/unittests/Linker/LinkModulesTest.cpp
@@ -36,7 +36,7 @@ protected:
ArrayType *AT = ArrayType::get(Type::getInt8PtrTy(Ctx), 3);
GV = new GlobalVariable(*M.get(), AT, false /*=isConstant*/,
- GlobalValue::InternalLinkage, 0, "switch.bas");
+ GlobalValue::InternalLinkage, nullptr,"switch.bas");
// Global Initializer
std::vector<Constant *> Init;
@@ -88,7 +88,7 @@ TEST_F(LinkModuleTest, BlockAddress) {
Builder.CreateRet(ConstantPointerNull::get(Type::getInt8PtrTy(Ctx)));
Module *LinkedModule = new Module("MyModuleLinked", Ctx);
- Linker::LinkModules(LinkedModule, M.get(), Linker::PreserveSource, 0);
+ Linker::LinkModules(LinkedModule, M.get(), Linker::PreserveSource, nullptr);
// Delete the original module.
M.reset();
@@ -138,16 +138,16 @@ TEST_F(LinkModuleTest, EmptyModule) {
GlobalVariable *GV =
new GlobalVariable(*InternalM, STy, false /*=isConstant*/,
- GlobalValue::InternalLinkage, 0, "g");
+ GlobalValue::InternalLinkage, nullptr, "g");
GV->setInitializer(ConstantStruct::get(STy, F));
Module *EmptyM = new Module("EmptyModule1", Ctx);
- Linker::LinkModules(EmptyM, InternalM, Linker::PreserveSource, 0);
+ Linker::LinkModules(EmptyM, InternalM, Linker::PreserveSource, nullptr);
delete EmptyM;
EmptyM = new Module("EmptyModule2", Ctx);
- Linker::LinkModules(InternalM, EmptyM, Linker::PreserveSource, 0);
+ Linker::LinkModules(InternalM, EmptyM, Linker::PreserveSource, nullptr);
delete EmptyM;
delete InternalM;
diff --git a/unittests/Support/Casting.cpp b/unittests/Support/Casting.cpp
index 228c90bb8b..88c7d19aa4 100644
--- a/unittests/Support/Casting.cpp
+++ b/unittests/Support/Casting.cpp
@@ -18,7 +18,7 @@ namespace llvm {
// Used to test illegal cast. If a cast doesn't match any of the "real" ones,
// it will match this one.
struct IllegalCast;
-template <typename T> IllegalCast *cast(...) { return 0; }
+template <typename T> IllegalCast *cast(...) { return nullptr; }
// set up two example classes
// with conversion facility
@@ -90,7 +90,7 @@ static_assert(std::is_same<simplify_type<foo *>::SimpleType, foo *>::value,
namespace {
-const foo *null_foo = NULL;
+const foo *null_foo = nullptr;
bar B;
extern bar &B1;
@@ -175,7 +175,7 @@ TEST(CastingTest, dyn_cast_or_null) {
const bar *B2 = &B;
} // anonymous namespace
-bar *llvm::fub() { return 0; }
+bar *llvm::fub() { return nullptr; }
namespace {
namespace inferred_upcasting {
@@ -203,7 +203,7 @@ TEST(CastingTest, UpcastIsInferred) {
Derived D;
EXPECT_TRUE(isa<Base>(D));
Base *BP = dyn_cast<Base>(&D);
- EXPECT_TRUE(BP != NULL);
+ EXPECT_TRUE(BP != nullptr);
}
diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp
index b0f1eb1ad6..b2d71ab795 100644
--- a/unittests/Support/CommandLineTest.cpp
+++ b/unittests/Support/CommandLineTest.cpp
@@ -23,7 +23,7 @@ class TempEnvVar {
TempEnvVar(const char *name, const char *value)
: name(name) {
const char *old_value = getenv(name);
- EXPECT_EQ(NULL, old_value) << old_value;
+ EXPECT_EQ(nullptr, old_value) << old_value;
#if HAVE_SETENV
setenv(name, value, true);
#else
diff --git a/unittests/Support/DataExtractorTest.cpp b/unittests/Support/DataExtractorTest.cpp
index ec8bd3d18c..81de983d22 100644
--- a/unittests/Support/DataExtractorTest.cpp
+++ b/unittests/Support/DataExtractorTest.cpp
@@ -94,7 +94,7 @@ TEST(DataExtractorTest, Strings) {
EXPECT_EQ(stringData, DE.getCStr(&offset));
EXPECT_EQ(11U, offset);
- EXPECT_EQ(NULL, DE.getCStr(&offset));
+ EXPECT_EQ(nullptr, DE.getCStr(&offset));
EXPECT_EQ(11U, offset);
}
diff --git a/unittests/Support/ErrorOrTest.cpp b/unittests/Support/ErrorOrTest.cpp
index 18ce507b88..7ace5e3e81 100644
--- a/unittests/Support/ErrorOrTest.cpp
+++ b/unittests/Support/ErrorOrTest.cpp
@@ -54,10 +54,10 @@ struct B {};
struct D : B {};
TEST(ErrorOr, Covariant) {
- ErrorOr<B*> b(ErrorOr<D*>(0));
- b = ErrorOr<D*>(0);
+ ErrorOr<B*> b(ErrorOr<D*>(nullptr));
+ b = ErrorOr<D*>(nullptr);
- ErrorOr<std::unique_ptr<B> > b1(ErrorOr<std::unique_ptr<D> >(0));
- b1 = ErrorOr<std::unique_ptr<D> >(0);
+ ErrorOr<std::unique_ptr<B> > b1(ErrorOr<std::unique_ptr<D> >(nullptr));
+ b1 = ErrorOr<std::unique_ptr<D> >(nullptr);
}
} // end anon namespace
diff --git a/unittests/Support/ManagedStatic.cpp b/unittests/Support/ManagedStatic.cpp
index 1497f4e340..ad2fc977e6 100644
--- a/unittests/Support/ManagedStatic.cpp
+++ b/unittests/Support/ManagedStatic.cpp
@@ -25,7 +25,7 @@ namespace test1 {
llvm::ManagedStatic<int> ms;
void *helper(void*) {
*ms;
- return NULL;
+ return nullptr;
}
// Valgrind's leak checker complains glibc's stack allocation.
@@ -49,10 +49,10 @@ TEST(Initialize, MultipleThreads) {
llvm_start_multithreaded();
pthread_t t1, t2;
- pthread_create(&t1, &a1, test1::helper, NULL);
- pthread_create(&t2, &a2, test1::helper, NULL);
- pthread_join(t1, NULL);
- pthread_join(t2, NULL);
+ pthread_create(&t1, &a1, test1::helper, nullptr);
+ pthread_create(&t2, &a2, test1::helper, nullptr);
+ pthread_join(t1, nullptr);
+ pthread_join(t2, nullptr);
free(p1);
free(p2);
llvm_stop_multithreaded();
diff --git a/unittests/Support/MemoryBufferTest.cpp b/unittests/Support/MemoryBufferTest.cpp
index 6790d0c53b..b7d0c206e8 100644
--- a/unittests/Support/MemoryBufferTest.cpp
+++ b/unittests/Support/MemoryBufferTest.cpp
@@ -43,15 +43,15 @@ protected:
TEST_F(MemoryBufferTest, get) {
// Default name and null-terminator flag
OwningBuffer MB1(MemoryBuffer::getMemBuffer(data));
- EXPECT_TRUE(0 != MB1.get());
+ EXPECT_TRUE(nullptr != MB1.get());
// RequiresNullTerminator = false
OwningBuffer MB2(MemoryBuffer::getMemBuffer(data, "one", false));
- EXPECT_TRUE(0 != MB2.get());
+ EXPECT_TRUE(nullptr != MB2.get());
// RequiresNullTerminator = true
OwningBuffer MB3(MemoryBuffer::getMemBuffer(data, "two", true));
- EXPECT_TRUE(0 != MB3.get());
+ EXPECT_TRUE(nullptr != MB3.get());
// verify all 3 buffers point to the same address
EXPECT_EQ(MB1->getBufferStart(), MB2->getBufferStart());
@@ -89,11 +89,11 @@ TEST_F(MemoryBufferTest, NullTerminator4K) {
TEST_F(MemoryBufferTest, copy) {
// copy with no name
OwningBuffer MBC1(MemoryBuffer::getMemBufferCopy(data));
- EXPECT_TRUE(0 != MBC1.get());
+ EXPECT_TRUE(nullptr != MBC1.get());
// copy with a name
OwningBuffer MBC2(MemoryBuffer::getMemBufferCopy(data, "copy"));
- EXPECT_TRUE(0 != MBC2.get());
+ EXPECT_TRUE(nullptr != MBC2.get());
// verify the two copies do not point to the same place
EXPECT_NE(MBC1->getBufferStart(), MBC2->getBufferStart());
@@ -102,25 +102,25 @@ TEST_F(MemoryBufferTest, copy) {
TEST_F(MemoryBufferTest, make_new) {
// 0-sized buffer
OwningBuffer Zero(MemoryBuffer::getNewUninitMemBuffer(0));
- EXPECT_TRUE(0 != Zero.get());
+ EXPECT_TRUE(nullptr != Zero.get());
// uninitialized buffer with no name
OwningBuffer One(MemoryBuffer::getNewUninitMemBuffer(321));
- EXPECT_TRUE(0 != One.get());
+ EXPECT_TRUE(nullptr != One.get());
// uninitialized buffer with name
OwningBuffer Two(MemoryBuffer::getNewUninitMemBuffer(123, "bla"));
- EXPECT_TRUE(0 != Two.get());
+ EXPECT_TRUE(nullptr != Two.get());
// 0-initialized buffer with no name
OwningBuffer Three(MemoryBuffer::getNewMemBuffer(321, data));
- EXPECT_TRUE(0 != Three.get());
+ EXPECT_TRUE(nullptr != Three.get());
for (size_t i = 0; i < 321; ++i)
EXPECT_EQ(0, Three->getBufferStart()[0]);
// 0-initialized buffer with name
OwningBuffer Four(MemoryBuffer::getNewMemBuffer(123, "zeros"));
- EXPECT_TRUE(0 != Four.get());
+ EXPECT_TRUE(nullptr != Four.get());
for (size_t i = 0; i < 123; ++i)
EXPECT_EQ(0, Four->getBufferStart()[0]);
}
diff --git a/unittests/Support/MemoryTest.cpp b/unittests/Support/MemoryTest.cpp
index 9d0cb54a13..f85f3dc312 100644
--- a/unittests/Support/MemoryTest.cpp
+++ b/unittests/Support/MemoryTest.cpp
@@ -58,10 +58,10 @@ protected:
TEST_P(MappedMemoryTest, AllocAndRelease) {
error_code EC;
- MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
+ MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(sizeof(int), M1.size());
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
@@ -69,18 +69,18 @@ TEST_P(MappedMemoryTest, AllocAndRelease) {
TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
error_code EC;
- MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
+ MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
- MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC);
+ MemoryBlock M2 = Memory::allocateMappedMemory(64, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
- MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC);
+ MemoryBlock M3 = Memory::allocateMappedMemory(32, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
- EXPECT_NE((void*)0, M2.base());
+ EXPECT_NE((void*)nullptr, M2.base());
EXPECT_LE(64U, M2.size());
- EXPECT_NE((void*)0, M3.base());
+ EXPECT_NE((void*)nullptr, M3.base());
EXPECT_LE(32U, M3.size());
EXPECT_FALSE(doesOverlap(M1, M2));
@@ -89,9 +89,9 @@ TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
- MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
+ MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M4.base());
+ EXPECT_NE((void*)nullptr, M4.base());
EXPECT_LE(16U, M4.size());
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
@@ -104,10 +104,10 @@ TEST_P(MappedMemoryTest, BasicWrite) {
return;
error_code EC;
- MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
+ MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(sizeof(int), M1.size());
int *a = (int*)M1.base();
@@ -123,22 +123,25 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
!((Flags & Memory::MF_READ) && (Flags & Memory::MF_WRITE)))
return;
error_code EC;
- MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
+ MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,
+ EC);
EXPECT_EQ(error_code(), EC);
- MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
+ MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags,
+ EC);
EXPECT_EQ(error_code(), EC);
- MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
+ MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags,
+ EC);
EXPECT_EQ(error_code(), EC);
EXPECT_FALSE(doesOverlap(M1, M2));
EXPECT_FALSE(doesOverlap(M2, M3));
EXPECT_FALSE(doesOverlap(M1, M3));
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(1U * sizeof(int), M1.size());
- EXPECT_NE((void*)0, M2.base());
+ EXPECT_NE((void*)nullptr, M2.base());
EXPECT_LE(8U * sizeof(int), M2.size());
- EXPECT_NE((void*)0, M3.base());
+ EXPECT_NE((void*)nullptr, M3.base());
EXPECT_LE(4U * sizeof(int), M3.size());
int *x = (int*)M1.base();
@@ -159,9 +162,10 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
- MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC);
+ MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), nullptr,
+ Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M4.base());
+ EXPECT_NE((void*)nullptr, M4.base());
EXPECT_LE(64U * sizeof(int), M4.size());
x = (int*)M4.base();
*x = 4;
@@ -177,18 +181,21 @@ TEST_P(MappedMemoryTest, MultipleWrite) {
TEST_P(MappedMemoryTest, EnabledWrite) {
error_code EC;
- MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC);
+ MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), nullptr, Flags,
+ EC);
EXPECT_EQ(error_code(), EC);
- MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
+ MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags,
+ EC);
EXPECT_EQ(error_code(), EC);
- MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
+ MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags,
+ EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(2U * sizeof(int), M1.size());
- EXPECT_NE((void*)0, M2.base());
+ EXPECT_NE((void*)nullptr, M2.base());
EXPECT_LE(8U * sizeof(int), M2.size());
- EXPECT_NE((void*)0, M3.base());
+ EXPECT_NE((void*)nullptr, M3.base());
EXPECT_LE(4U * sizeof(int), M3.size());
EXPECT_FALSE(Memory::protectMappedMemory(M1, getTestableEquivalent(Flags)));
@@ -216,9 +223,9 @@ TEST_P(MappedMemoryTest, EnabledWrite) {
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
EXPECT_EQ(6, y[6]);
- MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
+ MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M4.base());
+ EXPECT_NE((void*)nullptr, M4.base());
EXPECT_LE(16U, M4.size());
EXPECT_EQ(error_code(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
x = (int*)M4.base();
@@ -230,18 +237,18 @@ TEST_P(MappedMemoryTest, EnabledWrite) {
TEST_P(MappedMemoryTest, SuccessiveNear) {
error_code EC;
- MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
+ MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC);
EXPECT_EQ(error_code(), EC);
MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
- EXPECT_NE((void*)0, M2.base());
+ EXPECT_NE((void*)nullptr, M2.base());
EXPECT_LE(64U, M2.size());
- EXPECT_NE((void*)0, M3.base());
+ EXPECT_NE((void*)nullptr, M3.base());
EXPECT_LE(32U, M3.size());
EXPECT_FALSE(doesOverlap(M1, M2));
@@ -263,11 +270,11 @@ TEST_P(MappedMemoryTest, DuplicateNear) {
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
- EXPECT_NE((void*)0, M2.base());
+ EXPECT_NE((void*)nullptr, M2.base());
EXPECT_LE(64U, M2.size());
- EXPECT_NE((void*)0, M3.base());
+ EXPECT_NE((void*)nullptr, M3.base());
EXPECT_LE(32U, M3.size());
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
@@ -277,7 +284,7 @@ TEST_P(MappedMemoryTest, DuplicateNear) {
TEST_P(MappedMemoryTest, ZeroNear) {
error_code EC;
- MemoryBlock Near(0, 0);
+ MemoryBlock Near(nullptr, 0);
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
@@ -285,11 +292,11 @@ TEST_P(MappedMemoryTest, ZeroNear) {
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
- EXPECT_NE((void*)0, M2.base());
+ EXPECT_NE((void*)nullptr, M2.base());
EXPECT_LE(64U, M2.size());
- EXPECT_NE((void*)0, M3.base());
+ EXPECT_NE((void*)nullptr, M3.base());
EXPECT_LE(32U, M3.size());
EXPECT_FALSE(doesOverlap(M1, M2));
@@ -311,11 +318,11 @@ TEST_P(MappedMemoryTest, ZeroSizeNear) {
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(16U, M1.size());
- EXPECT_NE((void*)0, M2.base());
+ EXPECT_NE((void*)nullptr, M2.base());
EXPECT_LE(64U, M2.size());
- EXPECT_NE((void*)0, M3.base());
+ EXPECT_NE((void*)nullptr, M3.base());
EXPECT_LE(32U, M3.size());
EXPECT_FALSE(doesOverlap(M1, M2));
@@ -333,7 +340,7 @@ TEST_P(MappedMemoryTest, UnalignedNear) {
MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC);
EXPECT_EQ(error_code(), EC);
- EXPECT_NE((void*)0, M1.base());
+ EXPECT_NE((void*)nullptr, M1.base());
EXPECT_LE(sizeof(int), M1.size());
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
diff --git a/unittests/Support/ProgramTest.cpp b/unittests/Support/ProgramTest.cpp
index d8cb42af03..4e7316fb3a 100644
--- a/unittests/Support/ProgramTest.cpp
+++ b/unittests/Support/ProgramTest.cpp
@@ -54,7 +54,7 @@ static void CopyEnvironment(std::vector<const char *> &out) {
// environ seems to work for Windows and most other Unices.
char **envp = environ;
#endif
- while (*envp != 0) {
+ while (*envp != nullptr) {
out.push_back(*envp);
++envp;
}
@@ -76,14 +76,14 @@ TEST(ProgramTest, CreateProcessTrailingSlash) {
"--gtest_filter=ProgramTest.CreateProcessTrailingSlash",
"-program-test-string-arg1", "has\\\\ trailing\\",
"-program-test-string-arg2", "has\\\\ trailing\\",
- 0
+ nullptr
};
// Add LLVM_PROGRAM_TEST_CHILD to the environment of the child.
std::vector<const char *> envp;
CopyEnvironment(envp);
envp.push_back("LLVM_PROGRAM_TEST_CHILD=1");
- envp.push_back(0);
+ envp.push_back(nullptr);
std::string error;
bool ExecutionFailed;
@@ -93,7 +93,7 @@ TEST(ProgramTest, CreateProcessTrailingSlash) {
#else
StringRef nul("/dev/null");
#endif
- const StringRef *redirects[] = { &nul, &nul, 0 };
+ const StringRef *redirects[] = { &nul, &nul, nullptr };
int rc = ExecuteAndWait(my_exe, argv, &envp[0], redirects,
/*secondsToWait=*/ 10, /*memoryLimit=*/ 0, &error,
&ExecutionFailed);
@@ -114,19 +114,19 @@ TEST(ProgramTest, TestExecuteNoWait) {
const char *argv[] = {
Executable.c_str(),
"--gtest_filter=ProgramTest.TestExecuteNoWait",
- 0
+ nullptr
};
// Add LLVM_PROGRAM_TEST_EXECUTE_NO_WAIT to the environment of the child.
std::vector<const char *> envp;
CopyEnvironment(envp);
envp.push_back("LLVM_PROGRAM_TEST_EXECUTE_NO_WAIT=1");
- envp.push_back(0);
+ envp.push_back(nullptr);
std::string Error;
bool ExecutionFailed;
- ProcessInfo PI1 =
- ExecuteNoWait(Executable, argv, &envp[0], 0, 0, &Error, &ExecutionFailed);
+ ProcessInfo PI1 = ExecuteNoWait(Executable, argv, &envp[0], nullptr, 0,
+ &Error, &ExecutionFailed);
ASSERT_FALSE(ExecutionFailed) << Error;
ASSERT_NE(PI1.Pid, 0) << "Invalid process id";
@@ -144,8 +144,8 @@ TEST(ProgramTest, TestExecuteNoWait) {
EXPECT_EQ(LoopCount, 1u) << "LoopCount should be 1";
- ProcessInfo PI2 =
- ExecuteNoWait(Executable, argv, &envp[0], 0, 0, &Error, &ExecutionFailed);
+ ProcessInfo PI2 = ExecuteNoWait(Executable, argv, &envp[0], nullptr, 0,
+ &Error, &ExecutionFailed);
ASSERT_FALSE(ExecutionFailed) << Error;
ASSERT_NE(PI2.Pid, 0) << "Invalid process id";
@@ -175,32 +175,32 @@ TEST(ProgramTest, TestExecuteAndWaitTimeout) {
const char *argv[] = {
Executable.c_str(),
"--gtest_filter=ProgramTest.TestExecuteAndWaitTimeout",
- 0
+ nullptr
};
// Add LLVM_PROGRAM_TEST_TIMEOUT to the environment of the child.
std::vector<const char *> envp;
CopyEnvironment(envp);
envp.push_back("LLVM_PROGRAM_TEST_TIMEOUT=1");
- envp.push_back(0);
+ envp.push_back(nullptr);
std::string Error;
bool ExecutionFailed;
int RetCode =
- ExecuteAndWait(Executable, argv, &envp[0], 0, /*secondsToWait=*/1, 0,
+ ExecuteAndWait(Executable, argv, &envp[0], nullptr, /*secondsToWait=*/1, 0,
&Error, &ExecutionFailed);
ASSERT_EQ(-2, RetCode);
}
TEST(ProgramTest, TestExecuteNegative) {
std::string Executable = "i_dont_exist";
- const char *argv[] = { Executable.c_str(), 0 };
+ const char *argv[] = { Executable.c_str(), nullptr };
{
std::string Error;
bool ExecutionFailed;
- int RetCode =
- ExecuteAndWait(Executable, argv, 0, 0, 0, 0, &Error, &ExecutionFailed);
+ int RetCode = ExecuteAndWait(Executable, argv, nullptr, nullptr, 0, 0,
+ &Error, &ExecutionFailed);
ASSERT_TRUE(RetCode < 0) << "On error ExecuteAndWait should return 0 or "
"positive value indicating the result code";
ASSERT_TRUE(ExecutionFailed);
@@ -210,8 +210,8 @@ TEST(ProgramTest, TestExecuteNegative) {
{
std::string Error;
bool ExecutionFailed;
- ProcessInfo PI =
- ExecuteNoWait(Executable, argv, 0, 0, 0, &Error, &ExecutionFailed);
+ ProcessInfo PI = ExecuteNoWait(Executable, argv, nullptr, nullptr, 0,
+ &Error, &ExecutionFailed);
ASSERT_EQ(PI.Pid, 0)
<< "On error ExecuteNoWait should return an invalid ProcessInfo";
ASSERT_TRUE(ExecutionFailed);
diff --git a/unittests/Support/ThreadLocalTest.cpp b/unittests/Support/ThreadLocalTest.cpp
index dd4d706f5c..ea751be230 100644
--- a/unittests/Support/ThreadLocalTest.cpp
+++ b/unittests/Support/ThreadLocalTest.cpp
@@ -25,14 +25,14 @@ struct S {
TEST_F(ThreadLocalTest, Basics) {
ThreadLocal<const S> x;
- EXPECT_EQ(0, x.get());
+ EXPECT_EQ(nullptr, x.get());
S s;
x.set(&s);
EXPECT_EQ(&s, x.get());
x.erase();
- EXPECT_EQ(0, x.get());
+ EXPECT_EQ(nullptr, x.get());
}
}
diff --git a/unittests/Support/TimeValueTest.cpp b/unittests/Support/TimeValueTest.cpp
index 8058812ff4..3d2b9780c0 100644
--- a/unittests/Support/TimeValueTest.cpp
+++ b/unittests/Support/TimeValueTest.cpp
@@ -16,7 +16,7 @@ namespace {
TEST(TimeValue, time_t) {
sys::TimeValue now = sys::TimeValue::now();
- time_t now_t = time(NULL);
+ time_t now_t = time(nullptr);
EXPECT_TRUE(std::abs(static_cast<long>(now_t - now.toEpochTime())) < 2);
}
diff --git a/unittests/Support/YAMLIOTest.cpp b/unittests/Support/YAMLIOTest.cpp
index ffabbcfe05..8aed98012f 100644
--- a/unittests/Support/YAMLIOTest.cpp
+++ b/unittests/Support/YAMLIOTest.cpp
@@ -1204,7 +1204,7 @@ TEST(YAMLIO, TestValidatingInput) {
std::vector<MyValidation> docList;
Input yin("--- \nvalue: 3.0\n"
"--- \nvalue: -1.0\n...\n",
- NULL, suppressErrorMessages);
+ nullptr, suppressErrorMessages);
yin >> docList;
EXPECT_TRUE(!!yin.error());
}
@@ -1224,7 +1224,7 @@ TEST(YAMLIO, TestColorsReadError) {
"c2: purple\n"
"c3: green\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> map;
EXPECT_TRUE(!!yin.error());
@@ -1241,7 +1241,7 @@ TEST(YAMLIO, TestFlagsReadError) {
"f2: [ round, hollow ]\n"
"f3: []\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> map;
@@ -1260,7 +1260,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint8Error) {
"- 0\n"
"- 257\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1279,7 +1279,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint16Error) {
"- 0\n"
"- 66000\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1298,7 +1298,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint32Error) {
"- 0\n"
"- 5000000000\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1317,7 +1317,7 @@ TEST(YAMLIO, TestReadBuiltInTypesUint64Error) {
"- 0\n"
"- 19446744073709551615\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1337,7 +1337,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint8OverError) {
"- 127\n"
"- 128\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1355,7 +1355,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint8UnderError) {
"- 127\n"
"- -129\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1375,7 +1375,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint16UnderError) {
"- -32768\n"
"- -32769\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1394,7 +1394,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint16OverError) {
"- -32768\n"
"- 32768\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1414,7 +1414,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint32UnderError) {
"- -2147483648\n"
"- -2147483649\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1432,7 +1432,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint32OverError) {
"- -2147483648\n"
"- 2147483649\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1452,7 +1452,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint64UnderError) {
"- 9223372036854775807\n"
"- -9223372036854775809\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1470,7 +1470,7 @@ TEST(YAMLIO, TestReadBuiltInTypesint64OverError) {
"- 9223372036854775807\n"
"- 9223372036854775809\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1489,7 +1489,7 @@ TEST(YAMLIO, TestReadBuiltInTypesFloatError) {
"- -123.456\n"
"- 1.2.3\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1508,7 +1508,7 @@ TEST(YAMLIO, TestReadBuiltInTypesDoubleError) {
"- -123.456\n"
"- 1.2.3\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1526,7 +1526,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex8Error) {
"- 0xFE\n"
"- 0x123\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1545,7 +1545,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex16Error) {
"- 0xFEFF\n"
"- 0x12345\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1563,7 +1563,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex32Error) {
"- 0xFEFF0000\n"
"- 0x1234556789\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1581,7 +1581,7 @@ TEST(YAMLIO, TestReadBuiltInTypesHex64Error) {
"- 0xFFEEDDCCBBAA9988\n"
"- 0x12345567890ABCDEF0\n"
"...\n",
- /*Ctxt=*/NULL,
+ /*Ctxt=*/nullptr,
suppressErrorMessages);
yin >> seq;
@@ -1593,13 +1593,13 @@ TEST(YAMLIO, TestMalformedMapFailsGracefully) {
{
// We pass the suppressErrorMessages handler to handle the error
// message generated in the constructor of Input.
- Input yin("{foo:3, bar: 5}", /*Ctxt=*/NULL, suppressErrorMessages);
+ Input yin("{foo:3, bar: 5}", /*Ctxt=*/nullptr, suppressErrorMessages);
yin >> doc;
EXPECT_TRUE(!!yin.error());
}
{
- Input yin("---\nfoo:3\nbar: 5\n...\n", /*Ctxt=*/NULL, suppressErrorMessages);
+ Input yin("---\nfoo:3\nbar: 5\n...\n", /*Ctxt=*/nullptr, suppressErrorMessages);
yin >> doc;
EXPECT_TRUE(!!yin.error());
}
@@ -1685,7 +1685,7 @@ TEST(YAMLIO, TestEmptyStringSucceedsForMapWithOptionalFields) {
TEST(YAMLIO, TestEmptyStringSucceedsForSequence) {
std::vector<uint8_t> seq;
- Input yin("", /*Ctxt=*/NULL, suppressErrorMessages);
+ Input yin("", /*Ctxt=*/nullptr, suppressErrorMessages);
yin >> seq;
EXPECT_FALSE(yin.error());
diff --git a/unittests/Support/raw_ostream_test.cpp b/unittests/Support/raw_ostream_test.cpp
index 2b797b4366..44d27d0410 100644
--- a/unittests/Support/raw_ostream_test.cpp
+++ b/unittests/Support/raw_ostream_test.cpp
@@ -69,7 +69,7 @@ TEST(raw_ostreamTest, Types_Buffered) {
EXPECT_EQ("1.100000e+00", printToString(1.1));
// void*
- EXPECT_EQ("0x0", printToString((void*) 0));
+ EXPECT_EQ("0x0", printToString((void*) nullptr));
EXPECT_EQ("0xbeef", printToString((void*) 0xbeef));
EXPECT_EQ("0xdeadbeef", printToString((void*) 0xdeadbeef));
@@ -100,7 +100,7 @@ TEST(raw_ostreamTest, Types_Unbuffered) {
EXPECT_EQ("1.100000e+00", printToStringUnbuffered(1.1));
// void*
- EXPECT_EQ("0x0", printToStringUnbuffered((void*) 0));
+ EXPECT_EQ("0x0", printToStringUnbuffered((void*) nullptr));
EXPECT_EQ("0xbeef", printToStringUnbuffered((void*) 0xbeef));
EXPECT_EQ("0xdeadbeef", printToStringUnbuffered((void*) 0xdeadbeef));
diff --git a/unittests/Transforms/DebugIR/DebugIR.cpp b/unittests/Transforms/DebugIR/DebugIR.cpp
index 9b89c1593c..49ea09f7c6 100644
--- a/unittests/Transforms/DebugIR/DebugIR.cpp
+++ b/unittests/Transforms/DebugIR/DebugIR.cpp
@@ -65,7 +65,7 @@ char * current_dir() {
#if defined(LLVM_ON_WIN32) || defined(HAVE_GETCWD)
// calling getcwd (or _getcwd() on windows) with a null buffer makes it
// allocate a sufficiently sized buffer to store the current working dir.
- return getcwd_impl(0, 0);
+ return getcwd_impl(nullptr, 0);
#else
return 0;
#endif
diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp
index fb27dc1735..b3a1f5b105 100644
--- a/unittests/Transforms/Utils/Cloning.cpp
+++ b/unittests/Transforms/Utils/Cloning.cpp
@@ -32,7 +32,7 @@ namespace {
class CloneInstruction : public ::testing::Test {
protected:
virtual void SetUp() {
- V = NULL;
+ V = nullptr;
}
template <typename T>
@@ -272,7 +272,7 @@ protected:
void CreateNewFunc() {
ValueToValueMapTy VMap;
- NewFunc = CloneFunction(OldFunc, VMap, true, NULL);
+ NewFunc = CloneFunction(OldFunc, VMap, true, nullptr);
M->getFunctionList().push_back(NewFunc);
}
diff --git a/unittests/Transforms/Utils/SpecialCaseList.cpp b/unittests/Transforms/Utils/SpecialCaseList.cpp
index fd00687f89..bcbca493af 100644
--- a/unittests/Transforms/Utils/SpecialCaseList.cpp
+++ b/unittests/Transforms/Utils/SpecialCaseList.cpp
@@ -29,9 +29,9 @@ protected:
GlobalVariable *makeGlobal(StringRef Name, StringRef StructName, Module &M) {
StructType *ST =
- StructType::create(StructName, Type::getInt32Ty(Ctx), (Type*)0);
+ StructType::create(StructName, Type::getInt32Ty(Ctx), (Type*)nullptr);
return new GlobalVariable(
- M, ST, false, GlobalValue::ExternalLinkage, 0, Name);
+ M, ST, false, GlobalValue::ExternalLinkage, nullptr, Name);
}
GlobalAlias *makeAlias(StringRef Name, GlobalObject *Aliasee) {
@@ -209,17 +209,17 @@ TEST_F(SpecialCaseListTest, Substring) {
TEST_F(SpecialCaseListTest, InvalidSpecialCaseList) {
std::string Error;
- EXPECT_EQ(0, makeSpecialCaseList("badline", Error));
+ EXPECT_EQ(nullptr, makeSpecialCaseList("badline", Error));
EXPECT_EQ("Malformed line 1: 'badline'", Error);
- EXPECT_EQ(0, makeSpecialCaseList("src:bad[a-", Error));
+ EXPECT_EQ(nullptr, makeSpecialCaseList("src:bad[a-", Error));
EXPECT_EQ("Malformed regex in line 1: 'bad[a-': invalid character range",
Error);
- EXPECT_EQ(0, makeSpecialCaseList("src:a.c\n"
+ EXPECT_EQ(nullptr, makeSpecialCaseList("src:a.c\n"
"fun:fun(a\n",
Error));
EXPECT_EQ("Malformed regex in line 2: 'fun(a': parentheses not balanced",
Error);
- EXPECT_EQ(0, SpecialCaseList::create("unexisting", Error));
+ EXPECT_EQ(nullptr, SpecialCaseList::create("unexisting", Error));
EXPECT_EQ(0U, Error.find("Can't open file 'unexisting':"));
}