Modernise code to use std::make_unique
Generated by clang-tidy.
Test: m checkbuild
Change-Id: Idb24960d9326c0d94ab5d04b18deb0894d23da9f
diff --git a/runtime/monitor_test.cc b/runtime/monitor_test.cc
index 8610899..8ddd50f 100644
--- a/runtime/monitor_test.cc
+++ b/runtime/monitor_test.cc
@@ -16,6 +16,7 @@
#include "monitor.h"
+#include <memory>
#include <string>
#include "base/atomic.h"
@@ -251,8 +252,8 @@
"hello, world!"));
// Create the barrier used to synchronize.
- test->barrier_ = std::unique_ptr<Barrier>(new Barrier(2));
- test->complete_barrier_ = std::unique_ptr<Barrier>(new Barrier(3));
+ test->barrier_ = std::make_unique<Barrier>(2);
+ test->complete_barrier_ = std::make_unique<Barrier>(3);
test->completed_ = false;
// Our job: Fill the heap, then try Wait.
diff --git a/runtime/native_stack_dump.cc b/runtime/native_stack_dump.cc
index ce295aa..10f5898 100644
--- a/runtime/native_stack_dump.cc
+++ b/runtime/native_stack_dump.cc
@@ -16,6 +16,7 @@
#include "native_stack_dump.h"
+#include <memory>
#include <ostream>
#include <stdio.h>
@@ -128,10 +129,10 @@
} else {
close(caller_to_addr2line[0]);
close(addr2line_to_caller[1]);
- return std::unique_ptr<Addr2linePipe>(new Addr2linePipe(addr2line_to_caller[0],
- caller_to_addr2line[1],
- name,
- pid));
+ return std::make_unique<Addr2linePipe>(addr2line_to_caller[0],
+ caller_to_addr2line[1],
+ name,
+ pid);
}
}
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 2e495cc..7157928 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -16,6 +16,7 @@
#include "parsed_options.h"
+#include <memory>
#include <sstream>
#include <android-base/logging.h>
@@ -67,7 +68,7 @@
using M = RuntimeArgumentMap;
std::unique_ptr<RuntimeParser::Builder> parser_builder =
- std::unique_ptr<RuntimeParser::Builder>(new RuntimeParser::Builder());
+ std::make_unique<RuntimeParser::Builder>();
parser_builder->
Define("-Xzygote")
@@ -346,7 +347,7 @@
// TODO: Move Usage information into this DSL.
- return std::unique_ptr<RuntimeParser>(new RuntimeParser(parser_builder->Build()));
+ return std::make_unique<RuntimeParser>(parser_builder->Build());
}
#pragma GCC diagnostic pop