ART: Update stl_util.h

Replace MakeUnique with std::make_unique. Remove unused functions.

Test: m
Change-Id: I3afdc0529cd6fb9d1797e5294a3d5ea2f6b38fc7
diff --git a/compiler/elf_writer_quick.cc b/compiler/elf_writer_quick.cc
index 63b7cad..5d6dd2e 100644
--- a/compiler/elf_writer_quick.cc
+++ b/compiler/elf_writer_quick.cc
@@ -22,7 +22,6 @@
 
 #include "base/casts.h"
 #include "base/logging.h"
-#include "base/stl_util.h"
 #include "compiled_method.h"
 #include "debug/elf_debug_writer.h"
 #include "debug/method_debug_info.h"
@@ -137,15 +136,15 @@
                                                 const CompilerOptions* compiler_options,
                                                 File* elf_file) {
   if (Is64BitInstructionSet(instruction_set)) {
-    return MakeUnique<ElfWriterQuick<ElfTypes64>>(instruction_set,
-                                                  features,
-                                                  compiler_options,
-                                                  elf_file);
+    return std::make_unique<ElfWriterQuick<ElfTypes64>>(instruction_set,
+                                                        features,
+                                                        compiler_options,
+                                                        elf_file);
   } else {
-    return MakeUnique<ElfWriterQuick<ElfTypes32>>(instruction_set,
-                                                  features,
-                                                  compiler_options,
-                                                  elf_file);
+    return std::make_unique<ElfWriterQuick<ElfTypes32>>(instruction_set,
+                                                        features,
+                                                        compiler_options,
+                                                        elf_file);
   }
 }
 
@@ -161,7 +160,8 @@
       rodata_size_(0u),
       text_size_(0u),
       bss_size_(0u),
-      output_stream_(MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(elf_file))),
+      output_stream_(
+          std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(elf_file))),
       builder_(new ElfBuilder<ElfTypes>(instruction_set, features, output_stream_.get())) {}
 
 template <typename ElfTypes>
diff --git a/compiler/image_test.h b/compiler/image_test.h
index 026e9e1..3d89757 100644
--- a/compiler/image_test.h
+++ b/compiler/image_test.h
@@ -26,7 +26,6 @@
 #include "android-base/stringprintf.h"
 
 #include "art_method-inl.h"
-#include "base/stl_util.h"
 #include "base/unix_file/fd_file.h"
 #include "class_linker-inl.h"
 #include "compiler_callbacks.h"
