Skip to content

Commit 0eaee54

Browse files
committed
[llvm] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
1 parent 1c34d10 commit 0eaee54

File tree

430 files changed

+1472
-1472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

430 files changed

+1472
-1472
lines changed

llvm/docs/ORCv2.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ checking omitted for brevity) as:
174174

175175
ExecutionSession ES;
176176
RTDyldObjectLinkingLayer ObjLinkingLayer(
177-
ES, []() { return llvm::make_unique<SectionMemoryManager>(); });
177+
ES, []() { return std::make_unique<SectionMemoryManager>(); });
178178
CXXCompileLayer CXXLayer(ES, ObjLinkingLayer);
179179

180180
// Create JITDylib "A" and add code to it using the CXX layer.
@@ -453,7 +453,7 @@ std::unique_ptr<LLVMContext>:
453453

454454
.. code-block:: c++
455455

456-
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
456+
ThreadSafeContext TSCtx(std::make_unique<LLVMContext>());
457457

458458
ThreadSafeModules can be constructed from a pair of a std::unique_ptr<Module>
459459
and a ThreadSafeContext value. ThreadSafeContext values may be shared between
@@ -462,10 +462,10 @@ multiple ThreadSafeModules:
462462
.. code-block:: c++
463463

464464
ThreadSafeModule TSM1(
465-
llvm::make_unique<Module>("M1", *TSCtx.getContext()), TSCtx);
465+
std::make_unique<Module>("M1", *TSCtx.getContext()), TSCtx);
466466
467467
ThreadSafeModule TSM2(
468-
llvm::make_unique<Module>("M2", *TSCtx.getContext()), TSCtx);
468+
std::make_unique<Module>("M2", *TSCtx.getContext()), TSCtx);
469469
470470
Before using a ThreadSafeContext, clients should ensure that either the context
471471
is only accessible on the current thread, or that the context is locked. In the
@@ -476,7 +476,7 @@ or creating any Modules attached to it. E.g.
476476

477477
.. code-block:: c++
478478

479-
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
479+
ThreadSafeContext TSCtx(std::make_unique<LLVMContext>());
480480

481481
ThreadPool TP(NumThreads);
482482
JITStack J;
@@ -519,8 +519,8 @@ constructs a new ThreadSafeContext value from a std::unique_ptr<LLVMContext>:
519519
// Maximize concurrency opportunities by loading every module on a
520520
// separate context.
521521
for (const auto &IRPath : IRPaths) {
522-
auto Ctx = llvm::make_unique<LLVMContext>();
523-
auto M = llvm::make_unique<LLVMContext>("M", *Ctx);
522+
auto Ctx = std::make_unique<LLVMContext>();
523+
auto M = std::make_unique<LLVMContext>("M", *Ctx);
524524
CompileLayer.add(ES.getMainJITDylib(),
525525
ThreadSafeModule(std::move(M), std::move(Ctx)));
526526
}
@@ -531,7 +531,7 @@ all modules on the same context:
531531
.. code-block:: c++
532532

533533
// Save memory by using one context for all Modules:
534-
ThreadSafeContext TSCtx(llvm::make_unique<LLVMContext>());
534+
ThreadSafeContext TSCtx(std::make_unique<LLVMContext>());
535535
for (const auto &IRPath : IRPaths) {
536536
ThreadSafeModule TSM(parsePath(IRPath, *TSCtx.getContext()), TSCtx);
537537
CompileLayer.add(ES.getMainJITDylib(), ThreadSafeModule(std::move(TSM));

llvm/docs/tutorial/BuildingAJIT1.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ usual include guards and #includes [2]_, we get to the definition of our class:
138138
public:
139139
KaleidoscopeJIT(JITTargetMachineBuilder JTMB, DataLayout DL)
140140
: ObjectLayer(ES,
141-
[]() { return llvm::make_unique<SectionMemoryManager>(); }),
141+
[]() { return std::make_unique<SectionMemoryManager>(); }),
142142
CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(std::move(JTMB))),
143143
DL(std::move(DL)), Mangle(ES, this->DL),
144-
Ctx(llvm::make_unique<LLVMContext>()) {
144+
Ctx(std::make_unique<LLVMContext>()) {
145145
ES.getMainJITDylib().setGenerator(
146146
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(DL)));
147147
}
@@ -195,7 +195,7 @@ REPL process as well. We do this by attaching a
195195
if (!DL)
196196
return DL.takeError();
197197

