From 0eaee545eef49ff9498234d3a51a5cbde59bf976 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 15 Aug 2019 15:54:37 +0000 Subject: [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 --- .../MyFirstLanguageFrontend/LangImpl02.rst | 22 +++++++++++----------- .../MyFirstLanguageFrontend/LangImpl04.rst | 10 +++++----- .../MyFirstLanguageFrontend/LangImpl05.rst | 4 ++-- .../MyFirstLanguageFrontend/LangImpl06.rst | 4 ++-- .../MyFirstLanguageFrontend/LangImpl07.rst | 2 +- .../MyFirstLanguageFrontend/LangImpl09.rst | 6 +++--- 6 files changed, 24 insertions(+), 24 deletions(-) (limited to 'llvm/docs/tutorial/MyFirstLanguageFrontend') diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.rst index 3a26800..dec9f36 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.rst @@ -155,8 +155,8 @@ be generated with calls like this: .. code-block:: c++ - auto LHS = llvm::make_unique("x"); - auto RHS = llvm::make_unique("y"); + auto LHS = std::make_unique("x"); + auto RHS = std::make_unique("y"); auto Result = std::make_unique('+', std::move(LHS), std::move(RHS)); @@ -210,7 +210,7 @@ which parses that production. For numeric literals, we have: /// numberexpr ::= number static std::unique_ptr ParseNumberExpr() { - auto Result = llvm::make_unique(NumVal); + auto Result = std::make_unique(NumVal); getNextToken(); // consume the number return std::move(Result); } @@ -276,7 +276,7 @@ function calls: getNextToken(); // eat identifier. if (CurTok != '(') // Simple variable ref. - return llvm::make_unique(IdName); + return std::make_unique(IdName); // Call. getNextToken(); // eat ( @@ -300,7 +300,7 @@ function calls: // Eat the ')'. getNextToken(); - return llvm::make_unique(IdName, std::move(Args)); + return std::make_unique(IdName, std::move(Args)); } This routine follows the same style as the other routines. (It expects @@ -503,7 +503,7 @@ then continue parsing: } // Merge LHS/RHS. - LHS = llvm::make_unique(BinOp, std::move(LHS), + LHS = std::make_unique(BinOp, std::move(LHS), std::move(RHS)); } // loop around to the top of the while loop. } @@ -533,7 +533,7 @@ above two blocks duplicated for context): return nullptr; } // Merge LHS/RHS. - LHS = llvm::make_unique(BinOp, std::move(LHS), + LHS = std::make_unique(BinOp, std::move(LHS), std::move(RHS)); } // loop around to the top of the while loop. } @@ -593,7 +593,7 @@ expressions): // success. getNextToken(); // eat ')'. - return llvm::make_unique(FnName, std::move(ArgNames)); + return std::make_unique(FnName, std::move(ArgNames)); } Given this, a function definition is very simple, just a prototype plus @@ -608,7 +608,7 @@ an expression to implement the body: if (!Proto) return nullptr; if (auto E = ParseExpression()) - return llvm::make_unique(std::move(Proto), std::move(E)); + return std::make_unique(std::move(Proto), std::move(E)); return nullptr; } @@ -634,8 +634,8 @@ nullary (zero argument) functions for them: static std::unique_ptr ParseTopLevelExpr() { if (auto E = ParseExpression()) { // Make an anonymous proto. - auto Proto = llvm::make_unique("", std::vector()); - return llvm::make_unique(std::move(Proto), std::move(E)); + auto Proto = std::make_unique("", std::vector()); + return std::make_unique(std::move(Proto), std::move(E)); } return nullptr; } diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst index 773ce55..f5a46a6 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.rst @@ -141,10 +141,10 @@ for us: void InitializeModuleAndPassManager(void) { // Open a new module. - TheModule = llvm::make_unique("my cool jit", TheContext); + TheModule = std::make_unique("my cool jit", TheContext); // Create a new pass manager attached to it. - TheFPM = llvm::make_unique(TheModule.get()); + TheFPM = std::make_unique(TheModule.get()); // Do simple "peephole" optimizations and bit-twiddling optzns. TheFPM->add(createInstructionCombiningPass()); @@ -259,7 +259,7 @@ adding a global variable ``TheJIT``, and initializing it in fprintf(stderr, "ready> "); getNextToken(); - TheJIT = llvm::make_unique(); + TheJIT = std::make_unique(); // Run the main "interpreter loop" now. MainLoop(); @@ -273,11 +273,11 @@ We also need to setup the data layout for the JIT: void InitializeModuleAndPassManager(void) { // Open a new module. - TheModule = llvm::make_unique("my cool jit", TheContext); + TheModule = std::make_unique("my cool jit", TheContext); TheModule->setDataLayout(TheJIT->getTargetMachine().createDataLayout()); // Create a new pass manager attached to it. - TheFPM = llvm::make_unique(TheModule.get()); + TheFPM = std::make_unique(TheModule.get()); ... The KaleidoscopeJIT class is a simple JIT built specifically for these diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl05.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl05.rst index 685e5fb..0e61c07 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl05.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl05.rst @@ -146,7 +146,7 @@ First we define a new parsing function: if (!Else) return nullptr; - return llvm::make_unique(std::move(Cond), std::move(Then), + return std::make_unique(std::move(Cond), std::move(Then), std::move(Else)); } @@ -560,7 +560,7 @@ value to null in the AST node: if (!Body) return nullptr; - return llvm::make_unique(IdName, std::move(Start), + return std::make_unique(IdName, std::move(Start), std::move(End), std::move(Step), std::move(Body)); } diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl06.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl06.rst index 911a7dc..a05ed0b 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl06.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl06.rst @@ -220,7 +220,7 @@ user-defined operator, we need to parse it: if (Kind && ArgNames.size() != Kind) return LogErrorP("Invalid number of operands for operator"); - return llvm::make_unique(FnName, std::move(ArgNames), Kind != 0, + return std::make_unique(FnName, std::move(ArgNames), Kind != 0, BinaryPrecedence); } @@ -348,7 +348,7 @@ simple: we'll add a new function to do it: int Opc = CurTok; getNextToken(); if (auto Operand = ParseUnary()) - return llvm::make_unique(Opc, std::move(Operand)); + return std::make_unique(Opc, std::move(Operand)); return nullptr; } diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst index 8013dec..218e441 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst @@ -780,7 +780,7 @@ AST node: if (!Body) return nullptr; - return llvm::make_unique(std::move(VarNames), + return std::make_unique(std::move(VarNames), std::move(Body)); } diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst index 1dcc0a8..87584cd 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst @@ -77,8 +77,8 @@ statement be our "main": .. code-block:: udiff - - auto Proto = llvm::make_unique("", std::vector()); - + auto Proto = llvm::make_unique("main", std::vector()); + - auto Proto = std::make_unique("", std::vector()); + + auto Proto = std::make_unique("main", std::vector()); just with the simple change of giving it a name. @@ -325,7 +325,7 @@ that we pass down through when we create a new expression: .. code-block:: c++ - LHS = llvm::make_unique(BinLoc, BinOp, std::move(LHS), + LHS = std::make_unique(BinLoc, BinOp, std::move(LHS), std::move(RHS)); giving us locations for each of our expressions and variables. -- cgit v1.1