From a076ec54bee20c423cf710ea2818d01df84e28b0 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 16 May 2019 11:33:48 +0000 Subject: [Object] Change object::SectionRef::getContents() to return Expected Expected> may be better but use Expected for now. Follow-up of D61781. llvm-svn: 360876 --- llvm/lib/Object/IRObjectFile.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Object/IRObjectFile.cpp') diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index debe7899bfe..636f1521262 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -74,12 +74,12 @@ Expected IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { for (const SectionRef &Sec : Obj.sections()) { if (Sec.isBitcode()) { - StringRef SecContents; - if (std::error_code EC = Sec.getContents(SecContents)) - return errorCodeToError(EC); - if (SecContents.size() <= 1) + Expected Contents = Sec.getContents(); + if (!Contents) + return Contents.takeError(); + if (Contents->size() <= 1) return errorCodeToError(object_error::bitcode_section_not_found); - return MemoryBufferRef(SecContents, Obj.getFileName()); + return MemoryBufferRef(*Contents, Obj.getFileName()); } } -- cgit v1.2.3