Update the MemoryBuffer API to use ErrorOr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212405 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-07-06 17:43:13 +00:00
parent 04e43e64a9
commit 7cba2a973f
35 changed files with 296 additions and 279 deletions

View File

@ -450,13 +450,14 @@ void SampleModuleProfile::dump() {
///
/// \returns true if the file was loaded successfully, false otherwise.
bool SampleModuleProfile::loadText() {
std::unique_ptr<MemoryBuffer> Buffer;
std::error_code EC = MemoryBuffer::getFile(Filename, Buffer);
if (EC) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFile(Filename);
if (std::error_code EC = BufferOrErr.getError()) {
std::string Msg(EC.message());
M.getContext().diagnose(DiagnosticInfoSampleProfile(Filename.data(), Msg));
return false;
}
std::unique_ptr<MemoryBuffer> Buffer = std::move(BufferOrErr.get());
line_iterator LineIt(*Buffer, '#');
// Read the profile of each function. Since each function may be