198-
return llvm::make_unique<KaleidoscopeJIT>(std::move(*JTMB), std::move(*DL));
198+
return std::make_unique<KaleidoscopeJIT>(std::move(*JTMB), std::move(*DL));
199199
}
200200
201201
const DataLayout &getDataLayout() const { return DL; }

llvm/docs/tutorial/BuildingAJIT2.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ apply to each Module that is added via addModule:
7171

7272
KaleidoscopeJIT(JITTargetMachineBuilder JTMB, DataLayout DL)
7373
: ObjectLayer(ES,
74-
[]() { return llvm::make_unique<SectionMemoryManager>(); }),
74+
[]() { return std::make_unique<SectionMemoryManager>(); }),
7575
CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(std::move(JTMB))),
7676
TransformLayer(ES, CompileLayer, optimizeModule),
7777
DL(std::move(DL)), Mangle(ES, this->DL),
78-
Ctx(llvm::make_unique<LLVMContext>()) {
78+
Ctx(std::make_unique<LLVMContext>()) {
7979
ES.getMainJITDylib().setGenerator(
8080
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(DL)));
8181
}
@@ -102,7 +102,7 @@ Next we need to update our addModule method to replace the call to
102102
static Expected<ThreadSafeModule>
103103
optimizeModule(ThreadSafeModule M, const MaterializationResponsibility &R) {
104104
// Create a function pass manager.
105-
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(M.get());
105+
auto FPM = std::make_unique<legacy::FunctionPassManager>(M.get());
106106

107107
// Add some optimizations.
108108
FPM->add(createInstructionCombiningPass());
@@ -213,7 +213,7 @@ class:
213213
.. code-block:: c++
214214

215215
Error IRLayer::add(JITDylib &JD, ThreadSafeModule TSM, VModuleKey K) {
216-
return JD.define(llvm::make_unique<BasicIRLayerMaterializationUnit>(
216+
return JD.define(std::make_unique<BasicIRLayerMaterializationUnit>(
217217
*this, std::move(K), std::move(TSM)));
218218
}
219219

llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.rst

+11-11
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ be generated with calls like this:
155155

156156
.. code-block:: c++
157157

158-
auto LHS = llvm::make_unique<VariableExprAST>("x");
159-
auto RHS = llvm::make_unique<VariableExprAST>("y");
158+
auto LHS = std::make_unique<VariableExprAST>("x");
159+
auto RHS = std::make_unique<VariableExprAST>("y");
160160
auto Result = std::make_unique<BinaryExprAST>('+', std::move(LHS),
161161
std::move(RHS));
162162

@@ -210,7 +210,7 @@ which parses that production. For numeric literals, we have:
210210

211211
/// numberexpr ::= number
212212
static std::unique_ptr<ExprAST> ParseNumberExpr() {
213-
auto Result = llvm::make_unique<NumberExprAST>(NumVal);
213+
auto Result = std::make_unique<NumberExprAST>(NumVal);
214214
getNextToken(); // consume the number
215215
return std::move(Result);
216216
}
@@ -276,7 +276,7 @@ function calls:
276276
getNextToken(); // eat identifier.
277277

278278
if (CurTok != '(') // Simple variable ref.
279-
return llvm::make_unique<VariableExprAST>(IdName);
279+
return std::make_unique<VariableExprAST>(IdName);
280280

281281
// Call.
282282
getNextToken(); // eat (
@@ -300,7 +300,7 @@ function calls:
300300
// Eat the ')'.
301301
getNextToken();
302302

303-
return llvm::make_unique<CallExprAST>(IdName, std::move(Args));
303+
return std::make_unique<CallExprAST>(IdName, std::move(Args));
304304
}
305305

306306
This routine follows the same style as the other routines. (It expects
@@ -503,7 +503,7 @@ then continue parsing:
503503
}
504504

505505
// Merge LHS/RHS.
506-
LHS = llvm::make_unique<BinaryExprAST>(BinOp, std::move(LHS),
506+
LHS = std::make_unique<BinaryExprAST>(BinOp, std::move(LHS),
507507
std::move(RHS));
508508
} // loop around to the top of the while loop.
509509
}
@@ -533,7 +533,7 @@ above two blocks duplicated for context):
533533
return nullptr;
534534
}
535535
// Merge LHS/RHS.
536-
LHS = llvm::make_unique<BinaryExprAST>(BinOp, std::move(LHS),
536+
LHS = std::make_unique<BinaryExprAST>(BinOp, std::move(LHS),
537537
std::move(RHS));
538538
} // loop around to the top of the while loop.
539539
}
@@ -593,7 +593,7 @@ expressions):
593593
// success.
594594
getNextToken(); // eat ')'.
595595

