summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index d52206d8cd3..ccb861cb187 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -269,10 +269,9 @@ void COFFObjectFile::moveSectionNext(DataRefImpl &Ref) const {
Ref.p = reinterpret_cast<uintptr_t>(Sec);
}
-std::error_code COFFObjectFile::getSectionName(DataRefImpl Ref,
- StringRef &Result) const {
+Expected<StringRef> COFFObjectFile::getSectionName(DataRefImpl Ref) const {
const coff_section *Sec = toSec(Ref);
- return getSectionName(Sec, Result);
+ return getSectionName(Sec);
}
uint64_t COFFObjectFile::getSectionAddress(DataRefImpl Ref) const {
@@ -1074,8 +1073,8 @@ uint32_t COFFObjectFile::getSymbolIndex(COFFSymbolRef Symbol) const {
return Index;
}
-std::error_code COFFObjectFile::getSectionName(const coff_section *Sec,
- StringRef &Res) const {
+Expected<StringRef>
+COFFObjectFile::getSectionName(const coff_section *Sec) const {
StringRef Name;
if (Sec->Name[COFF::NameSize - 1] == 0)
// Null terminated, let ::strlen figure out the length.
@@ -1089,17 +1088,18 @@ std::error_code COFFObjectFile::getSectionName(const coff_section *Sec,
uint32_t Offset;
if (Name.startswith("//")) {
if (decodeBase64StringEntry(Name.substr(2), Offset))
- return object_error::parse_failed;
+ return createStringError(object_error::parse_failed,
+ "inalid section name");
} else {
if (Name.substr(1).getAsInteger(10, Offset))
- return object_error::parse_failed;
+ return createStringError(object_error::parse_failed,
+ "invalid section name");
}
if (std::error_code EC = getString(Offset, Name))
- return EC;
+ return errorCodeToError(EC);
}
- Res = Name;
- return std::error_code();
+ return Name;
}
uint64_t COFFObjectFile::getSectionSize(const coff_section *Sec) const {
OpenPOWER on IntegriCloud