[llvm] r360414 - [Object] Change SymbolicFile::printSymbolName to use Error
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri May 10 02:59:04 PDT 2019
Author: maskray
Date: Fri May 10 02:59:04 2019
New Revision: 360414
URL: http://llvm.org/viewvc/llvm-project?rev=360414&view=rev
Log:
[Object] Change SymbolicFile::printSymbolName to use Error
Modified:
llvm/trunk/include/llvm/Object/COFFImportFile.h
llvm/trunk/include/llvm/Object/IRObjectFile.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/include/llvm/Object/SymbolicFile.h
llvm/trunk/lib/Object/ArchiveWriter.cpp
llvm/trunk/lib/Object/IRObjectFile.cpp
llvm/trunk/lib/Object/ObjectFile.cpp
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
llvm/trunk/tools/llvm-objdump/COFFDump.cpp
llvm/trunk/tools/llvm-readobj/COFFImportDumper.cpp
Modified: llvm/trunk/include/llvm/Object/COFFImportFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFFImportFile.h?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFFImportFile.h (original)
+++ llvm/trunk/include/llvm/Object/COFFImportFile.h Fri May 10 02:59:04 2019
@@ -36,12 +36,11 @@ public:
void moveSymbolNext(DataRefImpl &Symb) const override { ++Symb.p; }
- std::error_code printSymbolName(raw_ostream &OS,
- DataRefImpl Symb) const override {
+ Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override {
if (Symb.p == 0)
OS << "__imp_";
OS << StringRef(Data.getBufferStart() + sizeof(coff_import_header));
- return std::error_code();
+ return Error::success();
}
uint32_t getSymbolFlags(DataRefImpl Symb) const override {
Modified: llvm/trunk/include/llvm/Object/IRObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/IRObjectFile.h?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/IRObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/IRObjectFile.h Fri May 10 02:59:04 2019
@@ -37,8 +37,7 @@ class IRObjectFile : public SymbolicFile
public:
~IRObjectFile() override;
void moveSymbolNext(DataRefImpl &Symb) const override;
- std::error_code printSymbolName(raw_ostream &OS,
- DataRefImpl Symb) const override;
+ Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override;
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
basic_symbol_iterator symbol_begin() const override;
basic_symbol_iterator symbol_end() const override;
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Fri May 10 02:59:04 2019
@@ -244,7 +244,7 @@ protected:
friend class SymbolRef;
virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
- std::error_code printSymbolName(raw_ostream &OS,
+ Error printSymbolName(raw_ostream &OS,
DataRefImpl Symb) const override;
virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
Modified: llvm/trunk/include/llvm/Object/SymbolicFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/SymbolicFile.h?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/SymbolicFile.h (original)
+++ llvm/trunk/include/llvm/Object/SymbolicFile.h Fri May 10 02:59:04 2019
@@ -126,7 +126,7 @@ public:
void moveNext();
- std::error_code printName(raw_ostream &OS) const;
+ Error printName(raw_ostream &OS) const;
/// Get symbol flags (bitwise OR of SymbolRef::Flags)
uint32_t getFlags() const;
@@ -145,8 +145,7 @@ public:
// virtual interface.
virtual void moveSymbolNext(DataRefImpl &Symb) const = 0;
- virtual std::error_code printSymbolName(raw_ostream &OS,
- DataRefImpl Symb) const = 0;
+ virtual Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const = 0;
virtual uint32_t getSymbolFlags(DataRefImpl Symb) const = 0;
@@ -193,7 +192,7 @@ inline void BasicSymbolRef::moveNext() {
return OwningObject->moveSymbolNext(SymbolPimpl);
}
-inline std::error_code BasicSymbolRef::printName(raw_ostream &OS) const {
+inline Error BasicSymbolRef::printName(raw_ostream &OS) const {
return OwningObject->printSymbolName(OS, SymbolPimpl);
}
Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Fri May 10 02:59:04 2019
@@ -376,8 +376,8 @@ getSymbols(MemoryBufferRef Buf, raw_ostr
if (!isArchiveSymbol(S))
continue;
Ret.push_back(SymNames.tell());
- if (auto EC = S.printName(SymNames))
- return errorCodeToError(EC);
+ if (Error E = S.printName(SymNames))
+ return std::move(E);
SymNames << '\0';
}
return Ret;
Modified: llvm/trunk/lib/Object/IRObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/lib/Object/IRObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/IRObjectFile.cpp Fri May 10 02:59:04 2019
@@ -42,10 +42,9 @@ void IRObjectFile::moveSymbolNext(DataRe
Symb.p += sizeof(ModuleSymbolTable::Symbol);
}
-std::error_code IRObjectFile::printSymbolName(raw_ostream &OS,
- DataRefImpl Symb) const {
+Error IRObjectFile::printSymbolName(raw_ostream &OS, DataRefImpl Symb) const {
SymTab.printSymbolName(OS, getSym(Symb));
- return std::error_code();
+ return Error::success();
}
uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const {
Modified: llvm/trunk/lib/Object/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ObjectFile.cpp?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ObjectFile.cpp Fri May 10 02:59:04 2019
@@ -56,13 +56,12 @@ uint64_t ObjectFile::getSymbolValue(Data
return getSymbolValueImpl(Ref);
}
-std::error_code ObjectFile::printSymbolName(raw_ostream &OS,
- DataRefImpl Symb) const {
+Error ObjectFile::printSymbolName(raw_ostream &OS, DataRefImpl Symb) const {
Expected<StringRef> Name = getSymbolName(Symb);
if (!Name)
- return errorToErrorCode(Name.takeError());
+ return Name.takeError();
OS << *Name;
- return std::error_code();
+ return Error::success();
}
uint32_t ObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; }
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Fri May 10 02:59:04 2019
@@ -1219,11 +1219,12 @@ dumpSymbolNamesFromObject(SymbolicFile &
}
S.TypeName = getNMTypeName(Obj, Sym);
S.TypeChar = getNMSectionTagAndName(Obj, Sym, S.SectionName);
- std::error_code EC = Sym.printName(OS);
- if (EC && MachO)
- OS << "bad string index";
- else
- error(EC);
+ if (Error E = Sym.printName(OS)) {
+ if (MachO)
+ OS << "bad string index";
+ else
+ error(std::move(E), Obj.getFileName());
+ }
OS << '\0';
S.Sym = Sym;
SymbolList.push_back(S);
Modified: llvm/trunk/tools/llvm-objdump/COFFDump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/COFFDump.cpp?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/COFFDump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/COFFDump.cpp Fri May 10 02:59:04 2019
@@ -634,7 +634,7 @@ void printCOFFSymbolTable(const object::
std::string Name;
raw_string_ostream NS(Name);
- Sym.printName(NS);
+ cantFail(Sym.printName(NS));
NS.flush();
outs() << "[" << format("%2d", Index) << "]"
Modified: llvm/trunk/tools/llvm-readobj/COFFImportDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFImportDumper.cpp?rev=360414&r1=360413&r2=360414&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFImportDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFImportDumper.cpp Fri May 10 02:59:04 2019
@@ -50,7 +50,7 @@ void dumpCOFFImportFile(const COFFImport
for (const object::BasicSymbolRef &Sym : File->symbols()) {
raw_ostream &OS = Writer.startLine();
OS << "Symbol: ";
- Sym.printName(OS);
+ cantFail(Sym.printName(OS));
OS << "\n";
}
}
More information about the llvm-commits
mailing list