mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Use ErrorOr for the ::create factory on instrumented and sample profilers.
Summary: As discussed in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141027/242445.html, the creation of reader and writer instances is better done using ErrorOr. There are no functional changes, but several callers needed to be adjusted. Reviewers: bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D6076 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user