#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;
/// \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));
else
EC = sampleprof_error::unrecognized_format;
- return EC;
+ if (EC)
+ return EC;
+
+ return std::move(Writer);
}