mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[Object] Change SymbolicFile::printSymbolName to use Error
llvm-svn: 360414
This commit is contained in:
parent
b25d3737f1
commit
d5d0ffef76
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -376,8 +376,8 @@ getSymbols(MemoryBufferRef Buf, raw_ostream &SymNames, bool &HasObject) {
|
||||
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;
|
||||
|
@ -42,10 +42,9 @@ void IRObjectFile::moveSymbolNext(DataRefImpl &Symb) const {
|
||||
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 {
|
||||
|
@ -56,13 +56,12 @@ uint64_t ObjectFile::getSymbolValue(DataRefImpl Ref) const {
|
||||
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; }
|
||||
|
@ -1219,11 +1219,12 @@ dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
|
||||
}
|
||||
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);
|
||||
|
@ -634,7 +634,7 @@ void printCOFFSymbolTable(const object::COFFImportFile *i) {
|
||||
std::string Name;
|
||||
raw_string_ostream NS(Name);
|
||||
|
||||
Sym.printName(NS);
|
||||
cantFail(Sym.printName(NS));
|
||||
NS.flush();
|
||||
|
||||
outs() << "[" << format("%2d", Index) << "]"
|
||||
|
@ -50,7 +50,7 @@ void dumpCOFFImportFile(const COFFImportFile *File, ScopedPrinter &Writer) {
|
||||
for (const object::BasicSymbolRef &Sym : File->symbols()) {
|
||||
raw_ostream &OS = Writer.startLine();
|
||||
OS << "Symbol: ";
|
||||
Sym.printName(OS);
|
||||
cantFail(Sym.printName(OS));
|
||||
OS << "\n";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user