596-
return llvm::make_unique<PrototypeAST>(FnName, std::move(ArgNames));
596+
return std::make_unique<PrototypeAST>(FnName, std::move(ArgNames));
597597
}
598598

599599
Given this, a function definition is very simple, just a prototype plus
@@ -608,7 +608,7 @@ an expression to implement the body:
608608
if (!Proto) return nullptr;
609609

610610
if (auto E = ParseExpression())
611-
return llvm::make_unique<FunctionAST>(std::move(Proto), std::move(E));
611+
return std::make_unique<FunctionAST>(std::move(Proto), std::move(E));
612612
return nullptr;
613613
}
614614

@@ -634,8 +634,8 @@ nullary (zero argument) functions for them:
634634
static std::unique_ptr<FunctionAST> ParseTopLevelExpr() {
635635
if (auto E = ParseExpression()) {
636636
// Make an anonymous proto.
637-
auto Proto = llvm::make_unique<PrototypeAST>("", std::vector<std::string>());
638-
return llvm::make_unique<FunctionAST>(std::move(Proto), std::move(E));
637+
auto Proto = std::make_unique<PrototypeAST>("", std::vector<std::string>());
638+
return std::make_unique<FunctionAST>(std::move(Proto), std::move(E));
639639
}
640640
return nullptr;
641641
}

llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ for us:
141141

