summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-06-13 03:07:50 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-06-13 03:07:50 +0000
commit1ad45020ec8518a5c9bea7ec1007798a456bff56 (patch)
tree07430093f7f8e4eaf7cfa61b960406627e961c54
parent7532b4038f2ce16cc285ed6b3254053f30088faa (diff)
downloadllvm-1ad45020ec8518a5c9bea7ec1007798a456bff56.tar.gz
llvm-1ad45020ec8518a5c9bea7ec1007798a456bff56.tar.bz2
llvm-1ad45020ec8518a5c9bea7ec1007798a456bff56.tar.xz
Remove 'using std::error_code' from tools.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210876 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/bugpoint/ExecutionDriver.cpp7
-rw-r--r--tools/bugpoint/ExtractFunction.cpp3
-rw-r--r--tools/bugpoint/Miscompilation.cpp9
-rw-r--r--tools/bugpoint/OptimizerDriver.cpp3
-rw-r--r--tools/bugpoint/ToolRunner.cpp9
-rw-r--r--tools/gold/gold-plugin.cpp5
-rw-r--r--tools/lli/RemoteMemoryManager.cpp3
-rw-r--r--tools/lli/lli.cpp5
-rw-r--r--tools/llvm-ar/llvm-ar.cpp5
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp4
-rw-r--r--tools/llvm-cov/llvm-cov.cpp5
-rw-r--r--tools/llvm-dis/llvm-dis.cpp3
-rw-r--r--tools/llvm-dwarfdump/llvm-dwarfdump.cpp5
-rw-r--r--tools/llvm-mc/llvm-mc.cpp4
-rw-r--r--tools/llvm-mcmarkup/llvm-mcmarkup.cpp3
-rw-r--r--tools/llvm-nm/llvm-nm.cpp3
-rw-r--r--tools/llvm-objdump/COFFDump.cpp42
-rw-r--r--tools/llvm-objdump/MachODump.cpp5
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp11
-rw-r--r--tools/llvm-profdata/llvm-profdata.cpp8
-rw-r--r--tools/llvm-readobj/COFFDumper.cpp56
-rw-r--r--tools/llvm-readobj/ELFDumper.cpp12
-rw-r--r--tools/llvm-readobj/MachODumper.cpp9
-rw-r--r--tools/llvm-readobj/Win64EHDumper.cpp18
-rw-r--r--tools/llvm-readobj/llvm-readobj.cpp16
-rw-r--r--tools/llvm-rtdyld/llvm-rtdyld.cpp9
-rw-r--r--tools/llvm-size/llvm-size.cpp7
-rw-r--r--tools/llvm-symbolizer/LLVMSymbolize.cpp5
-rw-r--r--tools/llvm-symbolizer/llvm-symbolizer.cpp1
-rw-r--r--tools/macho-dump/macho-dump.cpp3
-rw-r--r--tools/obj2yaml/coff2yaml.cpp5
-rw-r--r--tools/obj2yaml/elf2yaml.cpp69
-rw-r--r--tools/obj2yaml/obj2yaml.cpp9
33 files changed, 167 insertions, 194 deletions
diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp
index b41a4b0334..25813b34e6 100644
--- a/tools/bugpoint/ExecutionDriver.cpp
+++ b/tools/bugpoint/ExecutionDriver.cpp
@@ -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";
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index a257840b6e..4fb68566ac 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -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";
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 5143fa1f03..3f1f84ef62 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -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";
diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp
index 85790b0c63..d452fd94c0 100644
--- a/tools/bugpoint/OptimizerDriver.cpp
+++ b/tools/bugpoint/OptimizerDriver.cpp
@@ -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: "
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp
index ec120bb0b2..4a2401b530 100644
--- a/tools/bugpoint/ToolRunner.cpp
+++ b/tools/bugpoint/ToolRunner.cpp
@@ -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";
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp
index 2030fbd6c8..371574f261 100644
--- a/tools/gold/gold-plugin.cpp
+++ b/tools/gold/gold-plugin.cpp
@@ -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());
diff --git a/tools/lli/RemoteMemoryManager.cpp b/tools/lli/RemoteMemoryManager.cpp
index 041f7c7afd..481651772a 100644
--- a/tools/lli/RemoteMemoryManager.cpp
+++ b/tools/lli/RemoteMemoryManager.cpp
@@ -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 |
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 2c8a4749fd..73a19ac667 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -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());
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index d0d4f1477d..227adb4421 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -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";
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index d29c83714a..fe2b235e53 100644
--- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -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)
diff --git a/tools/llvm-cov/llvm-cov.cpp b/tools/llvm-cov/llvm-cov.cpp
index 97a91dd544..b233a90bf5 100644
--- a/tools/llvm-cov/llvm-cov.cpp
+++ b/tools/llvm-cov/llvm-cov.cpp
@@ -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;
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index f5dfedbc47..3b0f838f1d 100644
--- a/tools/llvm-dis/llvm-dis.cpp
+++ b/tools/llvm-dis/llvm-dis.cpp
@@ -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();
}
diff --git a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 2f10f2994f..29f0c8707a 100644
--- a/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -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;
}
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index 24a2d6f208..a6b74a7b1b 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -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;
}
diff --git a/tools/llvm-mcmarkup/llvm-mcmarkup.cpp b/tools/llvm-mcmarkup/llvm-mcmarkup.cpp
index e8416d6012..cbb0d51dd3 100644
--- a/tools/llvm-mcmarkup/llvm-mcmarkup.cpp
+++ b/tools/llvm-mcmarkup/llvm-mcmarkup.cpp
@@ -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;
}
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 6476a60c7e..19d9888e8a 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -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;
diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp
index 84799ec8b0..39d8e8e39f 100644
--- a/tools/llvm-objdump/COFFDump.cpp
+++ b/tools/llvm-objdump/COFFDump.cpp
@@ -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;
}
diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp
index cba7318354..21c4c96d4c 100644
--- a/tools/llvm-objdump/MachODump.cpp
+++ b/tools/llvm-objdump/MachODump.cpp
@@ -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;
}
diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp
index 254c802aec..e12ff3de2b 100644
--- a/tools/llvm-objdump/llvm-objdump.cpp
+++ b/tools/llvm-objdump/llvm-objdump.cpp
@@ -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;
}
diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp
index 9bf0897949..ba88aad9ec 100644
--- a/tools/llvm-profdata/llvm-profdata.cpp
+++ b/tools/llvm-profdata/llvm-profdata.cpp
@@ -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())
diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp
index 0a14c42fe3..8b0dcb3e2c 100644
--- a/tools/llvm-readobj/COFFDumper.cpp
+++ b/tools/llvm-readobj/COFFDumper.cpp
@@ -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;
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp
index 8ec59bec00..f13b300d6d 100644
--- a/tools/llvm-readobj/ELFDumper.cpp
+++ b/tools/llvm-readobj/ELFDumper.cpp
@@ -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);
diff --git a/tools/llvm-readobj/MachODumper.cpp b/tools/llvm-readobj/MachODumper.cpp
index 0c31bec993..d168030a27 100644
--- a/tools/llvm-readobj/MachODumper.cpp
+++ b/tools/llvm-readobj/MachODumper.cpp
@@ -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)))
diff --git a/tools/llvm-readobj/Win64EHDumper.cpp b/tools/llvm-readobj/Win64EHDumper.cpp
index f3749fc36c..f058632a8c 100644
--- a/tools/llvm-readobj/Win64EHDumper.cpp
+++ b/tools/llvm-readobj/Win64EHDumper.cpp
@@ -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);
diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp
index 70af4dc4cb..d66c02f413 100644
--- a/tools/llvm-readobj/llvm-readobj.cpp
+++ b/tools/llvm-readobj/llvm-readobj.cpp
@@ -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;
}
diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp
index e86d93bd49..f1364d5350 100644
--- a/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -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
diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp
index f0ec7fa6af..1ea22a937a 100644
--- a/tools/llvm-size/llvm-size.cpp
+++ b/tools/llvm-size/llvm-size.cpp
@@ -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;
}
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp
index 61c4e8ad20..c6bd4e7abf 100644
--- a/tools/llvm-symbolizer/LLVMSymbolize.cpp
+++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp
@@ -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));
diff --git a/tools/llvm-symbolizer/llvm-symbolizer.cpp b/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 2ee30e816e..29db172531 100644
--- a/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -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),
diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp
index 13e8a4b80c..bfe1a6eaef 100644
--- a/tools/macho-dump/macho-dump.cpp
+++ b/tools/macho-dump/macho-dump.cpp
@@ -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());
diff --git a/tools/obj2yaml/coff2yaml.cpp b/tools/obj2yaml/coff2yaml.cpp
index 816f9e65cd..48462f69fc 100644
--- a/tools/obj2yaml/coff2yaml.cpp
+++ b/tools/obj2yaml/coff2yaml.cpp
@@ -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);
diff --git a/tools/obj2yaml/elf2yaml.cpp b/tools/obj2yaml/elf2yaml.cpp
index a20ad6f3e2..c817e1526d 100644
--- a/tools/obj2yaml/elf2yaml.cpp
+++ b/tools/obj2yaml/elf2yaml.cpp
@@ -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());
diff --git a/tools/obj2yaml/obj2yaml.cpp b/tools/obj2yaml/obj2yaml.cpp
index 717c68d1c6..944314a923 100644
--- a/tools/obj2yaml/obj2yaml.cpp
+++ b/tools/obj2yaml/obj2yaml.cpp
@@ -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;
}