summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-nm/llvm-nm.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/tools/llvm-nm/llvm-nm.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/tools/llvm-nm/llvm-nm.cpp')
-rw-r--r--llvm/tools/llvm-nm/llvm-nm.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 898ffd8bd92..336167f34bb 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -525,7 +525,8 @@ static void darwinPrintSymbol(SymbolicFile &Obj, const NMSymbol &S,
}
DataRefImpl Ref = Sec->getRawDataRefImpl();
StringRef SectionName;
- MachO->getSectionName(Ref, SectionName);
+ if (Expected<StringRef> NameOrErr = MachO->getSectionName(Ref))
+ SectionName = *NameOrErr;
StringRef SegmentName = MachO->getSectionFinalSegmentName(Ref);
outs() << "(" << SegmentName << "," << SectionName << ") ";
break;
@@ -951,10 +952,9 @@ static char getSymbolNMTypeChar(COFFObjectFile &Obj, symbol_iterator I) {
section_iterator SecI = *SecIOrErr;
const coff_section *Section = Obj.getCOFFSection(*SecI);
Characteristics = Section->Characteristics;
- StringRef SectionName;
- Obj.getSectionName(Section, SectionName);
- if (SectionName.startswith(".idata"))
- return 'i';
+ if (Expected<StringRef> NameOrErr = Obj.getSectionName(Section))
+ if (NameOrErr->startswith(".idata"))
+ return 'i';
}
switch (Symb.getSectionNumber()) {
@@ -1014,7 +1014,8 @@ static char getSymbolNMTypeChar(MachOObjectFile &Obj, basic_symbol_iterator I) {
return 's';
DataRefImpl Ref = Sec->getRawDataRefImpl();
StringRef SectionName;
- Obj.getSectionName(Ref, SectionName);
+ if (Expected<StringRef> NameOrErr = Obj.getSectionName(Ref))
+ SectionName = *NameOrErr;
StringRef SegmentName = Obj.getSectionFinalSegmentName(Ref);
if (Obj.is64Bit() && Obj.getHeader64().filetype == MachO::MH_KEXT_BUNDLE &&
SegmentName == "__TEXT_EXEC" && SectionName == "__text")
@@ -1136,7 +1137,8 @@ static unsigned getNsectForSegSect(MachOObjectFile *Obj) {
for (auto &S : Obj->sections()) {
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SectionName;
- Obj->getSectionName(Ref, SectionName);
+ if (Expected<StringRef> NameOrErr = Obj->getSectionName(Ref))
+ SectionName = *NameOrErr;
StringRef SegmentName = Obj->getSectionFinalSegmentName(Ref);
if (SegmentName == SegSect[0] && SectionName == SegSect[1])
return Nsect;
OpenPOWER on IntegriCloud