C++14: Use std::make_unique where possible. Bug: b/147359661 Change-Id: I20e3b90b02327250d77a1006cea712022ad0f9d5 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39951 Reviewed-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Reactor/Coroutine.hpp b/src/Reactor/Coroutine.hpp index 92ad2e3..7d45115 100644 --- a/src/Reactor/Coroutine.hpp +++ b/src/Reactor/Coroutine.hpp
@@ -185,7 +185,7 @@ using Sig = Nucleus::CoroutineBegin<Arguments...>; auto pfn = (Sig *)routine->getEntry(Nucleus::CoroutineEntryBegin); auto handle = pfn(args...); - return std::unique_ptr<Stream<Return>>(new Stream<Return>(routine, handle)); + return std::make_unique<Stream<Return>>(routine, handle); } # ifdef Yield // Defined in WinBase.h
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp index f64f910..d5244a8 100644 --- a/src/Reactor/LLVMReactor.cpp +++ b/src/Reactor/LLVMReactor.cpp
@@ -1499,7 +1499,7 @@ jit->function = rr::createFunction("", T(ReturnType), T(Params)); #ifdef ENABLE_RR_DEBUG_INFO - jit->debugInfo = std::unique_ptr<DebugInfo>(new DebugInfo(jit->builder.get(), &jit->context, jit->module.get(), jit->function)); + jit->debugInfo = std::make_unique<DebugInfo>(jit->builder.get(), &jit->context, jit->module.get(), jit->function); #endif // ENABLE_RR_DEBUG_INFO jit->builder->SetInsertPoint(llvm::BasicBlock::Create(jit->context, "", jit->function)); @@ -4908,7 +4908,7 @@ // #ifdef ENABLE_RR_DEBUG_INFO - jit->debugInfo = std::unique_ptr<rr::DebugInfo>(new rr::DebugInfo(jit->builder.get(), &jit->context, jit->module.get(), jit->function)); + jit->debugInfo = std::make_unique<rr::DebugInfo>(jit->builder.get(), &jit->context, jit->module.get(), jit->function); #endif // ENABLE_RR_DEBUG_INFO jit->coroutine.suspendBlock = llvm::BasicBlock::Create(jit->context, "suspend", jit->function);
diff --git a/src/Reactor/LLVMReactorDebugInfo.cpp b/src/Reactor/LLVMReactorDebugInfo.cpp index 0cf4723..f36f9c9 100644 --- a/src/Reactor/LLVMReactorDebugInfo.cpp +++ b/src/Reactor/LLVMReactorDebugInfo.cpp
@@ -521,7 +521,7 @@ return it->second.get(); } - auto tokens = std::unique_ptr<LineTokens>(new LineTokens()); + auto tokens = std::make_unique<LineTokens>(); std::ifstream file(path); std::string line;
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp index b40886a..e4b02c8 100644 --- a/src/Vulkan/VkCommandBuffer.cpp +++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -1365,7 +1365,7 @@ void CommandBuffer::addCommand(Args &&... args) { // FIXME (b/119409619): use an allocator here so we can control all memory allocations - commands->push_back(std::unique_ptr<T>(new T(std::forward<Args>(args)...))); + commands->push_back(std::make_unique<T>(std::forward<Args>(args)...)); } void CommandBuffer::beginRenderPass(RenderPass *renderPass, Framebuffer *framebuffer, VkRect2D renderArea,
diff --git a/src/WSI/XcbSurfaceKHR.cpp b/src/WSI/XcbSurfaceKHR.cpp index 1c55ea0..56f0ee2 100644 --- a/src/WSI/XcbSurfaceKHR.cpp +++ b/src/WSI/XcbSurfaceKHR.cpp
@@ -70,12 +70,12 @@ static auto exports = [] { if(getProcAddress(RTLD_DEFAULT, "xcb_create_gc")) { - return std::unique_ptr<LibXcbExports>(new LibXcbExports(RTLD_DEFAULT)); + return std::make_unique<LibXcbExports>(RTLD_DEFAULT); } if(auto lib = loadLibrary("libxcb.so.1")) { - return std::unique_ptr<LibXcbExports>(new LibXcbExports(lib)); + return std::make_unique<LibXcbExports>(lib); } return std::unique_ptr<LibXcbExports>();