@@ -291,9 +290,9 @@
 
       if (kIsVdexEnabled) {
         for (size_t i = 0, size = vdex_files.size(); i != size; ++i) {
-          std::unique_ptr<BufferedOutputStream> vdex_out(
-              MakeUnique<BufferedOutputStream>(
-                  MakeUnique<FileOutputStream>(vdex_files[i].GetFile())));
+          std::unique_ptr<BufferedOutputStream> vdex_out =
+              std::make_unique<BufferedOutputStream>(
+                  std::make_unique<FileOutputStream>(vdex_files[i].GetFile()));
           oat_writers[i]->WriteVerifierDeps(vdex_out.get(), nullptr);
           oat_writers[i]->WriteChecksumsAndVdexHeader(vdex_out.get());
         }
diff --git a/compiler/linker/output_stream_test.cc b/compiler/linker/output_stream_test.cc
index 84c76f2..09fef29 100644
--- a/compiler/linker/output_stream_test.cc
+++ b/compiler/linker/output_stream_test.cc
@@ -19,7 +19,6 @@
 
 #include "base/unix_file/fd_file.h"
 #include "base/logging.h"
-#include "base/stl_util.h"
 #include "buffered_output_stream.h"
 #include "common_runtime_test.h"
 
@@ -79,7 +78,7 @@
 TEST_F(OutputStreamTest, Buffered) {
   ScratchFile tmp;
   {
-    BufferedOutputStream buffered_output_stream(MakeUnique<FileOutputStream>(tmp.GetFile()));
+    BufferedOutputStream buffered_output_stream(std::make_unique<FileOutputStream>(tmp.GetFile()));
     SetOutputStream(buffered_output_stream);
     GenerateTestOutput();
   }
@@ -125,7 +124,7 @@
     bool flush_called;
   };
 
-  std::unique_ptr<CheckingOutputStream> cos = MakeUnique<CheckingOutputStream>();
+  std::unique_ptr<CheckingOutputStream> cos = std::make_unique<CheckingOutputStream>();
   CheckingOutputStream* checking_output_stream = cos.get();
   BufferedOutputStream buffered(std::move(cos));
   ASSERT_FALSE(checking_output_stream->flush_called);
diff --git a/compiler/oat_test.cc b/compiler/oat_test.cc
index 84ec8b3..55d0bd9 100644
--- a/compiler/oat_test.cc
+++ b/compiler/oat_test.cc
@@ -225,8 +225,8 @@
                                       oat_writer.GetBssRootsOffset());
 
     if (kIsVdexEnabled) {
-      std::unique_ptr<BufferedOutputStream> vdex_out(
-            MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(vdex_file)));
+      std::unique_ptr<BufferedOutputStream> vdex_out =
+            std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(vdex_file));
       if (!oat_writer.WriteVerifierDeps(vdex_out.get(), nullptr)) {
         return false;
       }
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index 581b1ee..59daf5a 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -515,8 +515,8 @@
   ChecksumUpdatingOutputStream checksum_updating_rodata(oat_rodata, oat_header_.get());
 
   if (kIsVdexEnabled) {
-    std::unique_ptr<BufferedOutputStream> vdex_out(
-        MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(vdex_file)));
+    std::unique_ptr<BufferedOutputStream> vdex_out =
+        std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(vdex_file));
     // Write DEX files into VDEX, mmap and open them.
     if (!WriteDexFiles(vdex_out.get(), vdex_file, update_input_vdex) ||
         !OpenDexFiles(vdex_file, verify, &dex_files_map, &dex_files)) {
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 21e0724..3dd0703 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1402,8 +1402,8 @@
     // Note: we're only invalidating the magic data in the file, as dex2oat needs the rest of
     // the information to remain valid.
     if (update_input_vdex_) {
-      std::unique_ptr<BufferedOutputStream> vdex_out(MakeUnique<BufferedOutputStream>(
-          MakeUnique<FileOutputStream>(vdex_files_.back().get())));
+      std::unique_ptr<BufferedOutputStream> vdex_out = std::make_unique<BufferedOutputStream>(
+          std::make_unique<FileOutputStream>(vdex_files_.back().get()));
       if (!vdex_out->WriteFully(&VdexFile::Header::kVdexInvalidMagic,
                                 arraysize(VdexFile::Header::kVdexInvalidMagic))) {
         PLOG(ERROR) << "Failed to invalidate vdex header. File: " << vdex_out->GetLocation();
@@ -1900,8 +1900,8 @@
       verifier::VerifierDeps* verifier_deps = callbacks_->GetVerifierDeps();
       for (size_t i = 0, size = oat_files_.size(); i != size; ++i) {
         File* vdex_file = vdex_files_[i].get();
-        std::unique_ptr<BufferedOutputStream> vdex_out(
-            MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(vdex_file)));
+        std::unique_ptr<BufferedOutputStream> vdex_out =
+            std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(vdex_file));
 
         if (!oat_writers_[i]->WriteVerifierDeps(vdex_out.get(), verifier_deps)) {
           LOG(ERROR) << "Failed to write verifier dependencies into VDEX " << vdex_file->GetPath();
@@ -2933,7 +2933,7 @@
   // might produce a stack frame too large for this function or for
   // functions inlining it (such as main), that would not fit the
   // requirements of the `-Wframe-larger-than` option.
-  std::unique_ptr<Dex2Oat> dex2oat = MakeUnique<Dex2Oat>(&timings);
+  std::unique_ptr<Dex2Oat> dex2oat = std::make_unique<Dex2Oat>(&timings);
 
   // Parse arguments. Argument mistakes will lead to exit(EXIT_FAILURE) in UsageError.
   dex2oat->ParseArgs(argc, argv);
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 0c64b9f..9b95de2 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -130,8 +130,8 @@
     if (elf_file == nullptr) {
       return false;
     }
-    std::unique_ptr<BufferedOutputStream> output_stream(
-        MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(elf_file.get())));
+    std::unique_ptr<BufferedOutputStream> output_stream =
+        std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(elf_file.get()));
     builder_.reset(new ElfBuilder<ElfTypes>(isa, features.get(), output_stream.get()));
 
     builder_->Start();
diff --git a/runtime/base/stl_util.h b/runtime/base/stl_util.h
index f99465a..b272972 100644
--- a/runtime/base/stl_util.h
+++ b/runtime/base/stl_util.h
@@ -25,13 +25,6 @@
 
 namespace art {
 
-// Sort and remove duplicates of an STL vector or deque.
-template<class T>
-void STLSortAndRemoveDuplicates(T* v) {
-  std::sort(v->begin(), v->end());
-  v->erase(std::unique(v->begin(), v->end()), v->end());
-}
-
 // STLDeleteContainerPointers()
 //  For a range within a container of pointers, calls delete
 //  (non-array version) on these pointers.
@@ -83,20 +76,6 @@
   }
 }
 
