diff options
author | Diego Novillo <dnovillo@google.com> | 2014-11-03 00:51:45 +0000 |
---|---|---|
committer | Diego Novillo <dnovillo@google.com> | 2014-11-03 00:51:45 +0000 |
commit | fcd556074c03ab47fe809e1f94fc78a3b3fe94dd (patch) | |
tree | 0a20112f562c2a7dd6c9c11b0eebde6cedecd04c /llvm/lib/ProfileData/SampleProfWriter.cpp | |
parent | 4cd1d4ecb1a89d6201c24df5f48dd4c5366747fe (diff) | |
download | bcm5719-llvm-fcd556074c03ab47fe809e1f94fc78a3b3fe94dd.tar.gz bcm5719-llvm-fcd556074c03ab47fe809e1f94fc78a3b3fe94dd.zip |
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
llvm-svn: 221120
Diffstat (limited to 'llvm/lib/ProfileData/SampleProfWriter.cpp')
-rw-r--r-- | llvm/lib/ProfileData/SampleProfWriter.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp index 49d6fdbf4f7..85250452bd1 100644 --- a/llvm/lib/ProfileData/SampleProfWriter.cpp +++ b/llvm/lib/ProfileData/SampleProfWriter.cpp @@ -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); } |