llvm.org GIT mirror llvm / b177041
[C++11] Use 'nullptr'. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210442 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 5 years ago
59 changed file(s) with 350 addition(s) and 341 deletion(s). Raw diff Collapse all Expand all
311311 // Setup the builder so we can create any PHIs we need.
312312 Builder.SetInsertPoint(FailureBB, FailureBB->begin());
313313 BasicBlock *SuccessBB = FailureOrder == Monotonic ? BarrierBB : TryStoreBB;
314 PHINode *Success = 0, *Failure = 0;
314 PHINode *Success = nullptr, *Failure = nullptr;
315315
316316 // Look for any users of the cmpxchg that are just comparing the loaded value
317317 // against the desired one, and replace them with the CFG-derived version.
262262 if (F.hasFnAttribute(Attribute::JumpTable)) {
263263 assert(F.hasUnnamedAddr() &&
264264 "Attribute 'jumptable' requires 'unnamed_addr'");
265 Functions[&F] = NULL;
265 Functions[&F] = nullptr;
266266 }
267267 }
268268
17961796
17971797 ArgValue = DAG.getExtLoad(ExtType, DL, VA.getLocVT(), Chain, FIN,
17981798 MachinePointerInfo::getFixedStack(FI),
1799 MemVT, false, false, false, 0);
1799 MemVT, false, false, false, nullptr);
18001800
18011801 InVals.push_back(ArgValue);
18021802 }
299299 }
300300 DEBUG(dbgs() << "FixLEA: Candidate to replace:"; I->dump(););
301301 DEBUG(dbgs() << "FixLEA: Replaced by: ";);
302 MachineInstr *NewMI = 0;
302 MachineInstr *NewMI = nullptr;
303303 const MachineOperand &Dst = MI->getOperand(0);
304304 // Make ADD instruction for two registers writing to LEA's destination
305305 if (SrcR1 != 0 && SrcR2 != 0) {
1285012850 case PREFETCH: {
1285112851 SDValue Hint = Op.getOperand(6);
1285212852 unsigned HintVal;
12853 if (dyn_cast (Hint) == 0 ||
12853 if (dyn_cast (Hint) == nullptr ||
1285412854 (HintVal = dyn_cast (Hint)->getZExtValue()) > 1)
1285512855 llvm_unreachable("Wrong prefetch hint in intrinsic: should be 0 or 1");
1285612856 unsigned Opcode = (HintVal ? Intr.Opc1 : Intr.Opc0);
6161 if (Entry.size() != 1 || !isa(Entry.front()))
6262 return false;
6363 ReturnInst &RI = cast(Entry.front());
64 return RI.getReturnValue() == NULL;
64 return RI.getReturnValue() == nullptr;
6565 }
6666
6767 char GlobalDCE::ID = 0;
11721172 EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(8.5070592e+37f)));
11731173
11741174 // Large float, inverse is a denormal.
1175 EXPECT_FALSE(APFloat(1.7014118e38f).getExactInverse(0));
1175 EXPECT_FALSE(APFloat(1.7014118e38f).getExactInverse(nullptr));
11761176 // Zero
1177 EXPECT_FALSE(APFloat(0.0).getExactInverse(0));
1177 EXPECT_FALSE(APFloat(0.0).getExactInverse(nullptr));
11781178 // Denormalized float
1179 EXPECT_FALSE(APFloat(1.40129846e-45f).getExactInverse(0));
1179 EXPECT_FALSE(APFloat(1.40129846e-45f).getExactInverse(nullptr));
11801180 }
11811181
11821182 TEST(APFloatTest, roundToIntegral) {
9191 };
9292
9393 template
94 typename T::key_type *const DenseMapTest::dummy_key_ptr = 0;
94 typename T::key_type *const DenseMapTest::dummy_key_ptr = nullptr;
9595 template
96 typename T::mapped_type *const DenseMapTest::dummy_value_ptr = 0;
96 typename T::mapped_type *const DenseMapTest::dummy_value_ptr = nullptr;
9797
9898 // Register these types for testing.
9999 typedef ::testing::Types,
5757
5858 TEST(HashingTest, HashValueBasicTest) {
5959 int x = 42, y = 43, c = 'x';
60 void *p = 0;
60 void *p = nullptr;
6161 uint64_t i = 71;
6262 const unsigned ci = 71;
6363 volatile int vi = 71;
3535 EXPECT_TRUE(S.isEmpty());
3636 EXPECT_FALSE(S2.isEmpty());
3737
38 EXPECT_EQ(0, S.lookup(3));
39 EXPECT_EQ(0, S.lookup(9));
38 EXPECT_EQ(nullptr, S.lookup(3));
39 EXPECT_EQ(nullptr, S.lookup(9));
4040
4141 EXPECT_EQ(10, *S2.lookup(3));
4242 EXPECT_EQ(11, *S2.lookup(4));
7373
7474 TEST_F(OwningPtrTest, Take) {
7575 TrackDestructor::ResetCounts();
76 TrackDestructor *T = 0;
76 TrackDestructor *T = nullptr;
7777 {
7878 OwningPtr O(new TrackDestructor(3));
7979 T = O.take();
9191
9292 TEST_F(OwningPtrTest, Release) {
9393 TrackDestructor::ResetCounts();
94 TrackDestructor *T = 0;
94 TrackDestructor *T = nullptr;
9595 {
9696 OwningPtr O(new TrackDestructor(3));
9797 T = O.release();
6565 TEST_F(PointerUnionTest, Get) {
6666 EXPECT_EQ(a.get(), &f);
6767 EXPECT_EQ(b.get(), &i);
68 EXPECT_EQ(n.get(), (int *)0);
68 EXPECT_EQ(n.get(), (int *)nullptr);
6969 }
7070
7171 } // end anonymous namespace
212212 // Return a pointer to it.
213213 return FirstNode + i;
214214 assert(false && "Dereferencing end iterator!");
215 return 0; // Avoid compiler warning.
215 return nullptr; // Avoid compiler warning.
216216 }
217217 };
218218
2828 ilist List;
2929 List.push_back(Node(1));
3030 EXPECT_EQ(1, List.back().Value);
31 EXPECT_EQ(0, List.back().getPrevNode());
32 EXPECT_EQ(0, List.back().getNextNode());
31 EXPECT_EQ(nullptr, List.back().getPrevNode());
32 EXPECT_EQ(nullptr, List.back().getNextNode());
3333
3434 List.push_back(Node(2));
3535 EXPECT_EQ(2, List.back().Value);
4545 }
4646
4747 Function *F = M->getFunction("test");
48 if (F == NULL)
48 if (F == nullptr)
4949 report_fatal_error("Test must have a function named @test");
5050
51 A = B = NULL;
51 A = B = nullptr;
5252 for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
5353 if (I->hasName()) {
5454 if (I->getName() == "A")
5757 B = &*I;
5858 }
5959 }
60 if (A == NULL)
60 if (A == nullptr)
6161 report_fatal_error("@test must have an instruction %A");
62 if (B == NULL)
62 if (B == nullptr)
6363 report_fatal_error("@test must have an instruction %B");
6464 }
6565
7373
7474 static int initialize() {
7575 PassInfo *PI = new PassInfo("isPotentiallyReachable testing pass",
76 "", &ID, 0, true, true);
76 "", &ID, nullptr, true, true);
7777 PassRegistry::getPassRegistry()->registerPass(*PI, false);
7878 initializeLoopInfoPass(*PassRegistry::getPassRegistry());
7979 initializeDominatorTreeWrapperPassPass(
9494 LoopInfo *LI = &getAnalysis();
9595 DominatorTree *DT =
9696 &getAnalysis().getDomTree();
97 EXPECT_EQ(isPotentiallyReachable(A, B, 0, 0), ExpectedResult);
98 EXPECT_EQ(isPotentiallyReachable(A, B, DT, 0), ExpectedResult);
99 EXPECT_EQ(isPotentiallyReachable(A, B, 0, LI), ExpectedResult);
97 EXPECT_EQ(isPotentiallyReachable(A, B, nullptr, nullptr),
98 ExpectedResult);
99 EXPECT_EQ(isPotentiallyReachable(A, B, DT, nullptr), ExpectedResult);
100 EXPECT_EQ(isPotentiallyReachable(A, B, nullptr, LI), ExpectedResult);
100101 EXPECT_EQ(isPotentiallyReachable(A, B, DT, LI), ExpectedResult);
101102 return false;
102103 }
4242
4343 auto *Store1 = new StoreInst(Value, Addr, BB);
4444 auto *Store2 = new StoreInst(Value, Addr, BB);
45 ReturnInst::Create(C, 0, BB);
45 ReturnInst::Create(C, nullptr, BB);
4646
4747 // New TBAA metadata
4848 {
4040 std::vector(), false);
4141 Function *F = cast(M.getOrInsertFunction("f", FTy));
4242 BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
43 ReturnInst::Create(Context, 0, BB);
43 ReturnInst::Create(Context, nullptr, BB);
4444
4545 Type *Ty = Type::getInt1Ty(Context);
4646 Constant *Init = Constant::getNullValue(Ty);
9393 FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), Types, false);
9494 Function *F = cast(M.getOrInsertFunction("f", FTy));
9595 BasicBlock *BB = BasicBlock::Create(Context, "entry", F);
96 ReturnInst::Create(Context, 0, BB);
96 ReturnInst::Create(Context, nullptr, BB);
9797
9898 // Create a ScalarEvolution and "run" it so that it gets initialized.
9999 PM.add(&SE);
2525 }
2626
2727 virtual void SetUp() {
28 ASSERT_TRUE(Engine.get() != NULL) << "EngineBuilder returned error: '"
28 ASSERT_TRUE(Engine.get() != nullptr) << "EngineBuilder returned error: '"
2929 << Error << "'";
3030 }
3131
3232 GlobalVariable *NewExtGlobal(Type *T, const Twine &Name) {
3333 return new GlobalVariable(*M, T, false, // Not constant.
34 GlobalValue::ExternalLinkage, NULL, Name);
34 GlobalValue::ExternalLinkage, nullptr, Name);
3535 }
3636
3737 Module *const M;
4848 int32_t Mem2 = 4;
4949 Engine->updateGlobalMapping(G1, &Mem2);
5050 EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1));
51 Engine->updateGlobalMapping(G1, NULL);
52 EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G1));
51 Engine->updateGlobalMapping(G1, nullptr);
52 EXPECT_EQ(nullptr, Engine->getPointerToGlobalIfAvailable(G1));
5353 Engine->updateGlobalMapping(G1, &Mem2);
5454 EXPECT_EQ(&Mem2, Engine->getPointerToGlobalIfAvailable(G1));
5555
5656 GlobalVariable *G2 =
5757 NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global1");
58 EXPECT_EQ(NULL, Engine->getPointerToGlobalIfAvailable(G2))
58 EXPECT_EQ(nullptr, Engine->getPointerToGlobalIfAvailable(G2))
5959 << "The NULL return shouldn't depend on having called"
6060 << " updateGlobalMapping(..., NULL)";
6161 // Check that update...() can be called before add...().
7474 EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem1));
7575 int32_t Mem2 = 4;
7676 Engine->updateGlobalMapping(G1, &Mem2);
77 EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
77 EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
7878 EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2));
7979
8080 GlobalVariable *G2 =
8282 Engine->updateGlobalMapping(G2, &Mem1);
8383 EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1));
8484 EXPECT_EQ(G1, Engine->getGlobalValueAtAddress(&Mem2));
85 Engine->updateGlobalMapping(G1, NULL);
85 Engine->updateGlobalMapping(G1, nullptr);
8686 EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem1))
8787 << "Removing one mapping doesn't affect a different one.";
88 EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem2));
88 EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem2));
8989 Engine->updateGlobalMapping(G2, &Mem2);
90 EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
90 EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
9191 EXPECT_EQ(G2, Engine->getGlobalValueAtAddress(&Mem2))
9292 << "Once a mapping is removed, we can point another GV at the"
9393 << " now-free address.";
103103
104104 Engine->clearGlobalMappingsFromModule(M);
105105
106 EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
106 EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
107107
108108 GlobalVariable *G2 =
109109 NewExtGlobal(Type::getInt32Ty(getGlobalContext()), "Global2");
123123 // When the GV goes away, the ExecutionEngine should remove any
124124 // mappings that refer to it.
125125 G1->eraseFromParent();
126 EXPECT_EQ(NULL, Engine->getGlobalValueAtAddress(&Mem1));
126 EXPECT_EQ(nullptr, Engine->getGlobalValueAtAddress(&Mem1));
127127 }
128128
129129 }
266266
267267 // After allocating a bunch of stubs, we should have two.
268268 for (int I = 0; I < Iters; ++I)
269 MemMgr->allocateStub(NULL, Size, 8);
269 MemMgr->allocateStub(nullptr, Size, 8);
270270 EXPECT_EQ(2U, MemMgr->GetNumStubSlabs());
271271
272272 // And after much more, we should have three.
273273 for (int I = 0; I < Iters; ++I)
274 MemMgr->allocateStub(NULL, Size, 8);
274 MemMgr->allocateStub(nullptr, Size, 8);
275275 EXPECT_EQ(3U, MemMgr->GetNumStubSlabs());
276276 }
277277
285285 uint8_t *data2 = MemMgr->allocateDataSection(256, 64, 4, StringRef(), false);
286286 uint8_t *code3 = MemMgr->allocateCodeSection(258, 64, 5, StringRef());
287287
288 EXPECT_NE((uint8_t*)0, code1);
289 EXPECT_NE((uint8_t*)0, code2);
290 EXPECT_NE((uint8_t*)0, data1);
291 EXPECT_NE((uint8_t*)0, data2);
288 EXPECT_NE((uint8_t*)nullptr, code1);
289 EXPECT_NE((uint8_t*)nullptr, code2);
290 EXPECT_NE((uint8_t*)nullptr, data1);
291 EXPECT_NE((uint8_t*)nullptr, data2);
292292
293293 // Check alignment
294294 EXPECT_EQ((uint64_t)code1 & 0xf, 0u);
168168 bool LoadAssemblyInto(Module *M, const char *assembly) {
169169 SMDiagnostic Error;
170170 bool success =
171 NULL != ParseAssemblyString(assembly, M, Error, M->getContext());
171 nullptr != ParseAssemblyString(assembly, M, Error, M->getContext());
172172 std::string errMsg;
173173 raw_string_ostream os(errMsg);
174174 Error.print("", os);
192192 .setJITMemoryManager(RJMM)
193193 .setErrorStr(&Error)
194194 .setTargetOptions(Options).create());
195 ASSERT_TRUE(TheJIT.get() != NULL) << Error;
195 ASSERT_TRUE(TheJIT.get() != nullptr) << Error;
196196 }
197197
198198 void LoadAssembly(const char *assembly) {
248248
249249 // Since F1 was codegen'd, a pointer to G should be available.
250250 int32_t *GPtr = (int32_t*)JIT->getPointerToGlobalIfAvailable(G);
251 ASSERT_NE((int32_t*)NULL, GPtr);
251 ASSERT_NE((int32_t*)nullptr, GPtr);
252252 EXPECT_EQ(0, *GPtr);
253253
254254 // F1() should increment G.
635635 if (error_code EC = ModuleOrErr.getError()) {
636636 ADD_FAILURE() << EC.message();
637637 delete BitcodeBuffer;
638 return NULL;
638 return nullptr;
639639 }
640640 M = ModuleOrErr.get();
641641 std::string errMsg;
643643 .setEngineKind(EngineKind::JIT)
644644 .setErrorStr(&errMsg)
645645 .create();
646 if (TheJIT == NULL) {
646 if (TheJIT == nullptr) {
647647 ADD_FAILURE() << errMsg;
648648 delete M;
649 M = NULL;
650 return NULL;
649 M = nullptr;
650 return nullptr;
651651 }
652652 return TheJIT;
653653 }
2626 bool LoadAssemblyInto(Module *M, const char *assembly) {
2727 SMDiagnostic Error;
2828 bool success =
29 NULL != ParseAssemblyString(assembly, M, Error, M->getContext());
29 nullptr != ParseAssemblyString(assembly, M, Error, M->getContext());
3030 std::string errMsg;
3131 raw_string_ostream os(errMsg);
3232 Error.print("", os);
7070
7171 TEST(MultiJitTest, EagerMode) {
7272 LLVMContext Context1;
73 Module *M1 = 0;
74 Function *FooF1 = 0;
73 Module *M1 = nullptr;
74 Function *FooF1 = nullptr;
7575 createModule1(Context1, M1, FooF1);
7676
7777 LLVMContext Context2;
78 Module *M2 = 0;
79 Function *FooF2 = 0;
78 Module *M2 = nullptr;
79 Function *FooF2 = nullptr;
8080 createModule2(Context2, M2, FooF2);
8181
8282 // Now we create the JIT in eager mode
100100
101101 TEST(MultiJitTest, LazyMode) {
102102 LLVMContext Context1;
103 Module *M1 = 0;
104 Function *FooF1 = 0;
103 Module *M1 = nullptr;
104 Function *FooF1 = nullptr;
105105 createModule1(Context1, M1, FooF1);
106106
107107 LLVMContext Context2;
108 Module *M2 = 0;
109 Function *FooF2 = 0;
108 Module *M2 = nullptr;
109 Function *FooF2 = nullptr;
110110 createModule2(Context2, M2, FooF2);
111111
112112 // Now we create the JIT in lazy mode
134134
135135 TEST(MultiJitTest, JitPool) {
136136 LLVMContext Context1;
137 Module *M1 = 0;
138 Function *FooF1 = 0;
137 Module *M1 = nullptr;
138 Function *FooF1 = nullptr;
139139 createModule1(Context1, M1, FooF1);
140140
141141 LLVMContext Context2;
142 Module *M2 = 0;
143 Function *FooF2 = 0;
142 Module *M2 = nullptr;
143 Function *FooF2 = nullptr;
144144 createModule2(Context2, M2, FooF2);
145145
146146 // Now we create two JITs
147147 didCallAllocateCodeSection = false;
148148 didAllocateCompactUnwindSection = false;
149149 didCallYield = false;
150 Module = 0;
151 Function = 0;
152 Engine = 0;
153 Error = 0;
150 Module = nullptr;
151 Function = nullptr;
152 Engine = nullptr;
153 Error = nullptr;
154154 }
155155
156156 virtual void TearDown() {
165165
166166 LLVMSetTarget(Module, HostTriple.c_str());
167167
168 Function = LLVMAddFunction(
169 Module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0));
168 Function = LLVMAddFunction(Module, "simple_function",
169 LLVMFunctionType(LLVMInt32Type(), nullptr,0, 0));
170170 LLVMSetFunctionCallConv(Function, LLVMCCallConv);
171171
172172 LLVMBasicBlockRef entry = LLVMAppendBasicBlock(Function, "entry");
191191 LLVMFunctionType(LLVMVoidType(), stackmapParamTypes, 2, 1));
192192 LLVMSetLinkage(stackmap, LLVMExternalLinkage);
193193
194 Function = LLVMAddFunction(
195 Module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0));
194 Function = LLVMAddFunction(Module, "simple_function",
195 LLVMFunctionType(LLVMInt32Type(), nullptr, 0, 0));
196196
197197 LLVMBasicBlockRef entry = LLVMAppendBasicBlock(Function, "entry");
198198 LLVMBuilderRef builder = LLVMCreateBuilder();
220220 LLVMSetInitializer(GlobalVar, LLVMConstInt(LLVMInt32Type(), 42, 0));
221221
222222 {
223 Function = LLVMAddFunction(
224 Module, "getGlobal", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0));
223 Function = LLVMAddFunction(Module, "getGlobal",
224 LLVMFunctionType(LLVMInt32Type(), nullptr, 0, 0));
225225 LLVMSetFunctionCallConv(Function, LLVMCCallConv);
226226
227227 LLVMBasicBlockRef Entry = LLVMAppendBasicBlock(Function, "entry");
442442 buildMCJITOptions();
443443 buildMCJITEngine();
444444 LLVMContextRef C = LLVMGetGlobalContext();
445 LLVMContextSetYieldCallback(C, yield, NULL);
445 LLVMContextSetYieldCallback(C, yield, nullptr);
446446 buildAndRunPasses();
447447
448448 union {
2222 uint8_t *code2 = MemMgr->allocateCodeSection(256, 0, 3, "");
2323 uint8_t *data2 = MemMgr->allocateDataSection(256, 0, 4, "", false);
2424
25 EXPECT_NE((uint8_t*)0, code1);
26 EXPECT_NE((uint8_t*)0, code2);
27 EXPECT_NE((uint8_t*)0, data1);
28 EXPECT_NE((uint8_t*)0, data2);
25 EXPECT_NE((uint8_t*)nullptr, code1);
26 EXPECT_NE((uint8_t*)nullptr, code2);
27 EXPECT_NE((uint8_t*)nullptr, data1);
28 EXPECT_NE((uint8_t*)nullptr, data2);
2929
3030 // Initialize the data
3131 for (unsigned i = 0; i < 256; ++i) {
5555 uint8_t *code2 = MemMgr->allocateCodeSection(0x100000, 0, 3, "");
5656 uint8_t *data2 = MemMgr->allocateDataSection(0x100000, 0, 4, "", false);
5757
58 EXPECT_NE((uint8_t*)0, code1);
59 EXPECT_NE((uint8_t*)0, code2);
60 EXPECT_NE((uint8_t*)0, data1);
61 EXPECT_NE((uint8_t*)0, data2);
58 EXPECT_NE((uint8_t*)nullptr, code1);
59 EXPECT_NE((uint8_t*)nullptr, code2);
60 EXPECT_NE((uint8_t*)nullptr, data1);
61 EXPECT_NE((uint8_t*)nullptr, data2);
6262
6363 // Initialize the data
6464 for (unsigned i = 0; i < 0x100000; ++i) {
9797 data[i][j] = 2 + (i % 254);
9898 }
9999
100 EXPECT_NE((uint8_t *)0, code[i]);
101 EXPECT_NE((uint8_t *)0, data[i]);
100 EXPECT_NE((uint8_t *)nullptr, code[i]);
101 EXPECT_NE((uint8_t *)nullptr, data[i]);
102102 }
103103
104104 // Verify the data (this is checking for overlaps in the addresses)
140140 data[i][j] = 2 + (i % 254);
141141 }
142142
143 EXPECT_NE((uint8_t *)0, code[i]);
144 EXPECT_NE((uint8_t *)0, data[i]);
143 EXPECT_NE((uint8_t *)nullptr, code[i]);
144 EXPECT_NE((uint8_t *)nullptr, data[i]);
145145
146146 uintptr_t CodeAlign = Align ? (uintptr_t)code[i] % Align : 0;
147147 uintptr_t DataAlign = Align ? (uintptr_t)data[i] % Align : 0;
4747 const MemoryBuffer* BufferFound = getObjectInternal(M);
4848 ModulesLookedUp.insert(M->getModuleIdentifier());
4949 if (!BufferFound)
50 return NULL;
50 return nullptr;
5151 // Our test cache wants to maintain ownership of its object buffers
5252 // so we make a copy here for the execution engine.
5353 return MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer());
6666 const std::string ModuleID = M->getModuleIdentifier();
6767 StringMap::iterator it = ObjMap.find(ModuleID);
6868 if (it == ObjMap.end())
69 return 0;
69 return nullptr;
7070 return it->second;
7171 }
7272
100100 void compileAndRun(int ExpectedRC = OriginalRC) {
101101 // This function shouldn't be called until after SetUp.
102102 ASSERT_TRUE(bool(TheJIT));
103 ASSERT_TRUE(0 != Main);
103 ASSERT_TRUE(nullptr != Main);
104104
105105 // We may be using a null cache, so ensure compilation is valid.
106106 TheJIT->finalizeObject();
107107 void *vPtr = TheJIT->getPointerToFunction(Main);
108108
109 EXPECT_TRUE(0 != vPtr)
109 EXPECT_TRUE(nullptr != vPtr)
110110 << "Unable to get pointer to main() from JIT";
111111
112112 int (*FuncPtr)(void) = (int(*)(void))(intptr_t)vPtr;
122122
123123 createJIT(M.release());
124124
125 TheJIT->setObjectCache(NULL);
125 TheJIT->setObjectCache(nullptr);
126126
127127 compileAndRun();
128128 }
142142
143143 // Verify that our object cache does not contain the module yet.
144144 const MemoryBuffer *ObjBuffer = Cache->getObjectInternal(SavedModulePointer);
145 EXPECT_EQ(0, ObjBuffer);
145 EXPECT_EQ(nullptr, ObjBuffer);
146146
147147 compileAndRun();
148148
151151
152152 // Verify that our object cache now contains the module.
153153 ObjBuffer = Cache->getObjectInternal(SavedModulePointer);
154 EXPECT_TRUE(0 != ObjBuffer);
154 EXPECT_TRUE(nullptr != ObjBuffer);
155155
156156 // Verify that the cache was only notified once.
157157 EXPECT_FALSE(Cache->wereDuplicatesInserted());
220220
221221 // Verify that our object cache does not contain the module yet.
222222 const MemoryBuffer *ObjBuffer = Cache->getObjectInternal(SecondModulePointer);
223 EXPECT_EQ(0, ObjBuffer);
223 EXPECT_EQ(nullptr, ObjBuffer);
224224
225225 // Run the function and look for the replacement return code.
226226 compileAndRun(ReplacementRC);
230230
231231 // Verify that our object cache now contains the module.
232232 ObjBuffer = Cache->getObjectInternal(SecondModulePointer);
233 EXPECT_TRUE(0 != ObjBuffer);
233 EXPECT_TRUE(nullptr != ObjBuffer);
234234
235235 // Verify that MCJIT didn't try to cache this again.
236236 EXPECT_FALSE(Cache->wereDuplicatesInserted());
5050 GlobalValue *Global = insertGlobalInt32(M.get(), "test_global", initialValue);
5151 createJIT(M.release());
5252 void *globalPtr = TheJIT->getPointerToGlobal(Global);
53 EXPECT_TRUE(0 != globalPtr)
53 EXPECT_TRUE(nullptr != globalPtr)
5454 << "Unable to get pointer to global value from JIT";
5555
5656 EXPECT_EQ(initialValue, *(int32_t*)globalPtr)
9898 }
9999
100100 TEST_F(ConstantRangeTest, SingleElement) {
101 EXPECT_EQ(Full.getSingleElement(), static_cast(NULL));
102 EXPECT_EQ(Empty.getSingleElement(), static_cast(NULL));
101 EXPECT_EQ(Full.getSingleElement(), static_cast(nullptr));
102 EXPECT_EQ(Empty.getSingleElement(), static_cast(nullptr));
103103 EXPECT_EQ(*One.getSingleElement(), APInt(16, 0xa));
104 EXPECT_EQ(Some.getSingleElement(), static_cast(NULL));
105 EXPECT_EQ(Wrap.getSingleElement(), static_cast(NULL));
104 EXPECT_EQ(Some.getSingleElement(), static_cast(nullptr));
105 EXPECT_EQ(Wrap.getSingleElement(), static_cast(nullptr));
106106
107107 EXPECT_FALSE(Full.isSingleElement());
108108 EXPECT_FALSE(Empty.isSingleElement());
212212 "}\n";
213213 LLVMContext &C = getGlobalContext();
214214 SMDiagnostic Err;
215 return ParseAssemblyString(ModuleStrig, NULL, Err, C);
215 return ParseAssemblyString(ModuleStrig, nullptr, Err, C);
216216 }
217217
218218 TEST(DominatorTree, Unreachable) {
3030 F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
3131 BB = BasicBlock::Create(Ctx, "", F);
3232 GV = new GlobalVariable(*M, Type::getFloatTy(Ctx), true,
33 GlobalValue::ExternalLinkage, 0);
33 GlobalValue::ExternalLinkage, nullptr);
3434 }
3535
3636 virtual void TearDown() {
37 BB = 0;
37 BB = nullptr;
3838 M.reset();
3939 }
4040
7070
7171 IntrinsicInst *II_Start1 = dyn_cast(Start1);
7272 IntrinsicInst *II_End1 = dyn_cast(End1);
73 ASSERT_TRUE(II_Start1 != NULL);
73 ASSERT_TRUE(II_Start1 != nullptr);
7474 EXPECT_EQ(II_Start1->getIntrinsicID(), Intrinsic::lifetime_start);
75 ASSERT_TRUE(II_End1 != NULL);
75 ASSERT_TRUE(II_End1 != nullptr);
7676 EXPECT_EQ(II_End1->getIntrinsicID(), Intrinsic::lifetime_end);
7777 }
7878
202202
203203 // Test instructions.
204204 GlobalVariable *G = new GlobalVariable(*M, Builder.getInt32Ty(), true,
205 GlobalValue::ExternalLinkage, 0);
205 GlobalValue::ExternalLinkage, nullptr);
206206 Value *V = Builder.CreateLoad(G);
207207 EXPECT_TRUE(
208208 cast(Builder.CreateNSWAdd(V, V))->hasNoSignedWrap());
414414 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt,
415415 CastInst::IntToPtr,
416416 Int64PtrTy, Int64Ty, Int64PtrTy,
417 Int32Ty, 0, Int32Ty),
417 Int32Ty, nullptr, Int32Ty),
418418 CastInst::BitCast);
419419
420420 // Source and destination have unknown sizes, but the same address space and
422422 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt,
423423 CastInst::IntToPtr,
424424 Int64PtrTy, Int64Ty, Int64PtrTy,
425 0, 0, 0),
425 nullptr, nullptr, nullptr),
426426 CastInst::BitCast);
427427
428428 // Source and destination have unknown sizes, but the same address space and
430430 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::PtrToInt,
431431 CastInst::IntToPtr,
432432 Int64PtrTy, Int32Ty, Int64PtrTy,
433 0, 0, 0),
433 nullptr, nullptr, nullptr),
434434 0U);
435435
436436 // Middle pointer big enough -> bitcast.
437437 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr,
438438 CastInst::PtrToInt,
439439 Int64Ty, Int64PtrTy, Int64Ty,
440 0, Int64Ty, 0),
440 nullptr, Int64Ty, nullptr),
441441 CastInst::BitCast);
442442
443443 // Middle pointer too small -> fail.
444444 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr,
445445 CastInst::PtrToInt,
446446 Int64Ty, Int64PtrTy, Int64Ty,
447 0, Int32Ty, 0),
447 nullptr, Int32Ty, nullptr),
448448 0U);
449449
450450 // Test that we don't eliminate bitcasts between different address spaces,
463463 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr,
464464 CastInst::AddrSpaceCast,
465465 Int16Ty, Int64PtrTyAS1, Int64PtrTyAS2,
466 0, Int16SizePtr, Int64SizePtr),
466 nullptr, Int16SizePtr, Int64SizePtr),
467467 0U);
468468
469469 // Cannot simplify addrspacecast, ptrtoint
470470 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::AddrSpaceCast,
471471 CastInst::PtrToInt,
472472 Int64PtrTyAS1, Int64PtrTyAS2, Int16Ty,
473 Int64SizePtr, Int16SizePtr, 0),
473 Int64SizePtr, Int16SizePtr, nullptr),
474474 0U);
475475
476476 // Pass since the bitcast address spaces are the same
477477 EXPECT_EQ(CastInst::isEliminableCastPair(CastInst::IntToPtr,
478478 CastInst::BitCast,
479479 Int16Ty, Int64PtrTyAS1, Int64PtrTyAS1,
480 0, 0, 0),
480 nullptr, nullptr, nullptr),
481481 CastInst::IntToPtr);
482482
483483 }
475475 // Function: test1 (func_test1)
476476 {
477477
478 BasicBlock* label_entry = BasicBlock::Create(getGlobalContext(), "entry",func_test1,0);
478 BasicBlock* label_entry = BasicBlock::Create(getGlobalContext(), "entry",func_test1,nullptr);
479479
480480 // Block entry (label_entry)
481481 CallInst* int32_3 = CallInst::Create(func_test2, "", label_entry);
490490 // Function: test2 (func_test2)
491491 {
492492
493 BasicBlock* label_entry_5 = BasicBlock::Create(getGlobalContext(), "entry",func_test2,0);
493 BasicBlock* label_entry_5 = BasicBlock::Create(getGlobalContext(), "entry",func_test2,nullptr);
494494
495495 // Block entry (label_entry_5)
496496 CallInst* int32_6 = CallInst::Create(func_test3, "", label_entry_5);
505505 // Function: test3 (func_test3)
506506 {
507507
508 BasicBlock* label_entry_8 = BasicBlock::Create(getGlobalContext(), "entry",func_test3,0);
508 BasicBlock* label_entry_8 = BasicBlock::Create(getGlobalContext(), "entry",func_test3,nullptr);
509509
510510 // Block entry (label_entry_8)
511511 CallInst* int32_9 = CallInst::Create(func_test1, "", label_entry_8);
523523 Value* int1_f = args++;
524524 int1_f->setName("f");
525525
526 BasicBlock* label_entry_11 = BasicBlock::Create(getGlobalContext(), "entry",func_test4,0);
527 BasicBlock* label_bb = BasicBlock::Create(getGlobalContext(), "bb",func_test4,0);
528 BasicBlock* label_bb1 = BasicBlock::Create(getGlobalContext(), "bb1",func_test4,0);
529 BasicBlock* label_return = BasicBlock::Create(getGlobalContext(), "return",func_test4,0);
526 BasicBlock* label_entry_11 = BasicBlock::Create(getGlobalContext(), "entry",func_test4,nullptr);
527 BasicBlock* label_bb = BasicBlock::Create(getGlobalContext(), "bb",func_test4,nullptr);
528 BasicBlock* label_bb1 = BasicBlock::Create(getGlobalContext(), "bb1",func_test4,nullptr);
529 BasicBlock* label_return = BasicBlock::Create(getGlobalContext(), "return",func_test4,nullptr);
530530
531531 // Block entry (label_entry_11)
532532 BranchInst::Create(label_bb, label_entry_11);
3232 MDBuilder MDHelper(Context);
3333 MDNode *MD0 = MDHelper.createFPMath(0.0);
3434 MDNode *MD1 = MDHelper.createFPMath(1.0);
35 EXPECT_EQ(MD0, (MDNode *)0);
36 EXPECT_NE(MD1, (MDNode *)0);
35 EXPECT_EQ(MD0, (MDNode *)nullptr);
36 EXPECT_NE(MD1, (MDNode *)nullptr);
3737 EXPECT_EQ(MD1->getNumOperands(), 1U);
3838 Value *Op = MD1->getOperand(0);
3939 EXPECT_TRUE(isa(Op));
4646 APInt A(8, 1), B(8, 2);
4747 MDNode *R0 = MDHelper.createRange(A, A);
4848 MDNode *R1 = MDHelper.createRange(A, B);
49 EXPECT_EQ(R0, (MDNode *)0);
50 EXPECT_NE(R1, (MDNode *)0);
49 EXPECT_EQ(R0, (MDNode *)nullptr);
50 EXPECT_NE(R1, (MDNode *)nullptr);
5151 EXPECT_EQ(R1->getNumOperands(), 2U);
5252 EXPECT_TRUE(isa(R1->getOperand(0)));
5353 EXPECT_TRUE(isa(R1->getOperand(1)));
6565 EXPECT_GE(R1->getNumOperands(), 1U);
6666 EXPECT_EQ(R0->getOperand(0), R0);
6767 EXPECT_EQ(R1->getOperand(0), R1);
68 EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == 0);
69 EXPECT_TRUE(R1->getNumOperands() == 1 || R1->getOperand(1) == 0);
68 EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == nullptr);
69 EXPECT_TRUE(R1->getNumOperands() == 1 || R1->getOperand(1) == nullptr);
7070 }
7171 TEST_F(MDBuilderTest, createTBAARoot) {
7272 MDBuilder MDHelper(Context);
7676 EXPECT_GE(R0->getNumOperands(), 1U);
7777 EXPECT_TRUE(isa(R0->getOperand(0)));
7878 EXPECT_EQ(cast(R0->getOperand(0))->getString(), "Root");
79 EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == 0);
79 EXPECT_TRUE(R0->getNumOperands() == 1 || R0->getOperand(1) == nullptr);
8080 }
8181 TEST_F(MDBuilderTest, createTBAANode) {
8282 MDBuilder MDHelper(Context);
102102 #endif
103103 EXPECT_EQ(n4, n1);
104104 EXPECT_EQ(n5, n2);
105 EXPECT_EQ(n6, (Value*)0);
105 EXPECT_EQ(n6, (Value*)nullptr);
106106
107107 EXPECT_EQ(3u, n1->getNumOperands());
108108 EXPECT_EQ(s1, n1->getOperand(0));
167167 Module *parseIR(const char *IR) {
168168 LLVMContext &C = getGlobalContext();
169169 SMDiagnostic Err;
170 return ParseAssemblyString(IR, 0, Err, C);
170 return ParseAssemblyString(IR, nullptr, Err, C);
171171 }
172172
173173 class PassManagerTest : public ::testing::Test {
229229 m_NSWAdd(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNSWAdd(L, R)));
230230 EXPECT_EQ(L, MatchL);
231231 EXPECT_EQ(R, MatchR);
232 MatchL = MatchR = 0;
232 MatchL = MatchR = nullptr;
233233 EXPECT_TRUE(
234234 m_NSWSub(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNSWSub(L, R)));
235235 EXPECT_EQ(L, MatchL);
236236 EXPECT_EQ(R, MatchR);
237 MatchL = MatchR = 0;
237 MatchL = MatchR = nullptr;
238238 EXPECT_TRUE(
239239 m_NSWMul(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNSWMul(L, R)));
240240 EXPECT_EQ(L, MatchL);
241241 EXPECT_EQ(R, MatchR);
242 MatchL = MatchR = 0;
242 MatchL = MatchR = nullptr;
243243 EXPECT_TRUE(m_NSWShl(m_Value(MatchL), m_Value(MatchR)).match(
244244 IRB.CreateShl(L, R, "", /* NUW */ false, /* NSW */ true)));
245245 EXPECT_EQ(L, MatchL);
249249 m_NUWAdd(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNUWAdd(L, R)));
250250 EXPECT_EQ(L, MatchL);
251251 EXPECT_EQ(R, MatchR);
252 MatchL = MatchR = 0;
252 MatchL = MatchR = nullptr;
253253 EXPECT_TRUE(
254254 m_NUWSub(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNUWSub(L, R)));
255255 EXPECT_EQ(L, MatchL);
256256 EXPECT_EQ(R, MatchR);
257 MatchL = MatchR = 0;
257 MatchL = MatchR = nullptr;
258258 EXPECT_TRUE(
259259 m_NUWMul(m_Value(MatchL), m_Value(MatchR)).match(IRB.CreateNUWMul(L, R)));
260260 EXPECT_EQ(L, MatchL);
261261 EXPECT_EQ(R, MatchR);
262 MatchL = MatchR = 0;
262 MatchL = MatchR = nullptr;
263263 EXPECT_TRUE(m_NUWShl(m_Value(MatchL), m_Value(MatchR)).match(
264264 IRB.CreateShl(L, R, "", /* NUW */ true, /* NSW */ false)));
265265 EXPECT_EQ(L, MatchL);
233233 TypeBuilder::get(getGlobalContext()),
234234 TypeBuilder::get(getGlobalContext()),
235235 TypeBuilder::get(getGlobalContext()),
236 (void*)0)),
236 (void*)nullptr)),
237237 (TypeBuilder::get(getGlobalContext())));
238238 EXPECT_EQ(PointerType::getUnqual(StructType::get(
239239 TypeBuilder, false>::get(getGlobalContext()),
240240 TypeBuilder*, false>::get(getGlobalContext()),
241241 TypeBuilder*[], false>::get(getGlobalContext()),
242 (void*)0)),
242 (void*)nullptr)),
243243 (TypeBuilder::get(getGlobalContext())));
244244 EXPECT_EQ(PointerType::getUnqual(StructType::get(
245245 TypeBuilder, false>::get(getGlobalContext()),
246246 TypeBuilder*, false>::get(getGlobalContext()),
247247 TypeBuilder*[], false>::get(getGlobalContext()),
248 (void*)0)),
248 (void*)nullptr)),
249249 (TypeBuilder::get(getGlobalContext())));
250250 }
251251
6464 " ret void\n"
6565 "}\n";
6666 SMDiagnostic Err;
67 Module *M = ParseAssemblyString(ModuleString, NULL, Err, C);
67 Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C);
6868
6969 Function *F = M->getFunction("f");
7070 BasicBlock &ExitBB = F->back();
9393 WeakVH WVH_Copy(WVH);
9494 WeakVH WVH_Recreated(BitcastV.get());
9595 BitcastV.reset();
96 Value *null_value = NULL;
96 Value *null_value = nullptr;
9797 EXPECT_EQ(null_value, WVH);
9898 EXPECT_EQ(null_value, WVH_Copy);
9999 EXPECT_EQ(null_value, WVH_Recreated);
177177 EXPECT_DEATH({BitcastV.reset();},
178178 "An asserting value handle still pointed to this value!");
179179 AssertingVH Copy(AVH);
180 AVH = NULL;
180 AVH = nullptr;
181181 EXPECT_DEATH({BitcastV.reset();},
182182 "An asserting value handle still pointed to this value!");
183 Copy = NULL;
183 Copy = nullptr;
184184 BitcastV.reset();
185185 }
186186
262262 int DeletedCalls;
263263 Value *AURWArgument;
264264
265 RecordingVH() : DeletedCalls(0), AURWArgument(NULL) {}
265 RecordingVH() : DeletedCalls(0), AURWArgument(nullptr) {}
266266 RecordingVH(Value *V)
267 : CallbackVH(V), DeletedCalls(0), AURWArgument(NULL) {}
267 : CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr) {}
268268
269269 private:
270270 virtual void deleted() { DeletedCalls++; CallbackVH::deleted(); }
271271 virtual void allUsesReplacedWith(Value *new_value) {
272 EXPECT_EQ(NULL, AURWArgument);
272 EXPECT_EQ(nullptr, AURWArgument);
273273 AURWArgument = new_value;
274274 }
275275 };
277277 RecordingVH RVH;
278278 RVH = BitcastV.get();
279279 EXPECT_EQ(0, RVH.DeletedCalls);
280 EXPECT_EQ(NULL, RVH.AURWArgument);
280 EXPECT_EQ(nullptr, RVH.AURWArgument);
281281 BitcastV->replaceAllUsesWith(ConstantV);
282282 EXPECT_EQ(0, RVH.DeletedCalls);
283283 EXPECT_EQ(ConstantV, RVH.AURWArgument);
290290 Value *AURWArgument;
291291 LLVMContext *Context;
292292
293 RecoveringVH() : DeletedCalls(0), AURWArgument(NULL),
293 RecoveringVH() : DeletedCalls(0), AURWArgument(nullptr),
294294 Context(&getGlobalContext()) {}
295295 RecoveringVH(Value *V)
296 : CallbackVH(V), DeletedCalls(0), AURWArgument(NULL),
296 : CallbackVH(V), DeletedCalls(0), AURWArgument(nullptr),
297297 Context(&getGlobalContext()) {}
298298
299299 private:
300300 virtual void deleted() {
301301 getValPtr()->replaceAllUsesWith(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())));
302 setValPtr(NULL);
302 setValPtr(nullptr);
303303 }
304304 virtual void allUsesReplacedWith(Value *new_value) {
305 ASSERT_TRUE(NULL != getValPtr());
305 ASSERT_TRUE(nullptr != getValPtr());
306306 EXPECT_EQ(1U, getValPtr()->getNumUses());
307 EXPECT_EQ(NULL, AURWArgument);
307 EXPECT_EQ(nullptr, AURWArgument);
308308 AURWArgument = new_value;
309309 }
310310 };
367367 WeakVH ShouldBeVisited2(BitcastV.get());
368368
369369 BitcastV.reset();
370 EXPECT_EQ(NULL, static_cast(ShouldBeVisited1));
371 EXPECT_EQ(NULL, static_cast(ShouldBeVisited2));
370 EXPECT_EQ(nullptr, static_cast(ShouldBeVisited1));
371 EXPECT_EQ(nullptr, static_cast(ShouldBeVisited2));
372372 }
373373 }
374374
388388 }
389389
390390 virtual void deleted() {
391 *ToClear[0] = 0;
392 *ToClear[1] = 0;
391 *ToClear[0] = nullptr;
392 *ToClear[1] = nullptr;
393393 CallbackVH::deleted();
394394 }
395395 };
3939
4040 TYPED_TEST(ValueMapTest, Null) {
4141 ValueMap VM1;
42 VM1[NULL] = 7;
43 EXPECT_EQ(7, VM1.lookup(NULL));
42 VM1[nullptr] = 7;
43 EXPECT_EQ(7, VM1.lookup(nullptr));
4444 }
4545
4646 TYPED_TEST(ValueMapTest, FollowsValue) {
3333 " ret void\n"
3434 "}\n";
3535 SMDiagnostic Err;
36 Module *M = ParseAssemblyString(ModuleString, NULL, Err, C);
36 Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C);
3737
3838 Function *F = M->getFunction("f");
3939
5555 GlobalValue::ExternalLinkage,
5656 Constant::getAllOnesValue(Int32Ty),
5757 "dummy",
58 0,
58 nullptr,
5959 GlobalVariable::NotThreadLocal,
6060 1);
6161
7373 GlobalValue::ExternalLinkage,
7474 Constant::getAllOnesValue(Int32Ty),
7575 "dummy_cast",
76 0,
76 nullptr,
7777 GlobalVariable::NotThreadLocal,
7878 1);
7979
3030 FunctionType *FT = FunctionType::get(Type::getVoidTy(getGlobalContext()), true);
3131 Function *F = Function::Create(FT, GlobalValue::ExternalLinkage);
3232 const CallInst *A = CallInst::Create(F, makeArrayRef(values));
33 ASSERT_NE(A, (const CallInst*)NULL);
33 ASSERT_NE(A, (const CallInst*)nullptr);
3434 ASSERT_EQ(1U + 22, A->getNumOperands());
3535 const Use *U = &A->getOperandUse(0);
3636 const Use *Ue = &A->getOperandUse(22);
3535 ArrayType *AT = ArrayType::get(Type::getInt8PtrTy(Ctx), 3);
3636
3737 GV = new GlobalVariable(*M.get(), AT, false /*=isConstant*/,
38 GlobalValue::InternalLinkage, 0, "switch.bas");
38 GlobalValue::InternalLinkage, nullptr,"switch.bas");
3939
4040 // Global Initializer
4141 std::vector Init;
8787 Builder.CreateRet(ConstantPointerNull::get(Type::getInt8PtrTy(Ctx)));
8888
8989 Module *LinkedModule = new Module("MyModuleLinked", Ctx);
90 Linker::LinkModules(LinkedModule, M.get(), Linker::PreserveSource, 0);
90 Linker::LinkModules(LinkedModule, M.get(), Linker::PreserveSource, nullptr);
9191
9292 // Delete the original module.
9393 M.reset();
137137
138138 GlobalVariable *GV =
139139 new GlobalVariable(*InternalM, STy, false /*=isConstant*/,
140 GlobalValue::InternalLinkage, 0, "g");
140 GlobalValue::InternalLinkage, nullptr, "g");
141141
142142 GV->setInitializer(ConstantStruct::get(STy, F));
143143
144144 Module *EmptyM = new Module("EmptyModule1", Ctx);
145 Linker::LinkModules(EmptyM, InternalM, Linker::PreserveSource, 0);
145 Linker::LinkModules(EmptyM, InternalM, Linker::PreserveSource, nullptr);
146146
147147 delete EmptyM;
148148 EmptyM = new Module("EmptyModule2", Ctx);
149 Linker::LinkModules(InternalM, EmptyM, Linker::PreserveSource, 0);
149 Linker::LinkModules(InternalM, EmptyM, Linker::PreserveSource, nullptr);
150150
151151 delete EmptyM;
152152 delete InternalM;
1717 // Used to test illegal cast. If a cast doesn't match any of the "real" ones,
1818 // it will match this one.
1919 struct IllegalCast;
20 template IllegalCast *cast(...) { return 0; }
20 template IllegalCast *cast(...) { return nullptr; }
2121
2222 // set up two example classes
2323 // with conversion facility
8989
9090 namespace {
9191
92 const foo *null_foo = NULL;
92 const foo *null_foo = nullptr;
9393
9494 bar B;
9595 extern bar &B1;
174174 const bar *B2 = &B;
175175 } // anonymous namespace
176176
177 bar *llvm::fub() { return 0; }
177 bar *llvm::fub() { return nullptr; }
178178
179179 namespace {
180180 namespace inferred_upcasting {
202202 Derived D;
203203 EXPECT_TRUE(isa(D));
204204 Base *BP = dyn_cast(&D);
205 EXPECT_TRUE(BP != NULL);
205 EXPECT_TRUE(BP != nullptr);
206206 }
207207
208208
2222 TempEnvVar(const char *name, const char *value)
2323 : name(name) {
2424 const char *old_value = getenv(name);
25 EXPECT_EQ(NULL, old_value) << old_value;
25 EXPECT_EQ(nullptr, old_value) << old_value;
2626 #if HAVE_SETENV
2727 setenv(name, value, true);
2828 #else
9393
9494 EXPECT_EQ(stringData, DE.getCStr(&offset));
9595 EXPECT_EQ(11U, offset);
96 EXPECT_EQ(NULL, DE.getCStr(&offset));
96 EXPECT_EQ(nullptr, DE.getCStr(&offset));
9797 EXPECT_EQ(11U, offset);
9898 }
9999
5353 struct D : B {};
5454
5555 TEST(ErrorOr, Covariant) {
56 ErrorOr b(ErrorOr(0));
57 b = ErrorOr(0);
56 ErrorOr b(ErrorOr(nullptr));
57 b = ErrorOr(nullptr);
5858
59 ErrorOr > b1(ErrorOr >(0));
60 b1 = ErrorOr >(0);
59 ErrorOr > b1(ErrorOr >(nullptr));
60 b1 = ErrorOr >(nullptr);
6161 }
6262 } // end anon namespace
2424 llvm::ManagedStatic ms;
2525 void *helper(void*) {
2626 *ms;
27 return NULL;
27 return nullptr;
2828 }
2929
3030 // Valgrind's leak checker complains glibc's stack allocation.
4848
4949 llvm_start_multithreaded();
5050 pthread_t t1, t2;
51 pthread_create(&t1, &a1, test1::helper, NULL);
52 pthread_create(&t2, &a2, test1::helper, NULL);
53 pthread_join(t1, NULL);
54 pthread_join(t2, NULL);
51 pthread_create(&t1, &a1, test1::helper, nullptr);
52 pthread_create(&t2, &a2, test1::helper, nullptr);
53 pthread_join(t1, nullptr);
54 pthread_join(t2, nullptr);
5555 free(p1);
5656 free(p2);
5757 llvm_stop_multithreaded();
4242 TEST_F(MemoryBufferTest, get) {
4343 // Default name and null-terminator flag
4444 OwningBuffer MB1(MemoryBuffer::getMemBuffer(data));
45 EXPECT_TRUE(0 != MB1.get());
45 EXPECT_TRUE(nullptr != MB1.get());
4646
4747 // RequiresNullTerminator = false
4848 OwningBuffer MB2(MemoryBuffer::getMemBuffer(data, "one", false));
49 EXPECT_TRUE(0 != MB2.get());
49 EXPECT_TRUE(nullptr != MB2.get());
5050
5151 // RequiresNullTerminator = true
5252 OwningBuffer MB3(MemoryBuffer::getMemBuffer(data, "two", true));
53 EXPECT_TRUE(0 != MB3.get());
53 EXPECT_TRUE(nullptr != MB3.get());
5454
5555 // verify all 3 buffers point to the same address
5656 EXPECT_EQ(MB1->getBufferStart(), MB2->getBufferStart());
8888 TEST_F(MemoryBufferTest, copy) {
8989 // copy with no name
9090 OwningBuffer MBC1(MemoryBuffer::getMemBufferCopy(data));
91 EXPECT_TRUE(0 != MBC1.get());
91 EXPECT_TRUE(nullptr != MBC1.get());
9292
9393 // copy with a name
9494 OwningBuffer MBC2(MemoryBuffer::getMemBufferCopy(data, "copy"));
95 EXPECT_TRUE(0 != MBC2.get());
95 EXPECT_TRUE(nullptr != MBC2.get());
9696
9797 // verify the two copies do not point to the same place
9898 EXPECT_NE(MBC1->getBufferStart(), MBC2->getBufferStart());
101101 TEST_F(MemoryBufferTest, make_new) {
102102 // 0-sized buffer
103103 OwningBuffer Zero(MemoryBuffer::getNewUninitMemBuffer(0));
104 EXPECT_TRUE(0 != Zero.get());
104 EXPECT_TRUE(nullptr != Zero.get());
105105
106106 // uninitialized buffer with no name
107107 OwningBuffer One(MemoryBuffer::getNewUninitMemBuffer(321));
108 EXPECT_TRUE(0 != One.get());
108 EXPECT_TRUE(nullptr != One.get());
109109
110110 // uninitialized buffer with name
111111 OwningBuffer Two(MemoryBuffer::getNewUninitMemBuffer(123, "bla"));
112 EXPECT_TRUE(0 != Two.get());
112 EXPECT_TRUE(nullptr != Two.get());
113113
114114 // 0-initialized buffer with no name
115115 OwningBuffer Three(MemoryBuffer::getNewMemBuffer(321, data));
116 EXPECT_TRUE(0 != Three.get());
116 EXPECT_TRUE(nullptr != Three.get());
117117 for (size_t i = 0; i < 321; ++i)
118118 EXPECT_EQ(0, Three->getBufferStart()[0]);
119119
120120 // 0-initialized buffer with name
121121 OwningBuffer Four(MemoryBuffer::getNewMemBuffer(123, "zeros"));
122 EXPECT_TRUE(0 != Four.get());
122 EXPECT_TRUE(nullptr != Four.get());
123123 for (size_t i = 0; i < 123; ++i)
124124 EXPECT_EQ(0, Four->getBufferStart()[0]);
125125 }
5757
5858 TEST_P(MappedMemoryTest, AllocAndRelease) {
5959 error_code EC;
60 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
61 EXPECT_EQ(error_code(), EC);
62
63 EXPECT_NE((void*)0, M1.base());
60 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC);
61 EXPECT_EQ(error_code(), EC);
62
63 EXPECT_NE((void*)nullptr, M1.base());
6464 EXPECT_LE(sizeof(int), M1.size());
6565
6666 EXPECT_FALSE(Memory::releaseMappedMemory(M1));
6868
6969 TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
7070 error_code EC;
71 MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
72 EXPECT_EQ(error_code(), EC);
73 MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC);
74 EXPECT_EQ(error_code(), EC);
75 MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC);
76 EXPECT_EQ(error_code(), EC);
77
78 EXPECT_NE((void*)0, M1.base());
79 EXPECT_LE(16U, M1.size());
80 EXPECT_NE((void*)0, M2.base());
81 EXPECT_LE(64U, M2.size());
82 EXPECT_NE((void*)0, M3.base());
83 EXPECT_LE(32U, M3.size());
84
85 EXPECT_FALSE(doesOverlap(M1, M2));
86 EXPECT_FALSE(doesOverlap(M2, M3));
87 EXPECT_FALSE(doesOverlap(M1, M3));
88
89 EXPECT_FALSE(Memory::releaseMappedMemory(M1));
90 EXPECT_FALSE(Memory::releaseMappedMemory(M3));
91 MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
92 EXPECT_EQ(error_code(), EC);
93 EXPECT_NE((void*)0, M4.base());
71 MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
72 EXPECT_EQ(error_code(), EC);
73 MemoryBlock M2 = Memory::allocateMappedMemory(64, nullptr, Flags, EC);
74 EXPECT_EQ(error_code(), EC);
75 MemoryBlock M3 = Memory::allocateMappedMemory(32, nullptr, Flags, EC);
76 EXPECT_EQ(error_code(), EC);
77
78 EXPECT_NE((void*)nullptr, M1.base());
79 EXPECT_LE(16U, M1.size());
80 EXPECT_NE((void*)nullptr, M2.base());
81 EXPECT_LE(64U, M2.size());
82 EXPECT_NE((void*)nullptr, M3.base());
83 EXPECT_LE(32U, M3.size());
84
85 EXPECT_FALSE(doesOverlap(M1, M2));
86 EXPECT_FALSE(doesOverlap(M2, M3));
87 EXPECT_FALSE(doesOverlap(M1, M3));
88
89 EXPECT_FALSE(Memory::releaseMappedMemory(M1));
90 EXPECT_FALSE(Memory::releaseMappedMemory(M3));
91 MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
92 EXPECT_EQ(error_code(), EC);
93 EXPECT_NE((void*)nullptr, M4.base());
9494 EXPECT_LE(16U, M4.size());
9595 EXPECT_FALSE(Memory::releaseMappedMemory(M4));
9696 EXPECT_FALSE(Memory::releaseMappedMemory(M2));
103103 return;
104104
105105 error_code EC;
106 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
107 EXPECT_EQ(error_code(), EC);
108
109 EXPECT_NE((void*)0, M1.base());
106 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,EC);
107 EXPECT_EQ(error_code(), EC);
108
109 EXPECT_NE((void*)nullptr, M1.base());
110110 EXPECT_LE(sizeof(int), M1.size());
111111
112112 int *a = (int*)M1.base();
122122 !((Flags & Memory::MF_READ) && (Flags & Memory::MF_WRITE)))
123123 return;
124124 error_code EC;
125 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
126 EXPECT_EQ(error_code(), EC);
127 MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
128 EXPECT_EQ(error_code(), EC);
129 MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
130 EXPECT_EQ(error_code(), EC);
131
132 EXPECT_FALSE(doesOverlap(M1, M2));
133 EXPECT_FALSE(doesOverlap(M2, M3));
134 EXPECT_FALSE(doesOverlap(M1, M3));
135
136 EXPECT_NE((void*)0, M1.base());
125 MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), nullptr, Flags,
126 EC);
127 EXPECT_EQ(error_code(), EC);
128 MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags,
129 EC);
130 EXPECT_EQ(error_code(), EC);
131 MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags,
132 EC);
133 EXPECT_EQ(error_code(), EC);
134
135 EXPECT_FALSE(doesOverlap(M1, M2));
136 EXPECT_FALSE(doesOverlap(M2, M3));
137 EXPECT_FALSE(doesOverlap(M1, M3));
138
139 EXPECT_NE((void*)nullptr, M1.base());
137140 EXPECT_LE(1U * sizeof(int), M1.size());
138 EXPECT_NE((void*)0, M2.base());
141 EXPECT_NE((void*)nullptr, M2.base());
139142 EXPECT_LE(8U * sizeof(int), M2.size());
140 EXPECT_NE((void*)0, M3.base());
143 EXPECT_NE((void*)nullptr, M3.base());
141144 EXPECT_LE(4U * sizeof(int), M3.size());
142145
143146 int *x = (int*)M1.base();
158161 EXPECT_FALSE(Memory::releaseMappedMemory(M1));
159162 EXPECT_FALSE(Memory::releaseMappedMemory(M3));
160163
161 MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC);
162 EXPECT_EQ(error_code(), EC);
163 EXPECT_NE((void*)0, M4.base());
164 MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), nullptr,
165 Flags, EC);
166 EXPECT_EQ(error_code(), EC);
167 EXPECT_NE((void*)nullptr, M4.base());
164168 EXPECT_LE(64U * sizeof(int), M4.size());
165169 x = (int*)M4.base();
166170 *x = 4;
176180
177181 TEST_P(MappedMemoryTest, EnabledWrite) {
178182 error_code EC;
179 MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC);
180 EXPECT_EQ(error_code(), EC);
181 MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
182 EXPECT_EQ(error_code(), EC);
183 MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
184 EXPECT_EQ(error_code(), EC);
185
186 EXPECT_NE((void*)0, M1.base());
183 MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), nullptr, Flags,
184 EC);
185 EXPECT_EQ(error_code(), EC);
186 MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), nullptr, Flags,
187 EC);
188 EXPECT_EQ(error_code(), EC);
189 MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), nullptr, Flags,
190 EC);
191 EXPECT_EQ(error_code(), EC);
192
193 EXPECT_NE((void*)nullptr, M1.base());
187194 EXPECT_LE(2U * sizeof(int), M1.size());
188 EXPECT_NE((void*)0, M2.base());
195 EXPECT_NE((void*)nullptr, M2.base());
189196 EXPECT_LE(8U * sizeof(int), M2.size());
190 EXPECT_NE((void*)0, M3.base());
197 EXPECT_NE((void*)nullptr, M3.base());
191198 EXPECT_LE(4U * sizeof(int), M3.size());
192199
193200 EXPECT_FALSE(Memory::protectMappedMemory(M1, getTestableEquivalent(Flags)));
215222 EXPECT_FALSE(Memory::releaseMappedMemory(M3));
216223 EXPECT_EQ(6, y[6]);
217224
218 MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
219 EXPECT_EQ(error_code(), EC);
220 EXPECT_NE((void*)0, M4.base());
225 MemoryBlock M4 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
226 EXPECT_EQ(error_code(), EC);
227 EXPECT_NE((void*)nullptr, M4.base());
221228 EXPECT_LE(16U, M4.size());
222229 EXPECT_EQ(error_code(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
223230 x = (int*)M4.base();
229236
230237 TEST_P(MappedMemoryTest, SuccessiveNear) {
231238 error_code EC;
232 MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
239 MemoryBlock M1 = Memory::allocateMappedMemory(16, nullptr, Flags, EC);
233240 EXPECT_EQ(error_code(), EC);
234241 MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC);
235242 EXPECT_EQ(error_code(), EC);
236243 MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC);
237244 EXPECT_EQ(error_code(), EC);
238245
239 EXPECT_NE((void*)0, M1.base());
240 EXPECT_LE(16U, M1.size());
241 EXPECT_NE((void*)0, M2.base());
242 EXPECT_LE(64U, M2.size());
243 EXPECT_NE((void*)0, M3.base());
246 EXPECT_NE((void*)nullptr, M1.base());
247 EXPECT_LE(16U, M1.size());
248 EXPECT_NE((void*)nullptr, M2.base());
249 EXPECT_LE(64U, M2.size());
250 EXPECT_NE((void*)nullptr, M3.base());
244251 EXPECT_LE(32U, M3.size());
245252
246253 EXPECT_FALSE(doesOverlap(M1, M2));
262269 MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
263270 EXPECT_EQ(error_code(), EC);
264271
265 EXPECT_NE((void*)0, M1.base());
266 EXPECT_LE(16U, M1.size());
267 EXPECT_NE((void*)0, M2.base());
268 EXPECT_LE(64U, M2.size());
269 EXPECT_NE((void*)0, M3.base());
272 EXPECT_NE((void*)nullptr, M1.base());
273 EXPECT_LE(16U, M1.size());
274 EXPECT_NE((void*)nullptr, M2.base());
275 EXPECT_LE(64U, M2.size());
276 EXPECT_NE((void*)nullptr, M3.base());
270277 EXPECT_LE(32U, M3.size());
271278
272279 EXPECT_FALSE(Memory::releaseMappedMemory(M1));
276283
277284 TEST_P(MappedMemoryTest, ZeroNear) {
278285 error_code EC;
279 MemoryBlock Near(0, 0);
286 MemoryBlock Near(nullptr, 0);
280287 MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
281288 EXPECT_EQ(error_code(), EC);
282289 MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
284291 MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
285292 EXPECT_EQ(error_code(), EC);
286293
287 EXPECT_NE((void*)0, M1.base());
288 EXPECT_LE(16U, M1.size());
289 EXPECT_NE((void*)0, M2.base());
290 EXPECT_LE(64U, M2.size());
291 EXPECT_NE((void*)0, M3.base());
294 EXPECT_NE((void*)nullptr, M1.base());
295 EXPECT_LE(16U, M1.size());
296 EXPECT_NE((void*)nullptr, M2.base());
297 EXPECT_LE(64U, M2.size());
298 EXPECT_NE((void*)nullptr, M3.base());
292299 EXPECT_LE(32U, M3.size());
293300
294301 EXPECT_FALSE(doesOverlap(M1, M2));
310317 MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
311318 EXPECT_EQ(error_code(), EC);
312319
313 EXPECT_NE((void*)0, M1.base());
314 EXPECT_LE(16U, M1.size());
315 EXPECT_NE((void*)0, M2.base());
316 EXPECT_LE(64U, M2.size());
317 EXPECT_NE((void*)0, M3.base());
320 EXPECT_NE((void*)nullptr, M1.base());
321 EXPECT_LE(16U, M1.size());
322 EXPECT_NE((void*)nullptr, M2.base());
323 EXPECT_LE(64U, M2.size());
324 EXPECT_NE((void*)nullptr, M3.base());
318325 EXPECT_LE(32U, M3.size());
319326
320327 EXPECT_FALSE(doesOverlap(M1, M2));
332339 MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC);
333340 EXPECT_EQ(error_code(), EC);
334341
335 EXPECT_NE((void*)0, M1.base());
342 EXPECT_NE((void*)nullptr, M1.base());
336343 EXPECT_LE(sizeof(int), M1.size());
337344
338345 EXPECT_FALSE(Memory::releaseMappedMemory(M1));
5353 // environ seems to work for Windows and most other Unices.
5454 char **envp = environ;
5555 #endif
56 while (*envp != 0) {
56 while (*envp != nullptr) {
5757 out.push_back(*envp);
5858 ++envp;
5959 }
7575 "--gtest_filter=ProgramTest.CreateProcessTrailingSlash",
7676 "-program-test-string-arg1", "has\\\\ trailing\\",
7777 "-program-test-string-arg2", "has\\\\ trailing\\",
78 0
78 nullptr
7979 };
8080
8181 // Add LLVM_PROGRAM_TEST_CHILD to the environment of the child.
8282 std::vector envp;
8383 CopyEnvironment(envp);
8484 envp.push_back("LLVM_PROGRAM_TEST_CHILD=1");
85 envp.push_back(0);
85 envp.push_back(nullptr);
8686
8787 std::string error;
8888 bool ExecutionFailed;
9292 #else
9393 StringRef nul("/dev/null");
9494 #endif
95 const StringRef *redirects[] = { &nul, &nul, 0 };
95 const StringRef *redirects[] = { &nul, &nul, nullptr };
9696 int rc = ExecuteAndWait(my_exe, argv, &envp[0], redirects,
9797 /*secondsToWait=*/ 10, /*memoryLimit=*/ 0, &error,
9898 &ExecutionFailed);
113113 const char *argv[] = {
114114 Executable.c_str(),
115115 "--gtest_filter=ProgramTest.TestExecuteNoWait",
116 0
116 nullptr
117117 };
118118
119119 // Add LLVM_PROGRAM_TEST_EXECUTE_NO_WAIT to the environment of the child.
120120 std::vector envp;
121121 CopyEnvironment(envp);
122122 envp.push_back("LLVM_PROGRAM_TEST_EXECUTE_NO_WAIT=1");
123 envp.push_back(0);
123 envp.push_back(nullptr);
124124
125125 std::string Error;
126126 bool ExecutionFailed;
127 ProcessInfo PI1 =
128 ExecuteNoWait(Executable, argv, &envp[0], 0, 0, &Error, &ExecutionFailed);
127 ProcessInfo PI1 = ExecuteNoWait(Executable, argv, &envp[0], nullptr, 0,
128 &Error, &ExecutionFailed);
129129 ASSERT_FALSE(ExecutionFailed) << Error;
130130 ASSERT_NE(PI1.Pid, 0) << "Invalid process id";
131131
143143
144144 EXPECT_EQ(LoopCount, 1u) << "LoopCount should be 1";
145145
146 ProcessInfo PI2 =
147 ExecuteNoWait(Executable, argv, &envp[0], 0, 0, &Error, &ExecutionFailed);
146 ProcessInfo PI2 = ExecuteNoWait(Executable, argv, &envp[0], nullptr, 0,
147 &Error, &ExecutionFailed);
148148 ASSERT_FALSE(ExecutionFailed) << Error;
149149 ASSERT_NE(PI2.Pid, 0) << "Invalid process id";
150150
174174 const char *argv[] = {
175175 Executable.c_str(),
176176 "--gtest_filter=ProgramTest.TestExecuteAndWaitTimeout",
177 0
177 nullptr
178178 };
179179
180180 // Add LLVM_PROGRAM_TEST_TIMEOUT to the environment of the child.
181181 std::vector envp;
182182 CopyEnvironment(envp);
183183 envp.push_back("LLVM_PROGRAM_TEST_TIMEOUT=1");
184 envp.push_back(0);
184 envp.push_back(nullptr);
185185
186186 std::string Error;
187187 bool ExecutionFailed;
188188 int RetCode =
189 ExecuteAndWait(Executable, argv, &envp[0], 0, /*secondsToWait=*/1, 0,
189 ExecuteAndWait(Executable, argv, &envp[0], nullptr, /*secondsToWait=*/1, 0,
190190 &Error, &ExecutionFailed);
191191 ASSERT_EQ(-2, RetCode);
192192 }
193193
194194 TEST(ProgramTest, TestExecuteNegative) {
195195 std::string Executable = "i_dont_exist";
196 const char *argv[] = { Executable.c_str(), 0 };
196 const char *argv[] = { Executable.c_str(), nullptr };
197197
198198 {
199199 std::string Error;
200200 bool ExecutionFailed;
201 int RetCode =
202 ExecuteAndWait(Executable, argv, 0, 0, 0, 0, &Error, &ExecutionFailed);
201 int RetCode = ExecuteAndWait(Executable, argv, nullptr, nullptr, 0, 0,
202 &Error, &ExecutionFailed);
203203 ASSERT_TRUE(RetCode < 0) << "On error ExecuteAndWait should return 0 or "
204204 "positive value indicating the result code";
205205 ASSERT_TRUE(ExecutionFailed);
209209 {
210210 std::string Error;
211211 bool ExecutionFailed;
212 ProcessInfo PI =
213 ExecuteNoWait(Executable, argv, 0, 0, 0, &Error, &ExecutionFailed);
212 ProcessInfo PI = ExecuteNoWait(Executable, argv, nullptr, nullptr, 0,
213 &Error, &ExecutionFailed);
214214 ASSERT_EQ(PI.Pid, 0)
215215 << "On error ExecuteNoWait should return an invalid ProcessInfo";
216216 ASSERT_TRUE(ExecutionFailed);
2424 TEST_F(ThreadLocalTest, Basics) {
2525 ThreadLocal x;
2626
27 EXPECT_EQ(0, x.get());
27 EXPECT_EQ(nullptr, x.get());
2828
2929 S s;
3030 x.set(&s);
3131 EXPECT_EQ(&s, x.get());
3232
3333 x.erase();
34 EXPECT_EQ(0, x.get());
34 EXPECT_EQ(nullptr, x.get());
3535 }
3636
3737 }
1515
1616 TEST(TimeValue, time_t) {
1717 sys::TimeValue now = sys::TimeValue::now();
18 time_t now_t = time(NULL);
18 time_t now_t = time(nullptr);
1919 EXPECT_TRUE(std::abs(static_cast(now_t - now.toEpochTime())) < 2);
2020 }
2121
12031203 std::vector docList;
12041204 Input yin("--- \nvalue: 3.0\n"
12051205 "--- \nvalue: -1.0\n...\n",
1206 NULL, suppressErrorMessages);
1206 nullptr, suppressErrorMessages);
12071207 yin >> docList;
12081208 EXPECT_TRUE(!!yin.error());
12091209 }
12231223 "c2: purple\n"
12241224 "c3: green\n"
12251225 "...\n",
1226 /*Ctxt=*/NULL,
1226 /*Ctxt=*/nullptr,
12271227 suppressErrorMessages);
12281228 yin >> map;
12291229 EXPECT_TRUE(!!yin.error());
12401240 "f2: [ round, hollow ]\n"
12411241 "f3: []\n"
12421242 "...\n",
1243 /*Ctxt=*/NULL,
1243 /*Ctxt=*/nullptr,
12441244 suppressErrorMessages);
12451245 yin >> map;
12461246
12591259 "- 0\n"
12601260 "- 257\n"
12611261 "...\n",
1262 /*Ctxt=*/NULL,
1262 /*Ctxt=*/nullptr,
12631263 suppressErrorMessages);
12641264 yin >> seq;
12651265
12781278 "- 0\n"
12791279 "- 66000\n"
12801280 "...\n",
1281 /*Ctxt=*/NULL,
1281 /*Ctxt=*/nullptr,
12821282 suppressErrorMessages);
12831283 yin >> seq;
12841284
12971297 "- 0\n"
12981298 "- 5000000000\n"
12991299 "...\n",
1300 /*Ctxt=*/NULL,
1300 /*Ctxt=*/nullptr,
13011301 suppressErrorMessages);
13021302 yin >> seq;
13031303
13161316 "- 0\n"
13171317 "- 19446744073709551615\n"
13181318 "...\n",
1319 /*Ctxt=*/NULL,
1319 /*Ctxt=*/nullptr,
13201320 suppressErrorMessages);
13211321 yin >> seq;
13221322
13361336 "- 127\n"
13371337 "- 128\n"
13381338 "...\n",
1339 /*Ctxt=*/NULL,
1339 /*Ctxt=*/nullptr,
13401340 suppressErrorMessages);
13411341 yin >> seq;
13421342
13541354 "- 127\n"
13551355 "- -129\n"
13561356 "...\n",
1357 /*Ctxt=*/NULL,
1357 /*Ctxt=*/nullptr,
13581358 suppressErrorMessages);
13591359 yin >> seq;
13601360
13741374 "- -32768\n"
13751375 "- -32769\n"
13761376 "...\n",
1377 /*Ctxt=*/NULL,
1377 /*Ctxt=*/nullptr,
13781378 suppressErrorMessages);
13791379 yin >> seq;
13801380
13931393 "- -32768\n"
13941394 "- 32768\n"
13951395 "...\n",
1396 /*Ctxt=*/NULL,
1396 /*Ctxt=*/nullptr,
13971397 suppressErrorMessages);
13981398 yin >> seq;
13991399
14131413 "- -2147483648\n"
14141414 "- -2147483649\n"
14151415 "...\n",
1416 /*Ctxt=*/NULL,
1416 /*Ctxt=*/nullptr,
14171417 suppressErrorMessages);
14181418 yin >> seq;
14191419
14311431 "- -2147483648\n"
14321432 "- 2147483649\n"
14331433 "...\n",
1434 /*Ctxt=*/NULL,
1434 /*Ctxt=*/nullptr,
14351435 suppressErrorMessages);
14361436 yin >> seq;
14371437
14511451 "- 9223372036854775807\n"
14521452 "- -9223372036854775809\n"
14531453 "...\n",
1454 /*Ctxt=*/NULL,
1454 /*Ctxt=*/nullptr,
14551455 suppressErrorMessages);
14561456 yin >> seq;
14571457
14691469 "- 9223372036854775807\n"
14701470 "- 9223372036854775809\n"
14711471 "...\n",
1472 /*Ctxt=*/NULL,
1472 /*Ctxt=*/nullptr,
14731473 suppressErrorMessages);
14741474 yin >> seq;
14751475
14881488 "- -123.456\n"
14891489 "- 1.2.3\n"
14901490 "...\n",
1491 /*Ctxt=*/NULL,
1491 /*Ctxt=*/nullptr,
14921492 suppressErrorMessages);
14931493 yin >> seq;
14941494
15071507 "- -123.456\n"
15081508 "- 1.2.3\n"
15091509 "...\n",
1510 /*Ctxt=*/NULL,
1510 /*Ctxt=*/nullptr,
15111511 suppressErrorMessages);
15121512 yin >> seq;
15131513
15251525 "- 0xFE\n"
15261526 "- 0x123\n"
15271527 "...\n",
1528 /*Ctxt=*/NULL,
1528 /*Ctxt=*/nullptr,
15291529 suppressErrorMessages);
15301530 yin >> seq;
15311531
15441544 "- 0xFEFF\n"
15451545 "- 0x12345\n"
15461546 "...\n",
1547 /*Ctxt=*/NULL,
1547 /*Ctxt=*/nullptr,
15481548 suppressErrorMessages);
15491549 yin >> seq;
15501550
15621562 "- 0xFEFF0000\n"
15631563 "- 0x1234556789\n"
15641564 "...\n",
1565 /*Ctxt=*/NULL,
1565 /*Ctxt=*/nullptr,
15661566 suppressErrorMessages);
15671567 yin >> seq;
15681568
15801580 "- 0xFFEEDDCCBBAA9988\n"
15811581 "- 0x12345567890ABCDEF0\n"
15821582 "...\n",
1583 /*Ctxt=*/NULL,
1583 /*Ctxt=*/nullptr,
15841584 suppressErrorMessages);
15851585 yin >> seq;
15861586
15921592 {
15931593 // We pass the suppressErrorMessages handler to handle the error
15941594 // message generated in the constructor of Input.
1595 Input yin("{foo:3, bar: 5}", /*Ctxt=*/NULL, suppressErrorMessages);
1595 Input yin("{foo:3, bar: 5}", /*Ctxt=*/nullptr, suppressErrorMessages);
15961596 yin >> doc;
15971597 EXPECT_TRUE(!!yin.error());
15981598 }
15991599
16001600 {
1601 Input yin("---\nfoo:3\nbar: 5\n...\n", /*Ctxt=*/NULL, suppressErrorMessages);
1601 Input yin("---\nfoo:3\nbar: 5\n...\n", /*Ctxt=*/nullptr, suppressErrorMessages);
16021602 yin >> doc;
16031603 EXPECT_TRUE(!!yin.error());
16041604 }
16841684
16851685 TEST(YAMLIO, TestEmptyStringSucceedsForSequence) {
16861686 std::vector seq;
1687 Input yin("", /*Ctxt=*/NULL, suppressErrorMessages);
1687 Input yin("", /*Ctxt=*/nullptr, suppressErrorMessages);
16881688 yin >> seq;
16891689
16901690 EXPECT_FALSE(yin.error());
6868 EXPECT_EQ("1.100000e+00", printToString(1.1));
6969
7070 // void*
71 EXPECT_EQ("0x0", printToString((void*) 0));
71 EXPECT_EQ("0x0", printToString((void*) nullptr));
7272 EXPECT_EQ("0xbeef", printToString((void*) 0xbeef));
7373 EXPECT_EQ("0xdeadbeef", printToString((void*) 0xdeadbeef));
7474
9999 EXPECT_EQ("1.100000e+00", printToStringUnbuffered(1.1));
100100
101101 // void*
102 EXPECT_EQ("0x0", printToStringUnbuffered((void*) 0));
102 EXPECT_EQ("0x0", printToStringUnbuffered((void*) nullptr));
103103 EXPECT_EQ("0xbeef", printToStringUnbuffered((void*) 0xbeef));
104104 EXPECT_EQ("0xdeadbeef", printToStringUnbuffered((void*) 0xdeadbeef));
105105
6464 #if defined(LLVM_ON_WIN32) || defined(HAVE_GETCWD)
6565 // calling getcwd (or _getcwd() on windows) with a null buffer makes it
6666 // allocate a sufficiently sized buffer to store the current working dir.
67 return getcwd_impl(0, 0);
67 return getcwd_impl(nullptr, 0);
6868 #else
6969 return 0;
7070 #endif
3131 class CloneInstruction : public ::testing::Test {
3232 protected:
3333 virtual void SetUp() {
34 V = NULL;
34 V = nullptr;
3535 }
3636
3737 template
271271
272272 void CreateNewFunc() {
273273 ValueToValueMapTy VMap;
274 NewFunc = CloneFunction(OldFunc, VMap, true, NULL);
274 NewFunc = CloneFunction(OldFunc, VMap, true, nullptr);
275275 M->getFunctionList().push_back(NewFunc);
276276 }
277277
2828
2929 GlobalVariable *makeGlobal(StringRef Name, StringRef StructName, Module &M) {
3030 StructType *ST =
31 StructType::create(StructName, Type::getInt32Ty(Ctx), (Type*)0);
31 StructType::create(StructName, Type::getInt32Ty(Ctx), (Type*)nullptr);
3232 return new GlobalVariable(
33 M, ST, false, GlobalValue::ExternalLinkage, 0, Name);
33 M, ST, false, GlobalValue::ExternalLinkage, nullptr, Name);
3434 }
3535
3636 GlobalAlias *makeAlias(StringRef Name, GlobalObject *Aliasee) {
208208
209209 TEST_F(SpecialCaseListTest, InvalidSpecialCaseList) {
210210 std::string Error;
211 EXPECT_EQ(0, makeSpecialCaseList("badline", Error));
211 EXPECT_EQ(nullptr, makeSpecialCaseList("badline", Error));
212212 EXPECT_EQ("Malformed line 1: 'badline'", Error);
213 EXPECT_EQ(0, makeSpecialCaseList("src:bad[a-", Error));
213 EXPECT_EQ(nullptr, makeSpecialCaseList("src:bad[a-", Error));
214214 EXPECT_EQ("Malformed regex in line 1: 'bad[a-': invalid character range",
215215 Error);
216 EXPECT_EQ(0, makeSpecialCaseList("src:a.c\n"
216 EXPECT_EQ(nullptr, makeSpecialCaseList("src:a.c\n"
217217 "fun:fun(a\n",
218218 Error));
219219 EXPECT_EQ("Malformed regex in line 2: 'fun(a': parentheses not balanced",
220220 Error);
221 EXPECT_EQ(0, SpecialCaseList::create("unexisting", Error));
221 EXPECT_EQ(nullptr, SpecialCaseList::create("unexisting", Error));
222222 EXPECT_EQ(0U, Error.find("Can't open file 'unexisting':"));
223223 }
224224
10421042 SMLoc::getFromPointer(Buffer.data())))->getBufferStart() &&
10431043 "CHECK-NEXT can't be the first check in a file");
10441044
1045 const char *FirstNewLine = 0;
1045 const char *FirstNewLine = nullptr;
10461046 unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);
10471047
10481048 if (NumNewLines == 0) {
218218 int main() {
219219 // Seed the table with accesses to the LHS and RHS.
220220 ShufTab[0x0123].Cost = 0;
221 ShufTab[0x0123].Op = 0;
221 ShufTab[0x0123].Op = nullptr;
222222 ShufTab[0x0123].Arg0 = 0x0123;
223223 ShufTab[0x4567].Cost = 0;
224 ShufTab[0x4567].Op = 0;
224 ShufTab[0x4567].Op = nullptr;
225225 ShufTab[0x4567].Arg0 = 0x4567;
226226
227227 // Seed the first-level of shuffles, shuffles whose inputs are the input to
2929 std::string Program = sys::FindProgramByName(argv[0]);
3030
3131 std::string ErrMsg;
32 int Result = sys::ExecuteAndWait(Program, argv, 0, 0, 0, 0, &ErrMsg);
32 int Result = sys::ExecuteAndWait(Program, argv, nullptr, nullptr, 0, 0,
33 &ErrMsg);
3334 if (Result < 0) {
3435 errs() << "Error: " << ErrMsg << "\n";
3536 if (ExpectCrash)