mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Remove 'using std::error_code' from tools.
llvm-svn: 210876
This commit is contained in:
parent
251ce700f0
commit
5c15b3d369
@ -22,7 +22,6 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
namespace {
|
||||
// OutputType - Allow the user to specify the way code should be run, to test
|
||||
@ -268,7 +267,7 @@ void BugDriver::compileProgram(Module *M, std::string *Error) const {
|
||||
// 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()
|
||||
@ -306,7 +305,7 @@ std::string BugDriver::executeProgram(const Module *Program,
|
||||
// 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: "
|
||||
@ -332,7 +331,7 @@ std::string BugDriver::executeProgram(const Module *Program,
|
||||
|
||||
// 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";
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "llvm/Transforms/Utils/CodeExtractor.h"
|
||||
#include <set>
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
#define DEBUG_TYPE "bugpoint"
|
||||
|
||||
@ -367,7 +366,7 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
|
||||
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";
|
||||
|
@ -27,7 +27,6 @@
|
||||
#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;
|
||||
@ -965,8 +964,8 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe,
|
||||
|
||||
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";
|
||||
@ -1059,8 +1058,8 @@ bool BugDriver::debugCodeGenerator(std::string *Error) {
|
||||
|
||||
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";
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
#define DEBUG_TYPE "bugpoint"
|
||||
|
||||
@ -130,7 +129,7 @@ bool BugDriver::runPasses(Module *Program,
|
||||
// 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: "
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
#define DEBUG_TYPE "toolrunner"
|
||||
|
||||
@ -143,7 +142,7 @@ static std::string ProcessFailure(StringRef ProgPath, const char** Args,
|
||||
// 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";
|
||||
@ -479,7 +478,7 @@ GCC::FileType LLC::OutputCode(const std::string &Bitcode,
|
||||
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";
|
||||
@ -716,7 +715,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile,
|
||||
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";
|
||||
@ -826,7 +825,7 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
|
||||
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";
|
||||
|
@ -44,7 +44,6 @@
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
namespace {
|
||||
ld_plugin_status discard_message(int level, const char *format, ...) {
|
||||
@ -259,7 +258,7 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
|
||||
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;
|
||||
@ -485,7 +484,7 @@ static ld_plugin_status all_symbols_read_hook(void) {
|
||||
|
||||
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());
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "llvm/Support/Format.h"
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
#define DEBUG_TYPE "lli"
|
||||
|
||||
@ -62,7 +61,7 @@ allocateDataSection(uintptr_t Size, unsigned Alignment,
|
||||
}
|
||||
|
||||
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 |
|
||||
|
@ -62,7 +62,6 @@
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
#define DEBUG_TYPE "lli"
|
||||
|
||||
@ -416,7 +415,7 @@ int main(int argc, char **argv, char * const *envp) {
|
||||
|
||||
// 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);
|
||||
@ -540,7 +539,7 @@ int main(int argc, char **argv, char * const *envp) {
|
||||
|
||||
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());
|
||||
|
@ -36,7 +36,6 @@
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
// The name this program was invoked as.
|
||||
static StringRef ToolName;
|
||||
@ -54,7 +53,7 @@ LLVM_ATTRIBUTE_NORETURN static void fail(Twine Error) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void failIfError(error_code EC, Twine Context = "") {
|
||||
static void failIfError(std::error_code EC, Twine Context = "") {
|
||||
if (!EC)
|
||||
return;
|
||||
|
||||
@ -939,7 +938,7 @@ int ar_main(char **argv) {
|
||||
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";
|
||||
|
@ -43,7 +43,6 @@
|
||||
#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("-"));
|
||||
@ -481,8 +480,7 @@ static int AnalyzeBitcode() {
|
||||
// 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)
|
||||
|
@ -22,7 +22,6 @@
|
||||
#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"));
|
||||
@ -105,7 +104,7 @@ int main(int argc, char **argv) {
|
||||
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;
|
||||
}
|
||||
@ -116,7 +115,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -34,7 +34,6 @@
|
||||
#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("-"));
|
||||
@ -138,7 +137,7 @@ int main(int argc, char **argv) {
|
||||
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();
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
using namespace llvm;
|
||||
using namespace object;
|
||||
using std::error_code;
|
||||
|
||||
static cl::list<std::string>
|
||||
InputFilenames(cl::Positional, cl::desc("<input object files>"),
|
||||
@ -69,13 +68,13 @@ DumpType("debug-dump", cl::init(DIDT_All),
|
||||
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;
|
||||
}
|
||||
|
@ -40,7 +40,6 @@
|
||||
#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("-"));
|
||||
@ -368,7 +367,8 @@ int main(int argc, char **argv) {
|
||||
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;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
#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>"),
|
||||
@ -137,7 +136,7 @@ MarkupTag MarkupParser::parseTag() {
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include <vector>
|
||||
using namespace llvm;
|
||||
using namespace object;
|
||||
using std::error_code;
|
||||
|
||||
namespace {
|
||||
enum OutputFormatTy { bsd, sysv, posix, darwin };
|
||||
@ -133,7 +132,7 @@ static void error(Twine Message, Twine Path = Twine()) {
|
||||
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;
|
||||
|
@ -29,7 +29,6 @@
|
||||
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) {
|
||||
@ -158,14 +157,14 @@ static void printAllUnwindCodes(ArrayRef<UnwindCode> UCs) {
|
||||
}
|
||||
|
||||
// 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;
|
||||
@ -173,13 +172,13 @@ static error_code resolveSectionAndAddress(const COFFObjectFile *Obj,
|
||||
|
||||
// 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();
|
||||
@ -193,18 +192,17 @@ static error_code resolveSymbol(const std::vector<RelocationRef> &Rels,
|
||||
// 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;
|
||||
}
|
||||
@ -212,12 +210,12 @@ static error_code getSectionContents(const COFFObjectFile *Obj,
|
||||
// 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;
|
||||
}
|
||||
|
@ -42,7 +42,6 @@
|
||||
#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"));
|
||||
@ -198,7 +197,7 @@ static void DisassembleInputMachO2(StringRef Filename,
|
||||
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;
|
||||
}
|
||||
@ -290,7 +289,7 @@ static void DisassembleInputMachO2(StringRef Filename,
|
||||
// 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;
|
||||
}
|
||||
|
@ -64,7 +64,6 @@
|
||||
|
||||
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);
|
||||
@ -149,7 +148,7 @@ YAMLCFG("yaml-cfg",
|
||||
|
||||
static StringRef ToolName;
|
||||
|
||||
bool llvm::error(error_code EC) {
|
||||
bool llvm::error(std::error_code EC) {
|
||||
if (!EC)
|
||||
return false;
|
||||
|
||||
@ -396,7 +395,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
|
||||
// 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();
|
||||
@ -621,7 +620,7 @@ static void PrintSectionHeaders(const ObjectFile *Obj) {
|
||||
}
|
||||
|
||||
static void PrintSectionContents(const ObjectFile *Obj) {
|
||||
error_code EC;
|
||||
std::error_code EC;
|
||||
for (const SectionRef &Section : Obj->sections()) {
|
||||
StringRef Name;
|
||||
StringRef Contents;
|
||||
@ -852,7 +851,7 @@ static void DumpArchive(const Archive *a) {
|
||||
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()
|
||||
@ -882,7 +881,7 @@ static void DumpInput(StringRef file) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
static void exitWithError(const Twine &Message, StringRef Whence = "") {
|
||||
errs() << "error: ";
|
||||
@ -57,11 +56,12 @@ int merge_main(int argc, const char *argv[]) {
|
||||
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);
|
||||
@ -91,7 +91,7 @@ int show_main(int argc, const char *argv[]) {
|
||||
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())
|
||||
|
@ -38,7 +38,6 @@
|
||||
using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
using namespace llvm::Win64EH;
|
||||
using std::error_code;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -70,10 +69,10 @@ private:
|
||||
|
||||
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;
|
||||
|
||||
@ -86,8 +85,9 @@ private:
|
||||
|
||||
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;
|
||||
@ -100,12 +100,12 @@ error_code createCOFFDumper(const object::ObjectFile *Obj, StreamWriter &Writer,
|
||||
|
||||
// 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) {
|
||||
@ -118,12 +118,13 @@ error_code COFFDumper::resolveSymbol(const coff_section *Section,
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -308,9 +309,10 @@ WeakExternalCharacteristics[] = {
|
||||
{ "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;
|
||||
@ -720,7 +722,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
||||
|
||||
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;
|
||||
@ -764,7 +766,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
||||
|
||||
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 = "";
|
||||
@ -806,7 +808,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
||||
&& 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 = "";
|
||||
@ -822,7 +824,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) {
|
||||
|
||||
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 = "";
|
||||
@ -850,12 +852,12 @@ void COFFDumper::printUnwindInfo() {
|
||||
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;
|
||||
|
@ -30,7 +30,6 @@
|
||||
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;
|
||||
@ -82,15 +81,16 @@ template <class T> T errorOrDefault(ErrorOr<T> Val, T Default = T()) {
|
||||
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);
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
using namespace llvm;
|
||||
using namespace object;
|
||||
using std::error_code;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -55,9 +54,9 @@ private:
|
||||
|
||||
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;
|
||||
@ -278,7 +277,7 @@ void MachODumper::printSections(const MachOObjectFile *Obj) {
|
||||
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)))
|
||||
|
@ -16,7 +16,6 @@
|
||||
using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
using namespace llvm::Win64EH;
|
||||
using std::error_code;
|
||||
|
||||
static const EnumEntry<unsigned> UnwindFlags[] = {
|
||||
{ "ExceptionHandler", UNW_ExceptionHandler },
|
||||
@ -135,20 +134,21 @@ static std::string formatSymbol(const Dumper::Context &Ctx,
|
||||
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);
|
||||
|
@ -41,7 +41,6 @@
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
using std::error_code;
|
||||
|
||||
namespace opts {
|
||||
cl::list<std::string> InputFilenames(cl::Positional,
|
||||
@ -142,7 +141,7 @@ static int ReturnValue = EXIT_SUCCESS;
|
||||
|
||||
namespace llvm {
|
||||
|
||||
bool error(error_code EC) {
|
||||
bool error(std::error_code EC) {
|
||||
if (!EC)
|
||||
return false;
|
||||
|
||||
@ -161,8 +160,7 @@ bool relocAddressLess(RelocationRef a, RelocationRef b) {
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
|
||||
static void reportError(StringRef Input, error_code EC) {
|
||||
static void reportError(StringRef Input, std::error_code EC) {
|
||||
if (Input == "-")
|
||||
Input = "<stdin>";
|
||||
|
||||
@ -180,8 +178,8 @@ static void reportError(StringRef Input, StringRef Message) {
|
||||
}
|
||||
|
||||
/// @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;
|
||||
|
||||
@ -200,7 +198,7 @@ static error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
|
||||
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;
|
||||
}
|
||||
@ -245,7 +243,7 @@ static void dumpArchive(const Archive *Arc) {
|
||||
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());
|
||||
@ -270,7 +268,7 @@ static void dumpInput(StringRef File) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <system_error>
|
||||
using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
using std::error_code;
|
||||
|
||||
static cl::list<std::string>
|
||||
InputFileList(cl::Positional, cl::ZeroOrMore,
|
||||
@ -158,8 +157,8 @@ static int printLineInfoForInput() {
|
||||
// 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
|
||||
@ -219,8 +218,8 @@ static int executeInput() {
|
||||
// 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
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <system_error>
|
||||
using namespace llvm;
|
||||
using namespace object;
|
||||
using std::error_code;
|
||||
|
||||
enum OutputFormatTy {berkeley, sysv};
|
||||
static cl::opt<OutputFormatTy>
|
||||
@ -69,7 +68,7 @@ static cl::list<std::string>
|
||||
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";
|
||||
@ -236,7 +235,7 @@ static void PrintFileSectionSizes(StringRef file) {
|
||||
|
||||
// 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;
|
||||
}
|
||||
@ -247,7 +246,7 @@ static void PrintFileSectionSizes(StringRef file) {
|
||||
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;
|
||||
}
|
||||
|
@ -26,10 +26,9 @@
|
||||
#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";
|
||||
@ -311,7 +310,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
|
||||
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));
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
using namespace llvm;
|
||||
using namespace symbolize;
|
||||
using std::error_code;
|
||||
|
||||
static cl::opt<bool>
|
||||
ClUseSymbolTable("use-symbol-table", cl::init(true),
|
||||
|
@ -23,7 +23,6 @@
|
||||
#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("-"));
|
||||
@ -392,7 +391,7 @@ int main(int argc, char **argv) {
|
||||
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());
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -32,7 +31,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
static void check(error_code ec) {
|
||||
static void check(std::error_code ec) {
|
||||
if (ec)
|
||||
report_fatal_error(ec.message());
|
||||
}
|
||||
@ -211,7 +210,7 @@ COFFYAML::Object &COFFDumper::getYAMLObj() {
|
||||
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);
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
|
||||
using namespace llvm;
|
||||
using std::error_code;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -27,13 +26,13 @@ class ELFDumper {
|
||||
|
||||
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);
|
||||
@ -75,14 +74,14 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
|
||||
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;
|
||||
@ -90,7 +89,7 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
|
||||
// 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()));
|
||||
}
|
||||
@ -106,7 +105,7 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
|
||||
}
|
||||
|
||||
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())
|
||||
@ -129,14 +128,15 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@ -145,7 +145,7 @@ error_code ELFDumper<ELFT>::dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S) {
|
||||
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();
|
||||
|
||||
@ -154,9 +154,9 @@ error_code ELFDumper<ELFT>::dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S) {
|
||||
|
||||
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;
|
||||
@ -167,7 +167,7 @@ error_code ELFDumper<ELFT>::dumpRelocation(const Elf_Shdr *Shdr,
|
||||
|
||||
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();
|
||||
|
||||
@ -175,22 +175,22 @@ error_code ELFDumper<ELFT>::dumpRelocation(const Elf_Shdr *Shdr,
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@ -200,15 +200,15 @@ error_code ELFDumper<ELFT>::dumpCommonSection(const Elf_Shdr *Shdr,
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@ -222,13 +222,13 @@ ELFDumper<ELFT>::dumpRelSection(const Elf_Shdr *Shdr) {
|
||||
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);
|
||||
}
|
||||
@ -242,13 +242,13 @@ ELFDumper<ELFT>::dumpRelaSection(const Elf_Shdr *Shdr) {
|
||||
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);
|
||||
@ -262,11 +262,11 @@ ErrorOr<ELFYAML::RawContentSection *>
|
||||
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();
|
||||
@ -275,10 +275,11 @@ ELFDumper<ELFT>::dumpContentSection(const Elf_Shdr *Shdr) {
|
||||
}
|
||||
|
||||
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());
|
||||
@ -288,7 +289,7 @@ static error_code elf2yaml(raw_ostream &Out, const object::ELFFile<ELFT> &Obj) {
|
||||
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());
|
||||
|
||||
|
@ -18,9 +18,8 @@
|
||||
|
||||
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())
|
||||
@ -29,12 +28,12 @@ static error_code dumpObject(const ObjectFile &Obj) {
|
||||
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());
|
||||
@ -54,7 +53,7 @@ int main(int argc, char *argv[]) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user