summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-05-02 10:32:03 +0000
committerFangrui Song <maskray@google.com>2019-05-02 10:32:03 +0000
commit8be28cdc5281edbe83886168978303345ca4a78b (patch)
tree613ac659e7c0e7384806266757e1fbf34bf418c6 /llvm/lib/Object/COFFObjectFile.cpp
parent71569d0d523465203ba465a89c37d75075a5e2c2 (diff)
downloadbcm5719-llvm-8be28cdc5281edbe83886168978303345ca4a78b.tar.gz
bcm5719-llvm-8be28cdc5281edbe83886168978303345ca4a78b.zip
[Object] Change getSectionName() to return Expected<StringRef>
Summary: It currently receives an output parameter and returns std::error_code. Expected<StringRef> fits for this purpose perfectly. Differential Revision: https://reviews.llvm.org/D61421 llvm-svn: 359774
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