Commit 368d39c3 by Ben Clayton

C++14: Use std::make_unique where possible.

Bug: b/147359661 Change-Id: I20e3b90b02327250d77a1006cea712022ad0f9d5 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39951Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 73bcece4
......@@ -185,7 +185,7 @@ Coroutine<Return(Arguments...)>::operator()(Arguments... args)
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
......
......@@ -1499,7 +1499,7 @@ void Nucleus::createFunction(Type *ReturnType, std::vector<Type *> &Params)
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 @@ void promoteFunctionToCoroutine()
//
#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);
......
......@@ -521,7 +521,7 @@ DebugInfo::LineTokens const *DebugInfo::getOrParseFileTokens(const char *path)
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;
......
......@@ -1365,7 +1365,7 @@ template<typename T, typename... Args>
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,
......
......@@ -70,12 +70,12 @@ private:
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>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment