Modernise code to use std::make_unique

Generated by clang-tidy.

Test: m checkbuild
Change-Id: Idb24960d9326c0d94ab5d04b18deb0894d23da9f
diff --git a/cmdline/token_range.h b/cmdline/token_range.h
index 642bb1d..e28ead9 100644
--- a/cmdline/token_range.h
+++ b/cmdline/token_range.h
@@ -325,7 +325,7 @@
     string_idx += remaining;
     maybe_push_wildcard_token();
 
-    return std::unique_ptr<TokenRange>(new TokenRange(std::move(new_token_list)));
+    return std::make_unique<TokenRange>(std::move(new_token_list));
   }
 
   // Do a quick match token-by-token, and see if they match.
diff --git a/compiler/driver/simple_compiler_options_map.h b/compiler/driver/simple_compiler_options_map.h
index 3860da9..e7a51a4 100644
--- a/compiler/driver/simple_compiler_options_map.h
+++ b/compiler/driver/simple_compiler_options_map.h
@@ -50,7 +50,7 @@
 
 static inline Parser CreateSimpleParser(bool ignore_unrecognized) {
   std::unique_ptr<Parser::Builder> parser_builder =
-      std::unique_ptr<Parser::Builder>(new Parser::Builder());
+      std::make_unique<Parser::Builder>();
 
   AddCompilerOptionsArgumentParserOptions<SimpleParseArgumentMap>(*parser_builder);
 
diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc
index 710f14c..236c1fc 100644
--- a/dex2oat/dex2oat_options.cc
+++ b/dex2oat/dex2oat_options.cc
@@ -187,7 +187,7 @@
 }
 
 static Parser CreateArgumentParser() {
-  std::unique_ptr<Builder> parser_builder = std::unique_ptr<Builder>(new Builder());
+  std::unique_ptr<Builder> parser_builder = std::make_unique<Builder>();
 
   AddInputMappings(*parser_builder);
   AddGeneratedArtifactMappings(*parser_builder);
@@ -267,7 +267,7 @@
     return nullptr;
   }
 
-  return std::unique_ptr<Dex2oatArgumentMap>(new Dex2oatArgumentMap(parser.ReleaseArgumentsMap()));
+  return std::make_unique<Dex2oatArgumentMap>(parser.ReleaseArgumentsMap());
 }
 
 #pragma GCC diagnostic pop
diff --git a/dex2oat/linker/elf_writer_quick.cc b/dex2oat/linker/elf_writer_quick.cc
index 9a7f93d..9fbcca4 100644
--- a/dex2oat/linker/elf_writer_quick.cc
+++ b/dex2oat/linker/elf_writer_quick.cc
@@ -17,6 +17,7 @@
 #include "elf_writer_quick.h"
 
 #include <openssl/sha.h>
+#include <memory>
 #include <unordered_map>
 #include <unordered_set>
 
@@ -263,16 +264,15 @@
   if (!debug_info.Empty() && compiler_options_.GetGenerateMiniDebugInfo()) {
     // Prepare the mini-debug-info in background while we do other I/O.
     Thread* self = Thread::Current();
-    debug_info_task_ = std::unique_ptr<DebugInfoTask>(
-        new DebugInfoTask(builder_->GetIsa(),
-                          compiler_options_.GetInstructionSetFeatures(),
-                          builder_->GetText()->GetAddress(),
-                          text_size_,
-                          builder_->GetDex()->Exists() ? builder_->GetDex()->GetAddress() : 0,
-                          dex_section_size_,
-                          debug_info));
-    debug_info_thread_pool_ = std::unique_ptr<ThreadPool>(
-        new ThreadPool("Mini-debug-info writer", 1));
+    debug_info_task_ = std::make_unique<DebugInfoTask>(
+        builder_->GetIsa(),
+        compiler_options_.GetInstructionSetFeatures(),
+        builder_->GetText()->GetAddress(),
+        text_size_,
+        builder_->GetDex()->Exists() ? builder_->GetDex()->GetAddress() : 0,
+        dex_section_size_,
+        debug_info);
+    debug_info_thread_pool_ = std::make_unique<ThreadPool>("Mini-debug-info writer", 1);
     debug_info_thread_pool_->AddTask(self, debug_info_task_.get());
     debug_info_thread_pool_->StartWorkers(self);
   }
diff --git a/dexlayout/dex_ir_builder.cc b/dexlayout/dex_ir_builder.cc
index 947d3d5..7789c5f 100644
--- a/dexlayout/dex_ir_builder.cc
+++ b/dexlayout/dex_ir_builder.cc
@@ -17,6 +17,7 @@
  */
 
 #include <stdint.h>
+#include <memory>
 #include <vector>
 
 #include "dex_ir_builder.h"
@@ -698,8 +699,8 @@
       uint32_t annotation_set_offset = fields[i].annotations_off_;
       AnnotationSetItem* annotation_set_item =
           CreateAnnotationSetItem(dex_file, field_set_item, annotation_set_offset);
-      field_annotations->push_back(std::unique_ptr<FieldAnnotation>(
-          new FieldAnnotation(field_id, annotation_set_item)));
+      field_annotations->push_back(std::make_unique<FieldAnnotation>(
+          field_id, annotation_set_item));
     }
   }
   const DexFile::MethodAnnotationsItem* methods =
@@ -714,8 +715,8 @@
       uint32_t annotation_set_offset = methods[i].annotations_off_;
       AnnotationSetItem* annotation_set_item =
           CreateAnnotationSetItem(dex_file, method_set_item, annotation_set_offset);
-      method_annotations->push_back(std::unique_ptr<MethodAnnotation>(
-          new MethodAnnotation(method_id, annotation_set_item)));
+      method_annotations->push_back(std::make_unique<MethodAnnotation>(
+          method_id, annotation_set_item));
     }
   }
   const DexFile::ParameterAnnotationsItem* parameters =
@@ -1160,9 +1161,9 @@
       // Decode all name=value pairs.
       for (uint32_t i = 0; i < size; i++) {
         const uint32_t name_index = DecodeUnsignedLeb128(data);
-        elements->push_back(std::unique_ptr<AnnotationElement>(
-            new AnnotationElement(header_->StringIds()[name_index],
-                                  ReadEncodedValue(dex_file, data))));
+        elements->push_back(std::make_unique<AnnotationElement>(
+            header_->StringIds()[name_index],
+            ReadEncodedValue(dex_file, data)));
       }
       item->SetEncodedAnnotation(new EncodedAnnotation(header_->TypeIds()[type_idx], elements));
       break;
diff --git a/openjdkjvmti/OpenjdkJvmTi.cc b/openjdkjvmti/OpenjdkJvmTi.cc
index a2fabbf..bd5b598 100644
--- a/openjdkjvmti/OpenjdkJvmTi.cc
+++ b/openjdkjvmti/OpenjdkJvmTi.cc
@@ -29,6 +29,7 @@
  * questions.
  */
 
+#include <memory>
 #include <string>
 #include <type_traits>
 #include <vector>
@@ -1492,7 +1493,7 @@
       capabilities(),
       event_info_mutex_("jvmtiEnv_EventInfoMutex"),
       last_error_mutex_("jvmtiEnv_LastErrorMutex", art::LockLevel::kGenericBottomLock) {
-  object_tag_table = std::unique_ptr<ObjectTagTable>(new ObjectTagTable(event_handler, this));
+  object_tag_table = std::make_unique<ObjectTagTable>(event_handler, this);
   functions = &gJvmtiInterface;
 }
 
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