-template <class T>
-std::string ToString(const T& v) {
-  std::ostringstream os;
-  os << "[";
-  for (size_t i = 0; i < v.size(); ++i) {
-    os << v[i];
-    if (i < v.size() - 1) {
-      os << ", ";
-    }
-  }
-  os << "]";
-  return os.str();
-}
-
 // Deleter using free() for use with std::unique_ptr<>. See also UniqueCPtr<> below.
 struct FreeDelete {
   // NOTE: Deleting a const object is valid but free() takes a non-const pointer.
@@ -109,13 +88,6 @@
 template <typename T>
 using UniqueCPtr = std::unique_ptr<T, FreeDelete>;
 
-// C++14 from-the-future import (std::make_unique)
-// Invoke the constructor of 'T' with the provided args, and wrap the result in a unique ptr.
-template <typename T, typename ... Args>
-std::unique_ptr<T> MakeUnique(Args&& ... args) {
-  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
-}
-
 // Find index of the first element with the specified value known to be in the container.
 template <typename Container, typename T>
 size_t IndexOfElement(const Container& container, const T& value) {
@@ -150,13 +122,6 @@
   return it != container.end();
 }
 
-// const char* compare function suitable for std::map or std::set.
-struct CStringLess {
-  bool operator()(const char* lhs, const char* rhs) const {
-    return strcmp(lhs, rhs) < 0;
-  }
-};
-
 // 32-bit FNV-1a hash function suitable for std::unordered_map.
 // It can be used with any container which works with range-based for loop.
 // See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index 01c6641..f925994 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -728,13 +728,3 @@
 }
 
 }  // namespace art
-
-namespace std {
-
-template <typename T>
-std::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs) {
-os << ::art::ToString(rhs);
-return os;
-}
-
-}  // namespace std
diff --git a/runtime/common_runtime_test.h b/runtime/common_runtime_test.h
index 24dbd05..1274a36 100644
--- a/runtime/common_runtime_test.h
+++ b/runtime/common_runtime_test.h
@@ -258,12 +258,4 @@
 
 }  // namespace art
 
-namespace std {
-
-// TODO: isn't gtest supposed to be able to print STL types for itself?
-template <typename T>
-std::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs);
-
-}  // namespace std
-
 #endif  // ART_RUNTIME_COMMON_RUNTIME_TEST_H_