summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 179166ddbd3..3bfbfe06944 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -1986,12 +1986,13 @@ Expected<SectionRef> MachOObjectFile::getSection(unsigned SectionIndex) const {
}
Expected<SectionRef> MachOObjectFile::getSection(StringRef SectionName) const {
+ StringRef SecName;
for (const SectionRef &Section : sections()) {
- auto NameOrErr = Section.getName();
- if (!NameOrErr)
- return NameOrErr.takeError();
- if (*NameOrErr == SectionName)
+ if (std::error_code E = Section.getName(SecName))
+ return errorCodeToError(E);
+ if (SecName == SectionName) {
return Section;
+ }
}
return errorCodeToError(object_error::parse_failed);
}
@@ -3994,11 +3995,7 @@ BindRebaseSegInfo::BindRebaseSegInfo(const object::MachOObjectFile *Obj) {
uint64_t CurSegAddress;
for (const SectionRef &Section : Obj->sections()) {
SectionInfo Info;
- Expected<StringRef> NameOrErr = Section.getName();
- if (!NameOrErr)
- consumeError(NameOrErr.takeError());
- else
- Info.SectionName = *NameOrErr;
+ Section.getName(Info.SectionName);
Info.Address = Section.getAddress();
Info.Size = Section.getSize();
Info.SegmentName =
OpenPOWER on IntegriCloud