#include <fstream>
using namespace llvm;
-using std::error_code;
namespace {
// OutputType - Allow the user to specify the way code should be run, to test
// Emit the program to a bitcode file...
SmallString<128> BitcodeFile;
int BitcodeFD;
- error_code EC = sys::fs::createUniqueFile(
+ std::error_code EC = sys::fs::createUniqueFile(
OutputPrefix + "-test-program-%%%%%%%.bc", BitcodeFD, BitcodeFile);
if (EC) {
errs() << ToolName << ": Error making unique filename: " << EC.message()
// Emit the program to a bitcode file...
SmallString<128> UniqueFilename;
int UniqueFD;
- error_code EC = sys::fs::createUniqueFile(
+ std::error_code EC = sys::fs::createUniqueFile(
OutputPrefix + "-test-program-%%%%%%%.bc", UniqueFD, UniqueFilename);
if (EC) {
errs() << ToolName << ": Error making unique filename: "
// Check to see if this is a valid output filename...
SmallString<128> UniqueFile;
- error_code EC = sys::fs::createUniqueFile(OutputFile, UniqueFile);
+ std::error_code EC = sys::fs::createUniqueFile(OutputFile, UniqueFile);
if (EC) {
errs() << ToolName << ": Error making unique filename: "
<< EC.message() << "\n";
#include "llvm/Transforms/Utils/CodeExtractor.h"
#include <set>
using namespace llvm;
-using std::error_code;
#define DEBUG_TYPE "bugpoint"
Module *M) {
SmallString<128> Filename;
int FD;
- error_code EC = sys::fs::createUniqueFile(
+ std::error_code EC = sys::fs::createUniqueFile(
OutputPrefix + "-extractblocks%%%%%%%", FD, Filename);
if (EC) {
outs() << "*** Basic Block extraction failed!\n";
#include "llvm/Support/FileUtilities.h"
#include "llvm/Transforms/Utils/Cloning.h"
using namespace llvm;
-using std::error_code;
namespace llvm {
extern cl::opt<std::string> OutputPrefix;
SmallString<128> TestModuleBC;
int TestModuleFD;
- error_code EC = sys::fs::createTemporaryFile("bugpoint.test", "bc",
- TestModuleFD, TestModuleBC);
+ std::error_code EC = sys::fs::createTemporaryFile("bugpoint.test", "bc",
+ TestModuleFD, TestModuleBC);
if (EC) {
errs() << BD.getToolName() << "Error making unique filename: "
<< EC.message() << "\n";
SmallString<128> TestModuleBC;
int TestModuleFD;
- error_code EC = sys::fs::createTemporaryFile("bugpoint.test", "bc",
- TestModuleFD, TestModuleBC);
+ std::error_code EC = sys::fs::createTemporaryFile("bugpoint.test", "bc",
+ TestModuleFD, TestModuleBC);
if (EC) {
errs() << getToolName() << "Error making unique filename: "
<< EC.message() << "\n";
#include <fstream>
using namespace llvm;
-using std::error_code;
#define DEBUG_TYPE "bugpoint"
// setup the output file name
outs().flush();
SmallString<128> UniqueFilename;
- error_code EC = sys::fs::createUniqueFile(
+ std::error_code EC = sys::fs::createUniqueFile(
OutputPrefix + "-output-%%%%%%%.bc", UniqueFilename);
if (EC) {
errs() << getToolName() << ": Error making unique filename: "
#include <fstream>
#include <sstream>
using namespace llvm;
-using std::error_code;
#define DEBUG_TYPE "toolrunner"
// Rerun the compiler, capturing any error messages to print them.
SmallString<128> ErrorFilename;
int ErrorFD;
- error_code EC = sys::fs::createTemporaryFile(
+ std::error_code EC = sys::fs::createTemporaryFile(
"bugpoint.program_error_messages", "", ErrorFD, ErrorFilename);
if (EC) {
errs() << "Error making unique filename: " << EC.message() << "\n";
const char *Suffix = (UseIntegratedAssembler ? ".llc.o" : ".llc.s");
SmallString<128> UniqueFile;
- error_code EC =
+ std::error_code EC =
sys::fs::createUniqueFile(Bitcode + "-%%%%%%%" + Suffix, UniqueFile);
if (EC) {
errs() << "Error making unique filename: " << EC.message() << "\n";
GCCArgs.push_back("-o");
SmallString<128> OutputBinary;
- error_code EC =
+ std::error_code EC =
sys::fs::createUniqueFile(ProgramFile + "-%%%%%%%.gcc.exe", OutputBinary);
if (EC) {
errs() << "Error making unique filename: " << EC.message() << "\n";
const std::vector<std::string> &ArgsForGCC,
std::string &Error) {
SmallString<128> UniqueFilename;
- error_code EC = sys::fs::createUniqueFile(
+ std::error_code EC = sys::fs::createUniqueFile(
InputFile + "-%%%%%%%" + LTDL_SHLIB_EXT, UniqueFilename);
if (EC) {
errs() << "Error making unique filename: " << EC.message() << "\n";
#endif
using namespace llvm;
-using std::error_code;
namespace {
ld_plugin_status discard_message(int level, const char *format, ...) {
if (file->offset) {
offset = file->offset;
}
- if (error_code ec = MemoryBuffer::getOpenFileSlice(
+ if (std::error_code ec = MemoryBuffer::getOpenFileSlice(
file->fd, file->name, buffer, file->filesize, offset)) {
(*message)(LDPL_ERROR, ec.message().c_str());
return LDPS_ERR;
static ld_plugin_status cleanup_hook(void) {
for (int i = 0, e = Cleanup.size(); i != e; ++i) {
- error_code EC = sys::fs::remove(Cleanup[i]);
+ std::error_code EC = sys::fs::remove(Cleanup[i]);
if (EC)
(*message)(LDPL_ERROR, "Failed to delete '%s': %s", Cleanup[i].c_str(),
EC.message().c_str());
#include "llvm/Support/Format.h"
using namespace llvm;
-using std::error_code;
#define DEBUG_TYPE "lli"
}
sys::MemoryBlock RemoteMemoryManager::allocateSection(uintptr_t Size) {
- error_code ec;
+ std::error_code ec;
sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(Size,
&Near,
sys::Memory::MF_READ |
#endif
using namespace llvm;
-using std::error_code;
#define DEBUG_TYPE "lli"
// If not jitting lazily, load the whole bitcode file eagerly too.
if (NoLazyCompilation) {
- if (error_code EC = Mod->materializeAllPermanently()) {
+ if (std::error_code EC = Mod->materializeAllPermanently()) {
errs() << argv[0] << ": bitcode didn't read correctly.\n";
errs() << "Reason: " << EC.message() << "\n";
exit(1);
for (unsigned i = 0, e = ExtraArchives.size(); i != e; ++i) {
std::unique_ptr<MemoryBuffer> ArBuf;
- error_code ec;
+ std::error_code ec;
ec = MemoryBuffer::getFileOrSTDIN(ExtraArchives[i], ArBuf);
if (ec) {
Err.print(argv[0], errs());
#endif
using namespace llvm;
-using std::error_code;
// The name this program was invoked as.
static StringRef ToolName;
exit(1);
}
-static void failIfError(error_code EC, Twine Context = "") {
+static void failIfError(std::error_code EC, Twine Context = "") {
if (!EC)
return;
static int performOperation(ArchiveOperation Operation) {
// Create or open the archive object.
std::unique_ptr<MemoryBuffer> Buf;
- error_code EC = MemoryBuffer::getFile(ArchiveName, Buf, -1, false);
+ std::error_code EC = MemoryBuffer::getFile(ArchiveName, Buf, -1, false);
if (EC && EC != std::errc::no_such_file_or_directory) {
errs() << ToolName << ": error opening '" << ArchiveName
<< "': " << EC.message() << "!\n";
#include <map>
#include <system_error>
using namespace llvm;
-using std::error_code;
static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
// Read the input file.
std::unique_ptr<MemoryBuffer> MemBuf;
- if (error_code ec =
- MemoryBuffer::getFileOrSTDIN(InputFilename, MemBuf))
+ if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, MemBuf))
return Error("Error reading '" + InputFilename + "': " + ec.message());
if (MemBuf->getBufferSize() & 3)
#include "llvm/Support/Signals.h"
#include <system_error>
using namespace llvm;
-using std::error_code;
static cl::opt<std::string> SourceFile(cl::Positional, cl::Required,
cl::desc("SOURCEFILE"));
GCOVFile GF;
std::unique_ptr<MemoryBuffer> GCNO_Buff;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
+ if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
errs() << InputGCNO << ": " << ec.message() << "\n";
return 1;
}
}
std::unique_ptr<MemoryBuffer> GCDA_Buff;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
+ if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
if (ec != std::errc::no_such_file_or_directory) {
errs() << InputGCDA << ": " << ec.message() << "\n";
return 1;
#include "llvm/Support/ToolOutputFile.h"
#include <system_error>
using namespace llvm;
-using std::error_code;
static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
&ErrorMessage));
if(M.get()) {
- if (error_code EC = M->materializeAllPermanently()) {
+ if (std::error_code EC = M->materializeAllPermanently()) {
ErrorMessage = EC.message();
M.reset();
}
using namespace llvm;
using namespace object;
-using std::error_code;
static cl::list<std::string>
InputFilenames(cl::Positional, cl::desc("<input object files>"),
static void DumpInput(const StringRef &Filename) {
std::unique_ptr<MemoryBuffer> Buff;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
+ if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
errs() << Filename << ": " << ec.message() << "\n";
return;
}
ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(Buff.release()));
- if (error_code EC = ObjOrErr.getError()) {
+ if (std::error_code EC = ObjOrErr.getError()) {
errs() << Filename << ": " << EC.message() << '\n';
return;
}
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
using namespace llvm;
-using std::error_code;
static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
return 1;
std::unique_ptr<MemoryBuffer> BufferPtr;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, BufferPtr)) {
+ if (std::error_code ec =
+ MemoryBuffer::getFileOrSTDIN(InputFilename, BufferPtr)) {
errs() << ProgName << ": " << ec.message() << '\n';
return 1;
}
#include "llvm/Support/raw_ostream.h"
#include <system_error>
using namespace llvm;
-using std::error_code;
static cl::list<std::string>
InputFilenames(cl::Positional, cl::desc("<input files>"),
static void parseMCMarkup(StringRef Filename) {
std::unique_ptr<MemoryBuffer> BufferPtr;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, BufferPtr)) {
+ if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, BufferPtr)) {
errs() << ToolName << ": " << ec.message() << '\n';
return;
}
#include <vector>
using namespace llvm;
using namespace object;
-using std::error_code;
namespace {
enum OutputFormatTy { bsd, sysv, posix, darwin };
errs() << ToolName << ": " << Path << ": " << Message << ".\n";
}
-static bool error(error_code EC, Twine Path = Twine()) {
+static bool error(std::error_code EC, Twine Path = Twine()) {
if (EC) {
error(EC.message(), Path);
return true;
using namespace llvm;
using namespace object;
using namespace llvm::Win64EH;
-using std::error_code;
// Returns the name of the unwind code.
static StringRef getUnwindCodeTypeName(uint8_t Code) {
}
// Given a symbol sym this functions returns the address and section of it.
-static error_code resolveSectionAndAddress(const COFFObjectFile *Obj,
- const SymbolRef &Sym,
- const coff_section *&ResolvedSection,
- uint64_t &ResolvedAddr) {
- if (error_code EC = Sym.getAddress(ResolvedAddr))
+static std::error_code
+resolveSectionAndAddress(const COFFObjectFile *Obj, const SymbolRef &Sym,
+ const coff_section *&ResolvedSection,
+ uint64_t &ResolvedAddr) {
+ if (std::error_code EC = Sym.getAddress(ResolvedAddr))
return EC;
section_iterator iter(Obj->section_begin());
- if (error_code EC = Sym.getSection(iter))
+ if (std::error_code EC = Sym.getSection(iter))
return EC;
ResolvedSection = Obj->getCOFFSection(*iter);
return object_error::success;
// Given a vector of relocations for a section and an offset into this section
// the function returns the symbol used for the relocation at the offset.
-static error_code resolveSymbol(const std::vector<RelocationRef> &Rels,
- uint64_t Offset, SymbolRef &Sym) {
+static std::error_code resolveSymbol(const std::vector<RelocationRef> &Rels,
+ uint64_t Offset, SymbolRef &Sym) {
for (std::vector<RelocationRef>::const_iterator I = Rels.begin(),
E = Rels.end();
I != E; ++I) {
uint64_t Ofs;
- if (error_code EC = I->getOffset(Ofs))
+ if (std::error_code EC = I->getOffset(Ofs))
return EC;
if (Ofs == Offset) {
Sym = *I->getSymbol();
// the function resolves the symbol used for the relocation at the offset and
// returns the section content and the address inside the content pointed to
// by the symbol.
-static error_code getSectionContents(const COFFObjectFile *Obj,
- const std::vector<RelocationRef> &Rels,
- uint64_t Offset,
- ArrayRef<uint8_t> &Contents,
- uint64_t &Addr) {
+static std::error_code
+getSectionContents(const COFFObjectFile *Obj,
+ const std::vector<RelocationRef> &Rels, uint64_t Offset,
+ ArrayRef<uint8_t> &Contents, uint64_t &Addr) {
SymbolRef Sym;
- if (error_code EC = resolveSymbol(Rels, Offset, Sym))
+ if (std::error_code EC = resolveSymbol(Rels, Offset, Sym))
return EC;
const coff_section *Section;
- if (error_code EC = resolveSectionAndAddress(Obj, Sym, Section, Addr))
+ if (std::error_code EC = resolveSectionAndAddress(Obj, Sym, Section, Addr))
return EC;
- if (error_code EC = Obj->getSectionContents(Section, Contents))
+ if (std::error_code EC = Obj->getSectionContents(Section, Contents))
return EC;
return object_error::success;
}
// Given a vector of relocations for a section and an offset into this section
// the function returns the name of the symbol used for the relocation at the
// offset.
-static error_code resolveSymbolName(const std::vector<RelocationRef> &Rels,
- uint64_t Offset, StringRef &Name) {
+static std::error_code resolveSymbolName(const std::vector<RelocationRef> &Rels,
+ uint64_t Offset, StringRef &Name) {
SymbolRef Sym;
- if (error_code EC = resolveSymbol(Rels, Offset, Sym))
+ if (std::error_code EC = resolveSymbol(Rels, Offset, Sym))
return EC;
- if (error_code EC = Sym.getName(Name))
+ if (std::error_code EC = Sym.getName(Name))
return EC;
return object_error::success;
}
#include <system_error>
using namespace llvm;
using namespace object;
-using std::error_code;
static cl::opt<bool>
UseDbg("g", cl::desc("Print line information from debug info if available"));
void llvm::DisassembleInputMachO(StringRef Filename) {
std::unique_ptr<MemoryBuffer> Buff;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
+ if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
errs() << "llvm-objdump: " << Filename << ": " << ec.message() << "\n";
return;
}
// get the sections and supply it to the section name parsing machinery.
if (!DSYMFile.empty()) {
std::unique_ptr<MemoryBuffer> Buf;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(DSYMFile, Buf)) {
+ if (std::error_code ec = MemoryBuffer::getFileOrSTDIN(DSYMFile, Buf)) {
errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n';
return;
}
using namespace llvm;
using namespace object;
-using std::error_code;
static cl::list<std::string>
InputFilenames(cl::Positional, cl::desc("<input object files>"),cl::ZeroOrMore);
static StringRef ToolName;
-bool llvm::error(error_code EC) {
+bool llvm::error(std::error_code EC) {
if (!EC)
return false;
// Create a mapping, RelocSecs = SectionRelocMap[S], where sections
// in RelocSecs contain the relocations for section S.
- error_code EC;
+ std::error_code EC;
std::map<SectionRef, SmallVector<SectionRef, 1>> SectionRelocMap;
for (const SectionRef &Section : Obj->sections()) {
section_iterator Sec2 = Section.getRelocatedSection();
}
static void PrintSectionContents(const ObjectFile *Obj) {
- error_code EC;
+ std::error_code EC;
for (const SectionRef &Section : Obj->sections()) {
StringRef Name;
StringRef Contents;
for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
++i) {
std::unique_ptr<Binary> child;
- if (error_code EC = i->getAsBinary(child)) {
+ if (std::error_code EC = i->getAsBinary(child)) {
// Ignore non-object files.
if (EC != object_error::invalid_file_type)
errs() << ToolName << ": '" << a->getFileName() << "': " << EC.message()
// Attempt to open the binary.
ErrorOr<Binary *> BinaryOrErr = createBinary(file);
- if (error_code EC = BinaryOrErr.getError()) {
+ if (std::error_code EC = BinaryOrErr.getError()) {
errs() << ToolName << ": '" << file << "': " << EC.message() << ".\n";
return;
}
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
-using std::error_code;
static void exitWithError(const Twine &Message, StringRef Whence = "") {
errs() << "error: ";
InstrProfWriter Writer;
for (const auto &Filename : Inputs) {
std::unique_ptr<InstrProfReader> Reader;
- if (error_code ec = InstrProfReader::create(Filename, Reader))
+ if (std::error_code ec = InstrProfReader::create(Filename, Reader))
exitWithError(ec.message(), Filename);
for (const auto &I : *Reader)
- if (error_code EC = Writer.addFunctionCounts(I.Name, I.Hash, I.Counts))
+ if (std::error_code EC =
+ Writer.addFunctionCounts(I.Name, I.Hash, I.Counts))
errs() << Filename << ": " << I.Name << ": " << EC.message() << "\n";
if (Reader->hasError())
exitWithError(Reader->getError().message(), Filename);
cl::ParseCommandLineOptions(argc, argv, "LLVM profile data summary\n");
std::unique_ptr<InstrProfReader> Reader;
- if (error_code EC = InstrProfReader::create(Filename, Reader))
+ if (std::error_code EC = InstrProfReader::create(Filename, Reader))
exitWithError(EC.message(), Filename);
if (OutputFilename.empty())
using namespace llvm;
using namespace llvm::object;
using namespace llvm::Win64EH;
-using std::error_code;
namespace {
void cacheRelocations();
- error_code resolveSymbol(const coff_section *Section, uint64_t Offset,
- SymbolRef &Sym);
- error_code resolveSymbolName(const coff_section *Section, uint64_t Offset,
- StringRef &Name);
+ std::error_code resolveSymbol(const coff_section *Section, uint64_t Offset,
+ SymbolRef &Sym);
+ std::error_code resolveSymbolName(const coff_section *Section,
+ uint64_t Offset, StringRef &Name);
typedef DenseMap<const coff_section*, std::vector<RelocationRef> > RelocMapTy;
namespace llvm {
-error_code createCOFFDumper(const object::ObjectFile *Obj, StreamWriter &Writer,
- std::unique_ptr<ObjDumper> &Result) {
+std::error_code createCOFFDumper(const object::ObjectFile *Obj,
+ StreamWriter &Writer,
+ std::unique_ptr<ObjDumper> &Result) {
const COFFObjectFile *COFFObj = dyn_cast<COFFObjectFile>(Obj);
if (!COFFObj)
return readobj_error::unsupported_obj_file_format;
// Given a a section and an offset into this section the function returns the
// symbol used for the relocation at the offset.
-error_code COFFDumper::resolveSymbol(const coff_section *Section,
- uint64_t Offset, SymbolRef &Sym) {
+std::error_code COFFDumper::resolveSymbol(const coff_section *Section,
+ uint64_t Offset, SymbolRef &Sym) {
const auto &Relocations = RelocMap[Section];
for (const auto &Relocation : Relocations) {
uint64_t RelocationOffset;
- if (error_code EC = Relocation.getOffset(RelocationOffset))
+ if (std::error_code EC = Relocation.getOffset(RelocationOffset))
return EC;
if (RelocationOffset == Offset) {
// Given a section and an offset into this section the function returns the name
// of the symbol used for the relocation at the offset.
-error_code COFFDumper::resolveSymbolName(const coff_section *Section,
- uint64_t Offset, StringRef &Name) {
+std::error_code COFFDumper::resolveSymbolName(const coff_section *Section,
+ uint64_t Offset,
+ StringRef &Name) {
SymbolRef Symbol;
- if (error_code EC = resolveSymbol(Section, Offset, Symbol))
+ if (std::error_code EC = resolveSymbol(Section, Offset, Symbol))
return EC;
- if (error_code EC = Symbol.getName(Name))
+ if (std::error_code EC = Symbol.getName(Name))
return EC;
return object_error::success;
}
{ "Alias" , COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS }
};
-template<typename T>
-static error_code getSymbolAuxData(const COFFObjectFile *Obj,
- const coff_symbol *Symbol, const T* &Aux) {
+template <typename T>
+static std::error_code getSymbolAuxData(const COFFObjectFile *Obj,
+ const coff_symbol *Symbol,
+ const T *&Aux) {
ArrayRef<uint8_t> AuxData = Obj->getSymbolAuxData(Symbol);
Aux = reinterpret_cast<const T*>(AuxData.data());
return readobj_error::success;
const coff_symbol *Symbol = Obj->getCOFFSymbol(Sym);
const coff_section *Section;
- if (error_code EC = Obj->getSection(Symbol->SectionNumber, Section)) {
+ if (std::error_code EC = Obj->getSection(Symbol->SectionNumber, Section)) {
W.startLine() << "Invalid section number: " << EC.message() << "\n";
W.flush();
return;
const coff_symbol *Linked;
StringRef LinkedName;
- error_code EC;
+ std::error_code EC;
if ((EC = Obj->getSymbol(Aux->TagIndex, Linked)) ||
(EC = Obj->getSymbolName(Linked, LinkedName))) {
LinkedName = "";
&& Aux->Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE) {
const coff_section *Assoc;
StringRef AssocName;
- error_code EC;
+ std::error_code EC;
if ((EC = Obj->getSection(Aux->Number, Assoc)) ||
(EC = Obj->getSectionName(Assoc, AssocName))) {
AssocName = "";
const coff_symbol *ReferredSym;
StringRef ReferredName;
- error_code EC;
+ std::error_code EC;
if ((EC = Obj->getSymbol(Aux->SymbolTableIndex, ReferredSym)) ||
(EC = Obj->getSymbolName(ReferredSym, ReferredName))) {
ReferredName = "";
switch (Header->Machine) {
case COFF::IMAGE_FILE_MACHINE_AMD64: {
Win64EH::Dumper Dumper(W);
- Win64EH::Dumper::SymbolResolver Resolver =
- [](const object::coff_section *Section, uint64_t Offset,
- SymbolRef &Symbol, void *user_data) -> error_code {
- COFFDumper *Dumper = reinterpret_cast<COFFDumper*>(user_data);
- return Dumper->resolveSymbol(Section, Offset, Symbol);
- };
+ Win64EH::Dumper::SymbolResolver
+ Resolver = [](const object::coff_section *Section, uint64_t Offset,
+ SymbolRef &Symbol, void *user_data) -> std::error_code {
+ COFFDumper *Dumper = reinterpret_cast<COFFDumper *>(user_data);
+ return Dumper->resolveSymbol(Section, Offset, Symbol);
+ };
Win64EH::Dumper::Context Ctx(*Obj, Resolver, this);
Dumper.printData(Ctx);
break;
using namespace llvm;
using namespace llvm::object;
using namespace ELF;
-using std::error_code;
#define LLVM_READOBJ_ENUM_CASE(ns, enum) \
case ns::enum: return #enum;
namespace llvm {
template <class ELFT>
-static error_code createELFDumper(const ELFFile<ELFT> *Obj,
- StreamWriter &Writer,
- std::unique_ptr<ObjDumper> &Result) {
+static std::error_code createELFDumper(const ELFFile<ELFT> *Obj,
+ StreamWriter &Writer,
+ std::unique_ptr<ObjDumper> &Result) {
Result.reset(new ELFDumper<ELFT>(Obj, Writer));
return readobj_error::success;
}
-error_code createELFDumper(const object::ObjectFile *Obj, StreamWriter &Writer,
- std::unique_ptr<ObjDumper> &Result) {
+std::error_code createELFDumper(const object::ObjectFile *Obj,
+ StreamWriter &Writer,
+ std::unique_ptr<ObjDumper> &Result) {
// Little-endian 32-bit
if (const ELF32LEObjectFile *ELFObj = dyn_cast<ELF32LEObjectFile>(Obj))
return createELFDumper(ELFObj->getELFFile(), Writer, Result);
using namespace llvm;
using namespace object;
-using std::error_code;
namespace {
namespace llvm {
-error_code createMachODumper(const object::ObjectFile *Obj,
- StreamWriter &Writer,
- std::unique_ptr<ObjDumper> &Result) {
+std::error_code createMachODumper(const object::ObjectFile *Obj,
+ StreamWriter &Writer,
+ std::unique_ptr<ObjDumper> &Result) {
const MachOObjectFile *MachOObj = dyn_cast<MachOObjectFile>(Obj);
if (!MachOObj)
return readobj_error::unsupported_obj_file_format;
void MachODumper::printRelocations() {
ListScope D(W, "Relocations");
- error_code EC;
+ std::error_code EC;
for (const SectionRef &Section : Obj->sections()) {
StringRef Name;
if (error(Section.getName(Name)))
using namespace llvm;
using namespace llvm::object;
using namespace llvm::Win64EH;
-using std::error_code;
static const EnumEntry<unsigned> UnwindFlags[] = {
{ "ExceptionHandler", UNW_ExceptionHandler },
return OS.str();
}
-static error_code resolveRelocation(const Dumper::Context &Ctx,
- const coff_section *Section,
- uint64_t Offset,
- const coff_section *&ResolvedSection,
- uint64_t &ResolvedAddress) {
+static std::error_code resolveRelocation(const Dumper::Context &Ctx,
+ const coff_section *Section,
+ uint64_t Offset,
+ const coff_section *&ResolvedSection,
+ uint64_t &ResolvedAddress) {
SymbolRef Symbol;
- if (error_code EC = Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData))
+ if (std::error_code EC =
+ Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData))
return EC;
- if (error_code EC = Symbol.getAddress(ResolvedAddress))
+ if (std::error_code EC = Symbol.getAddress(ResolvedAddress))
return EC;
section_iterator SI = Ctx.COFF.section_begin();
- if (error_code EC = Symbol.getSection(SI))
+ if (std::error_code EC = Symbol.getSection(SI))
return EC;
ResolvedSection = Ctx.COFF.getCOFFSection(*SI);
using namespace llvm;
using namespace llvm::object;
-using std::error_code;
namespace opts {
cl::list<std::string> InputFilenames(cl::Positional,
namespace llvm {
-bool error(error_code EC) {
+bool error(std::error_code EC) {
if (!EC)
return false;
} // namespace llvm
-
-static void reportError(StringRef Input, error_code EC) {
+static void reportError(StringRef Input, std::error_code EC) {
if (Input == "-")
Input = "<stdin>";
}
/// @brief Creates an format-specific object file dumper.
-static error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
- std::unique_ptr<ObjDumper> &Result) {
+static std::error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
+ std::unique_ptr<ObjDumper> &Result) {
if (!Obj)
return readobj_error::unsupported_file_format;
static void dumpObject(const ObjectFile *Obj) {
StreamWriter Writer(outs());
std::unique_ptr<ObjDumper> Dumper;
- if (error_code EC = createDumper(Obj, Writer, Dumper)) {
+ if (std::error_code EC = createDumper(Obj, Writer, Dumper)) {
reportError(Obj->getFileName(), EC);
return;
}
ArcE = Arc->child_end();
ArcI != ArcE; ++ArcI) {
std::unique_ptr<Binary> child;
- if (error_code EC = ArcI->getAsBinary(child)) {
+ if (std::error_code EC = ArcI->getAsBinary(child)) {
// Ignore non-object files.
if (EC != object_error::invalid_file_type)
reportError(Arc->getFileName(), EC.message());
// Attempt to open the binary.
ErrorOr<Binary *> BinaryOrErr = createBinary(File);
- if (error_code EC = BinaryOrErr.getError()) {
+ if (std::error_code EC = BinaryOrErr.getError()) {
reportError(File, EC);
return;
}
#include <system_error>
using namespace llvm;
using namespace llvm::object;
-using std::error_code;
static cl::list<std::string>
InputFileList(cl::Positional, cl::ZeroOrMore,
// Load the input memory buffer.
std::unique_ptr<MemoryBuffer> InputBuffer;
std::unique_ptr<ObjectImage> LoadedObject;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFileList[i],
- InputBuffer))
+ if (std::error_code ec =
+ MemoryBuffer::getFileOrSTDIN(InputFileList[i], InputBuffer))
return Error("unable to read input: '" + ec.message() + "'");
// Load the object file
// Load the input memory buffer.
std::unique_ptr<MemoryBuffer> InputBuffer;
std::unique_ptr<ObjectImage> LoadedObject;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFileList[i],
- InputBuffer))
+ if (std::error_code ec =
+ MemoryBuffer::getFileOrSTDIN(InputFileList[i], InputBuffer))
return Error("unable to read input: '" + ec.message() + "'");
// Load the object file
#include <system_error>
using namespace llvm;
using namespace object;
-using std::error_code;
enum OutputFormatTy {berkeley, sysv};
static cl::opt<OutputFormatTy>
static std::string ToolName;
/// @brief If ec is not success, print the error and return true.
-static bool error(error_code ec) {
+static bool error(std::error_code ec) {
if (!ec) return false;
outs() << ToolName << ": error reading file: " << ec.message() << ".\n";
// Attempt to open the binary.
ErrorOr<Binary *> BinaryOrErr = createBinary(file);
- if (error_code EC = BinaryOrErr.getError()) {
+ if (std::error_code EC = BinaryOrErr.getError()) {
errs() << ToolName << ": " << file << ": " << EC.message() << ".\n";
return;
}
for (object::Archive::child_iterator i = a->child_begin(),
e = a->child_end(); i != e; ++i) {
std::unique_ptr<Binary> child;
- if (error_code ec = i->getAsBinary(child)) {
+ if (std::error_code ec = i->getAsBinary(child)) {
errs() << ToolName << ": " << file << ": " << ec.message() << ".\n";
continue;
}
#include <stdlib.h>
namespace llvm {
-using std::error_code;
namespace symbolize {
-static bool error(error_code ec) {
+static bool error(std::error_code ec) {
if (!ec)
return false;
errs() << "LLVMSymbolizer: error reading file: " << ec.message() << ".\n";
const std::string &ResourcePath =
getDarwinDWARFResourceForPath(Path);
BinaryOrErr = createBinary(ResourcePath);
- error_code EC = BinaryOrErr.getError();
+ std::error_code EC = BinaryOrErr.getError();
if (EC != std::errc::no_such_file_or_directory && !error(EC)) {
DbgBin = BinaryOrErr.get();
ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
using namespace llvm;
using namespace symbolize;
-using std::error_code;
static cl::opt<bool>
ClUseSymbolTable("use-symbol-table", cl::init(true),
#include <system_error>
using namespace llvm;
using namespace llvm::object;
-using std::error_code;
static cl::opt<std::string>
InputFile(cl::Positional, cl::desc("<input file>"), cl::init("-"));
cl::ParseCommandLineOptions(argc, argv, "llvm Mach-O dumping tool\n");
ErrorOr<Binary *> BinaryOrErr = createBinary(InputFile);
- if (error_code EC = BinaryOrErr.getError())
+ if (std::error_code EC = BinaryOrErr.getError())
return Error("unable to read input: '" + EC.message() + "'");
std::unique_ptr<Binary> Binary(BinaryOrErr.get());
#include "llvm/Support/YAMLTraits.h"
using namespace llvm;
-using std::error_code;
namespace {
}
-static void check(error_code ec) {
+static void check(std::error_code ec) {
if (ec)
report_fatal_error(ec.message());
}
return YAMLObj;
}
-error_code coff2yaml(raw_ostream &Out, const object::COFFObjectFile &Obj) {
+std::error_code coff2yaml(raw_ostream &Out, const object::COFFObjectFile &Obj) {
COFFDumper Dumper(Obj);
yaml::Output Yout(Out);
#include "llvm/Support/YAMLTraits.h"
using namespace llvm;
-using std::error_code;
namespace {
const object::ELFFile<ELFT> &Obj;
- error_code dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S);
- error_code dumpCommonSection(const Elf_Shdr *Shdr, ELFYAML::Section &S);
- error_code dumpCommonRelocationSection(const Elf_Shdr *Shdr,
- ELFYAML::RelocationSection &S);
+ std::error_code dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S);
+ std::error_code dumpCommonSection(const Elf_Shdr *Shdr, ELFYAML::Section &S);
+ std::error_code dumpCommonRelocationSection(const Elf_Shdr *Shdr,
+ ELFYAML::RelocationSection &S);
template <class RelT>
- error_code dumpRelocation(const Elf_Shdr *Shdr, const RelT *Rel,
- ELFYAML::Relocation &R);
+ std::error_code dumpRelocation(const Elf_Shdr *Shdr, const RelT *Rel,
+ ELFYAML::Relocation &R);
ErrorOr<ELFYAML::RelocationSection *> dumpRelSection(const Elf_Shdr *Shdr);
ErrorOr<ELFYAML::RelocationSection *> dumpRelaSection(const Elf_Shdr *Shdr);
break;
case ELF::SHT_RELA: {
ErrorOr<ELFYAML::RelocationSection *> S = dumpRelaSection(&Sec);
- if (error_code EC = S.getError())
+ if (std::error_code EC = S.getError())
return EC;
Y->Sections.push_back(std::unique_ptr<ELFYAML::Section>(S.get()));
break;
}
case ELF::SHT_REL: {
ErrorOr<ELFYAML::RelocationSection *> S = dumpRelSection(&Sec);
- if (error_code EC = S.getError())
+ if (std::error_code EC = S.getError())
return EC;
Y->Sections.push_back(std::unique_ptr<ELFYAML::Section>(S.get()));
break;
// FIXME: Support SHT_GROUP section format.
default: {
ErrorOr<ELFYAML::RawContentSection *> S = dumpContentSection(&Sec);
- if (error_code EC = S.getError())
+ if (std::error_code EC = S.getError())
return EC;
Y->Sections.push_back(std::unique_ptr<ELFYAML::Section>(S.get()));
}
}
ELFYAML::Symbol S;
- if (error_code EC = ELFDumper<ELFT>::dumpSymbol(SI, S))
+ if (std::error_code EC = ELFDumper<ELFT>::dumpSymbol(SI, S))
return EC;
switch (SI->getBinding())
}
template <class ELFT>
-error_code ELFDumper<ELFT>::dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S) {
+std::error_code ELFDumper<ELFT>::dumpSymbol(Elf_Sym_Iter Sym,
+ ELFYAML::Symbol &S) {
S.Type = Sym->getType();
S.Value = Sym->st_value;
S.Size = Sym->st_size;
S.Visibility = Sym->st_other & 0x3;
ErrorOr<StringRef> NameOrErr = Obj.getSymbolName(Sym);
- if (error_code EC = NameOrErr.getError())
+ if (std::error_code EC = NameOrErr.getError())
return EC;
S.Name = NameOrErr.get();
return obj2yaml_error::success;
NameOrErr = Obj.getSectionName(Shdr);
- if (error_code EC = NameOrErr.getError())
+ if (std::error_code EC = NameOrErr.getError())
return EC;
S.Section = NameOrErr.get();
template <class ELFT>
template <class RelT>
-error_code ELFDumper<ELFT>::dumpRelocation(const Elf_Shdr *Shdr,
- const RelT *Rel,
- ELFYAML::Relocation &R) {
+std::error_code ELFDumper<ELFT>::dumpRelocation(const Elf_Shdr *Shdr,
+ const RelT *Rel,
+ ELFYAML::Relocation &R) {
R.Type = Rel->getType(Obj.isMips64EL());
R.Offset = Rel->r_offset;
R.Addend = 0;
ErrorOr<StringRef> NameOrErr =
Obj.getSymbolName(NamePair.first, NamePair.second);
- if (error_code EC = NameOrErr.getError())
+ if (std::error_code EC = NameOrErr.getError())
return EC;
R.Symbol = NameOrErr.get();
}
template <class ELFT>
-error_code ELFDumper<ELFT>::dumpCommonSection(const Elf_Shdr *Shdr,
- ELFYAML::Section &S) {
+std::error_code ELFDumper<ELFT>::dumpCommonSection(const Elf_Shdr *Shdr,
+ ELFYAML::Section &S) {
S.Type = Shdr->sh_type;
S.Flags = Shdr->sh_flags;
S.Address = Shdr->sh_addr;
S.AddressAlign = Shdr->sh_addralign;
ErrorOr<StringRef> NameOrErr = Obj.getSectionName(Shdr);
- if (error_code EC = NameOrErr.getError())
+ if (std::error_code EC = NameOrErr.getError())
return EC;
S.Name = NameOrErr.get();
if (Shdr->sh_link != ELF::SHN_UNDEF) {
if (const Elf_Shdr *LinkSection = Obj.getSection(Shdr->sh_link)) {
NameOrErr = Obj.getSectionName(LinkSection);
- if (error_code EC = NameOrErr.getError())
+ if (std::error_code EC = NameOrErr.getError())
return EC;
S.Link = NameOrErr.get();
}
}
template <class ELFT>
-error_code
+std::error_code
ELFDumper<ELFT>::dumpCommonRelocationSection(const Elf_Shdr *Shdr,
ELFYAML::RelocationSection &S) {
- if (error_code EC = dumpCommonSection(Shdr, S))
+ if (std::error_code EC = dumpCommonSection(Shdr, S))
return EC;
if (const Elf_Shdr *InfoSection = Obj.getSection(Shdr->sh_info)) {
ErrorOr<StringRef> NameOrErr = Obj.getSectionName(InfoSection);
- if (error_code EC = NameOrErr.getError())
+ if (std::error_code EC = NameOrErr.getError())
return EC;
S.Info = NameOrErr.get();
}
assert(Shdr->sh_type == ELF::SHT_REL && "Section type is not SHT_REL");
auto S = make_unique<ELFYAML::RelocationSection>();
- if (error_code EC = dumpCommonRelocationSection(Shdr, *S))
+ if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S))
return EC;
for (auto RI = Obj.begin_rel(Shdr), RE = Obj.end_rel(Shdr); RI != RE;
++RI) {
ELFYAML::Relocation R;
- if (error_code EC = dumpRelocation(Shdr, &*RI, R))
+ if (std::error_code EC = dumpRelocation(Shdr, &*RI, R))
return EC;
S->Relocations.push_back(R);
}
assert(Shdr->sh_type == ELF::SHT_RELA && "Section type is not SHT_RELA");
auto S = make_unique<ELFYAML::RelocationSection>();
- if (error_code EC = dumpCommonRelocationSection(Shdr, *S))
+ if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S))
return EC;
for (auto RI = Obj.begin_rela(Shdr), RE = Obj.end_rela(Shdr); RI != RE;
++RI) {
ELFYAML::Relocation R;
- if (error_code EC = dumpRelocation(Shdr, &*RI, R))
+ if (std::error_code EC = dumpRelocation(Shdr, &*RI, R))
return EC;
R.Addend = RI->r_addend;
S->Relocations.push_back(R);
ELFDumper<ELFT>::dumpContentSection(const Elf_Shdr *Shdr) {
auto S = make_unique<ELFYAML::RawContentSection>();
- if (error_code EC = dumpCommonSection(Shdr, *S))
+ if (std::error_code EC = dumpCommonSection(Shdr, *S))
return EC;
ErrorOr<ArrayRef<uint8_t>> ContentOrErr = Obj.getSectionContents(Shdr);
- if (error_code EC = ContentOrErr.getError())
+ if (std::error_code EC = ContentOrErr.getError())
return EC;
S->Content = object::yaml::BinaryRef(ContentOrErr.get());
S->Size = S->Content.binary_size();
}
template <class ELFT>
-static error_code elf2yaml(raw_ostream &Out, const object::ELFFile<ELFT> &Obj) {
+static std::error_code elf2yaml(raw_ostream &Out,
+ const object::ELFFile<ELFT> &Obj) {
ELFDumper<ELFT> Dumper(Obj);
ErrorOr<ELFYAML::Object *> YAMLOrErr = Dumper.dump();
- if (error_code EC = YAMLOrErr.getError())
+ if (std::error_code EC = YAMLOrErr.getError())
return EC;
std::unique_ptr<ELFYAML::Object> YAML(YAMLOrErr.get());
return object::object_error::success;
}
-error_code elf2yaml(raw_ostream &Out, const object::ObjectFile &Obj) {
+std::error_code elf2yaml(raw_ostream &Out, const object::ObjectFile &Obj) {
if (const auto *ELFObj = dyn_cast<object::ELF32LEObjectFile>(&Obj))
return elf2yaml(Out, *ELFObj->getELFFile());
using namespace llvm;
using namespace llvm::object;
-using std::error_code;
-static error_code dumpObject(const ObjectFile &Obj) {
+static std::error_code dumpObject(const ObjectFile &Obj) {
if (Obj.isCOFF())
return coff2yaml(outs(), cast<COFFObjectFile>(Obj));
if (Obj.isELF())
return obj2yaml_error::unsupported_obj_file_format;
}
-static error_code dumpInput(StringRef File) {
+static std::error_code dumpInput(StringRef File) {
if (File != "-" && !sys::fs::exists(File))
return obj2yaml_error::file_not_found;
ErrorOr<Binary *> BinaryOrErr = createBinary(File);
- if (error_code EC = BinaryOrErr.getError())
+ if (std::error_code EC = BinaryOrErr.getError())
return EC;
std::unique_ptr<Binary> Binary(BinaryOrErr.get());
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
- if (error_code EC = dumpInput(InputFilename)) {
+ if (std::error_code EC = dumpInput(InputFilename)) {
errs() << "Error: '" << EC.message() << "'\n";
return 1;
}