142142
void InitializeModuleAndPassManager(void) {
143143
// Open a new module.
144-
TheModule = llvm::make_unique<Module>("my cool jit", TheContext);
144+
TheModule = std::make_unique<Module>("my cool jit", TheContext);
145145

146146
// Create a new pass manager attached to it.
147-
TheFPM = llvm::make_unique<FunctionPassManager>(TheModule.get());
147+
TheFPM = std::make_unique<FunctionPassManager>(TheModule.get());
148148

149149
// Do simple "peephole" optimizations and bit-twiddling optzns.
150150
TheFPM->add(createInstructionCombiningPass());
@@ -259,7 +259,7 @@ adding a global variable ``TheJIT``, and initializing it in
259259
fprintf(stderr, "ready> ");
260260
getNextToken();
261261

262-
TheJIT = llvm::make_unique<KaleidoscopeJIT>();
262+
TheJIT = std::make_unique<KaleidoscopeJIT>();
263263

264264
// Run the main "interpreter loop" now.
265265
MainLoop();
@@ -273,11 +273,11 @@ We also need to setup the data layout for the JIT:
273273

274274
void InitializeModuleAndPassManager(void) {
275275
// Open a new module.
276-
TheModule = llvm::make_unique<Module>("my cool jit", TheContext);
276+
TheModule = std::make_unique<Module>("my cool jit", TheContext);
277277
TheModule->setDataLayout(TheJIT->getTargetMachine().createDataLayout());
278278

279279
// Create a new pass manager attached to it.
280-
TheFPM = llvm::make_unique<FunctionPassManager>(TheModule.get());
280+
TheFPM = std::make_unique<FunctionPassManager>(TheModule.get());
281281
...
282282

283283
The KaleidoscopeJIT class is a simple JIT built specifically for these

llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl05.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ First we define a new parsing function:
146146
if (!Else)
147147
return nullptr;
148148

149-
return llvm::make_unique<IfExprAST>(std::move(Cond), std::move(Then),
149+
return std::make_unique<IfExprAST>(std::move(Cond), std::move(Then),
150150
std::move(Else));
151151
}
152152

@@ -560,7 +560,7 @@ value to null in the AST node:
560560
if (!Body)
561561
return nullptr;
562562

563-
return llvm::make_unique<ForExprAST>(IdName, std::move(Start),
563+
return std::make_unique<ForExprAST>(IdName, std::move(Start),
564564
std::move(End), std::move(Step),
565565
std::move(Body));
566566
}

llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl06.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ user-defined operator, we need to parse it:
220220
if (Kind && ArgNames.size() != Kind)
221221
return LogErrorP("Invalid number of operands for operator");
222222

223-
return llvm::make_unique<PrototypeAST>(FnName, std::move(ArgNames), Kind != 0,
223+
return std::make_unique<PrototypeAST>(FnName, std::move(ArgNames), Kind != 0,
224224
BinaryPrecedence);
225225
}
226226

@@ -348,7 +348,7 @@ simple: we'll add a new function to do it:
348348
int Opc = CurTok;
349349
getNextToken();
350350
if (auto Operand = ParseUnary())
351-
return llvm::make_unique<UnaryExprAST>(Opc, std::move(Operand));
351+
return std::make_unique<UnaryExprAST>(Opc, std::move(Operand));
352352
return nullptr;
353353
}
354354

llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ AST node:
780780
if (!Body)
781781
return nullptr;
782782

783-
return llvm::make_unique<VarExprAST>(std::move(VarNames),
783+
return std::make_unique<VarExprAST>(std::move(VarNames),
784784
std::move(Body));
785785
}
786786

llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ statement be our "main":
7777

7878
.. code-block:: udiff
7979
80-
- auto Proto = llvm::make_unique<PrototypeAST>("", std::vector<std::string>());
81-
+ auto Proto = llvm::make_unique<PrototypeAST>("main", std::vector<std::string>());
80+
- auto Proto = std::make_unique<PrototypeAST>("", std::vector<std::string>());
81+
+ auto Proto = std::make_unique<PrototypeAST>("main", std::vector<std::string>());
8282
8383
just with the simple change of giving it a name.
8484

@@ -325,7 +325,7 @@ that we pass down through when we create a new expression:
325325

326326
.. code-block:: c++
327327

328-
LHS = llvm::make_unique<BinaryExprAST>(BinLoc, BinOp, std::move(LHS),
328+
LHS = std::make_unique<BinaryExprAST>(BinLoc, BinOp, std::move(LHS),
329329
std::move(RHS));
330330

331331
giving us locations for each of our expressions and variables.

llvm/examples/ExceptionDemo/ExceptionDemo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ int main(int argc, char *argv[]) {
19041904

19051905
// Make the module, which holds all the code.
19061906
std::unique_ptr<llvm::Module> Owner =
1907-
llvm::make_unique<llvm::Module>("my cool jit", Context);
1907+
std::make_unique<llvm::Module>("my cool jit", Context);
19081908
llvm::Module *module = Owner.get();
19091909

19101910
std::unique_ptr<llvm::RTDyldMemoryManager> MemMgr(new llvm::SectionMemoryManager());

llvm/examples/HowToUseJIT/HowToUseJIT.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int main() {
6363
LLVMContext Context;
6464

6565
// Create some module to put our function into it.
66-
std::unique_ptr<Module> Owner = make_unique<Module>("test", Context);
66+
std::unique_ptr<Module> Owner = std::make_unique<Module>("test", Context);
6767
Module *M = Owner.get();
6868

6969
// Create the add1 function entry and insert this entry into module M. The

llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ using namespace llvm::orc;
2020
ExitOnError ExitOnErr;
2121

2222
ThreadSafeModule createDemoModule() {
23-
auto Context = llvm::make_unique<LLVMContext>();
24-
auto M = make_unique<Module>("test", *Context);
23+
auto Context = std::make_unique<LLVMContext>();
24+
auto M = std::make_unique<Module>("test", *Context);
2525

2626
// Create the add1 function entry and insert this entry into module M. The
2727
// function will have a return type of "int" and take an argument of "int".

llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class KaleidoscopeJIT {
4242
public:
4343
KaleidoscopeJIT(JITTargetMachineBuilder JTMB, DataLayout DL)
4444
: ObjectLayer(ES,
45-
[]() { return llvm::make_unique<SectionMemoryManager>(); }),
45+
[]() { return std::make_unique<SectionMemoryManager>(); }),
4646
CompileLayer(ES, ObjectLayer, ConcurrentIRCompiler(std::move(JTMB))),
4747
DL(std::move(DL)), Mangle(ES, this->DL),
48-
Ctx(llvm::make_unique<LLVMContext>()) {
48+
Ctx(std::make_unique<LLVMContext>()) {
4949
ES.getMainJITDylib().addGenerator(
5050
cantFail(DynamicLibrarySearchGenerator::GetForCurrentProcess(
5151
DL.getGlobalPrefix())));
@@ -61,7 +61,7 @@ class KaleidoscopeJIT {
6161
if (!DL)
6262
return DL.takeError();
6363

64-
return llvm::make_unique<KaleidoscopeJIT>(std::move(*JTMB), std::move(*DL));
64+
return std::make_unique<KaleidoscopeJIT>(std::move(*JTMB), std::move(*DL));
6565
}
6666

6767
const DataLayout &getDataLayout() const { return DL; }

0 commit comments

Comments
 (0)