Remove ResourcePriorityQueue::dump as it relies on copying a non-copyable type which...
[oota-llvm.git] / lib / ProfileData / SampleProfWriter.cpp
index 49d6fdbf4f7be05645a237c818e9954a965b310d..c95267ad976b896d8b69d85e755fe7529c2077cb 100644 (file)
@@ -21,9 +21,9 @@
 #include "llvm/ProfileData/SampleProfWriter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorOr.h"
-#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/LineIterator.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Regex.h"
 
 using namespace llvm::sampleprof;
@@ -107,11 +107,10 @@ bool SampleProfileWriterBinary::write(StringRef FName,
 /// \param Format Encoding format for the profile file.
 ///
 /// \returns an error code indicating the status of the created writer.
-std::error_code
-SampleProfileWriter::create(StringRef Filename,
-                            std::unique_ptr<SampleProfileWriter> &Writer,
-                            SampleProfileFormat Format) {
+ErrorOr<std::unique_ptr<SampleProfileWriter>>
+SampleProfileWriter::create(StringRef Filename, SampleProfileFormat Format) {
   std::error_code EC;
+  std::unique_ptr<SampleProfileWriter> Writer;
 
   if (Format == SPF_Binary)
     Writer.reset(new SampleProfileWriterBinary(Filename, EC));
@@ -120,5 +119,8 @@ SampleProfileWriter::create(StringRef Filename,
   else
     EC = sampleprof_error::unrecognized_format;
 
-  return EC;
+  if (EC)
+    return EC;
+
+  return std::move(Writer);
 }