summaryrefslogtreecommitdiff
path: root/unittests/ExecutionEngine
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/ExecutionEngine
parentd8fdbb2ea84afd9be849e4237634ec09879a2d36 (diff)
[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/ExecutionEngine')
-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
8 files changed, 70 insertions, 70 deletions
diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp
index e6f07dce1e5..f23745c19db 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 ab308844f27..296838de61b 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 f438286f317..5eb52c6f017 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 5016532eef8..f530e0de5d5 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 20d3f139b4c..d03de898b4e 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 f862999da86..98587f7e85c 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 46847d3e512..fbbab42dbb0 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 a439508af0c..c37c1d1d599 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)