1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[C++11] Use 'nullptr'.

llvm-svn: 210442
This commit is contained in:
Craig Topper 2014-06-08 22:29:17 +00:00
parent eb29e86a73
commit b00824c629
59 changed files with 309 additions and 300 deletions

View File

@ -312,7 +312,7 @@ bool AtomicExpandLoadLinked::expandAtomicCmpXchg(AtomicCmpXchgInst *CI) {
// Setup the builder so we can create any PHIs we need.
Builder.SetInsertPoint(FailureBB, FailureBB->begin());
BasicBlock *SuccessBB = FailureOrder == Monotonic ? BarrierBB : TryStoreBB;
PHINode *Success = 0, *Failure = 0;
PHINode *Success = nullptr, *Failure = nullptr;
// Look for any users of the cmpxchg that are just comparing the loaded value
// against the desired one, and replace them with the CFG-derived version.

View File

@ -263,7 +263,7 @@ bool JumpInstrTables::runOnModule(Module &M) {
if (F.hasFnAttribute(Attribute::JumpTable)) {
assert(F.hasUnnamedAddr() &&
"Attribute 'jumptable' requires 'unnamed_addr'");
Functions[&F] = NULL;
Functions[&F] = nullptr;
}
}

View File

@ -1797,7 +1797,7 @@ SDValue AArch64TargetLowering::LowerFormalArguments(
ArgValue = DAG.getExtLoad(ExtType, DL, VA.getLocVT(), Chain, FIN,
MachinePointerInfo::getFixedStack(FI),
MemVT, false, false, false, 0);
MemVT, false, false, false, nullptr);
InVals.push_back(ArgValue);
}

View File

@ -300,7 +300,7 @@ void FixupLEAPass::processInstructionForSLM(MachineBasicBlock::iterator &I,
}
DEBUG(dbgs() << "FixLEA: Candidate to replace:"; I->dump(););
DEBUG(dbgs() << "FixLEA: Replaced by: ";);
MachineInstr *NewMI = 0;
MachineInstr *NewMI = nullptr;
const MachineOperand &Dst = MI->getOperand(0);
// Make ADD instruction for two registers writing to LEA's destination
if (SrcR1 != 0 && SrcR2 != 0) {

View File

@ -12851,7 +12851,7 @@ static SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, const X86Subtarget *Subtarget,
case PREFETCH: {
SDValue Hint = Op.getOperand(6);
unsigned HintVal;
if (dyn_cast<ConstantSDNode> (Hint) == 0 ||
if (dyn_cast<ConstantSDNode> (Hint) == nullptr ||
(HintVal = dyn_cast<ConstantSDNode> (Hint)->getZExtValue()) > 1)
llvm_unreachable("Wrong prefetch hint in intrinsic: should be 0 or 1");
unsigned Opcode = (HintVal ? Intr.Opc1 : Intr.Opc0);

View File

@ -62,7 +62,7 @@ static bool isEmptyFunction(Function *F) {
if (Entry.size() != 1 || !isa<ReturnInst>(Entry.front()))
return false;
ReturnInst &RI = cast<ReturnInst>(Entry.front());
return RI.getReturnValue() == NULL;
return RI.getReturnValue() == nullptr;
}
char GlobalDCE::ID = 0;

View File

@ -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) {

View File

@ -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>,

View File

@ -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;

View File

@ -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));

View File

@ -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();

View File

@ -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

View File

@ -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.
}
};

View File

@ -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);

View File

@ -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;
}

View File

@ -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
{

View File

@ -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);

View File

@ -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));
}
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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

View File

@ -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 {

View File

@ -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;

View File

@ -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());

View File

@ -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)

View File

@ -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());

View File

@ -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) {

View File

@ -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());

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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 {

View File

@ -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);

View File

@ -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())));
}

View File

@ -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();

View File

@ -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();
}
};

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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();

View File

@ -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]);
}

View File

@ -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));

View File

@ -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);

View File

@ -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());
}
}

View File

@ -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);
}

View File

@ -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());

View File

@ -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));

View File

@ -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

View File

@ -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);
}

View File

@ -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':"));
}

View File

@ -1043,7 +1043,7 @@ bool CheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const {
SMLoc::getFromPointer(Buffer.data())))->getBufferStart() &&
"CHECK-NEXT can't be the first check in a file");
const char *FirstNewLine = 0;
const char *FirstNewLine = nullptr;
unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);
if (NumNewLines == 0) {

View File

@ -219,10 +219,10 @@ static void EvaluateOps(unsigned short Elt, unsigned short Vals[],
int main() {
// Seed the table with accesses to the LHS and RHS.
ShufTab[0x0123].Cost = 0;
ShufTab[0x0123].Op = 0;
ShufTab[0x0123].Op = nullptr;
ShufTab[0x0123].Arg0 = 0x0123;
ShufTab[0x4567].Cost = 0;
ShufTab[0x4567].Op = 0;
ShufTab[0x4567].Op = nullptr;
ShufTab[0x4567].Arg0 = 0x4567;
// Seed the first-level of shuffles, shuffles whose inputs are the input to

View File

@ -30,7 +30,8 @@ int main(int argc, const char **argv) {
std::string Program = sys::FindProgramByName(argv[0]);
std::string ErrMsg;
int Result = sys::ExecuteAndWait(Program, argv, 0, 0, 0, 0, &ErrMsg);
int Result = sys::ExecuteAndWait(Program, argv, nullptr, nullptr, 0, 0,
&ErrMsg);
if (Result < 0) {
errs() << "Error: " << ErrMsg << "\n";
if (ExpectCrash)