summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp7
-rw-r--r--tools/llvm-dis/llvm-dis.cpp10
-rw-r--r--tools/llvm-mc/llvm-mc.cpp35
-rw-r--r--tools/llvm-nm/llvm-nm.cpp6
-rw-r--r--tools/llvm-prof/llvm-prof.cpp8
-rw-r--r--tools/macho-dump/macho-dump.cpp6
6 files changed, 35 insertions, 37 deletions
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index 36b0deb07e..f11fdb893f 100644
--- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -38,6 +38,7 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Signals.h"
+#include "llvm/Support/system_error.h"
#include <cstdio>
#include <map>
#include <algorithm>
@@ -473,10 +474,12 @@ static void PrintSize(uint64_t Bits) {
/// AnalyzeBitcode - Analyze the bitcode file specified by InputFilename.
static int AnalyzeBitcode() {
// Read the input file.
- MemoryBuffer *MemBuf = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str());
+ error_code ec;
+ MemoryBuffer *MemBuf =
+ MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), ec);
if (MemBuf == 0)
- return Error("Error reading '" + InputFilename + "'.");
+ return Error("Error reading '" + InputFilename + "': " + ec.message());
if (MemBuf->getBufferSize() & 3)
return Error("Bitcode stream should be a multiple of 4 bytes in length");
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index 9e057755f8..781bca95ea 100644
--- a/tools/llvm-dis/llvm-dis.cpp
+++ b/tools/llvm-dis/llvm-dis.cpp
@@ -28,6 +28,7 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/Signals.h"
+#include "llvm/Support/system_error.h"
using namespace llvm;
static cl::opt<std::string>
@@ -78,13 +79,14 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
std::string ErrorMessage;
+ error_code ec;
std::auto_ptr<Module> M;
-
- if (MemoryBuffer *Buffer
- = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
+
+ if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename, ec)) {
M.reset(ParseBitcodeFile(Buffer, Context, &ErrorMessage));
delete Buffer;
- }
+ } else
+ ErrorMessage = ec.message();
if (M.get() == 0) {
errs() << argv[0] << ": ";
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index b42f373472..46eb3727d6 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -37,6 +37,7 @@
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Signals.h"
+#include "llvm/Support/system_error.h"
#include "Disassembler.h"
using namespace llvm;
@@ -164,15 +165,10 @@ static tool_output_file *GetOutputStream() {
}
static int AsLexInput(const char *ProgName) {
- std::string ErrorMessage;
- MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
- &ErrorMessage);
+ error_code ec;
+ MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename, ec);
if (Buffer == 0) {
- errs() << ProgName << ": ";
- if (ErrorMessage.size())
- errs() << ErrorMessage << "\n";
- else
- errs() << "input file didn't read correctly.\n";
+ errs() << ProgName << ": " << ec.message() << '\n';
return 1;
}
@@ -282,14 +278,10 @@ static int AssembleInput(const char *ProgName) {
if (!TheTarget)
return 1;
- std::string Error;
- MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename, &Error);
+ error_code ec;
+ MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename, ec);
if (Buffer == 0) {
- errs() << ProgName << ": ";
- if (Error.size())
- errs() << Error << "\n";
- else
- errs() << "input file didn't read correctly.\n";
+ errs() << ProgName << ": " << ec.message() << '\n';
return 1;
}
@@ -383,18 +375,11 @@ static int DisassembleInput(const char *ProgName, bool Enhanced) {
const Target *TheTarget = GetTarget(ProgName);
if (!TheTarget)
return 0;
-
- std::string ErrorMessage;
-
- MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename,
- &ErrorMessage);
+ error_code ec;
+ MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFilename, ec);
if (Buffer == 0) {
- errs() << ProgName << ": ";
- if (ErrorMessage.size())
- errs() << ErrorMessage << "\n";
- else
- errs() << "input file didn't read correctly.\n";
+ errs() << ProgName << ": " << ec.message() << '\n';
return 1;
}
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 132644d8d2..16615964a3 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -26,6 +26,7 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Signals.h"
+#include "llvm/Support/system_error.h"
#include <algorithm>
#include <cctype>
#include <cerrno>
@@ -143,8 +144,11 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
sys::Path aPath(Filename);
// Note: Currently we do not support reading an archive from stdin.
if (Filename == "-" || aPath.isBitcodeFile()) {
+ error_code ec;
std::auto_ptr<MemoryBuffer> Buffer(
- MemoryBuffer::getFileOrSTDIN(Filename, &ErrorMessage));
+ MemoryBuffer::getFileOrSTDIN(Filename, ec));
+ if (Buffer.get() == 0)
+ ErrorMessage = ec.message();
Module *Result = 0;
if (Buffer.get())
Result = ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage);
diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp
index 3351bd2735..aa9cf004c7 100644
--- a/tools/llvm-prof/llvm-prof.cpp
+++ b/tools/llvm-prof/llvm-prof.cpp
@@ -30,6 +30,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Signals.h"
+#include "llvm/Support/system_error.h"
#include <algorithm>
#include <iomanip>
#include <map>
@@ -263,12 +264,13 @@ int main(int argc, char **argv) {
// Read in the bitcode file...
std::string ErrorMessage;
+ error_code ec;
Module *M = 0;
- if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BitcodeFile,
- &ErrorMessage)) {
+ if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(BitcodeFile, ec)) {
M = ParseBitcodeFile(Buffer, Context, &ErrorMessage);
delete Buffer;
- }
+ } else
+ ErrorMessage = ec.message();
if (M == 0) {
errs() << argv[0] << ": " << BitcodeFile << ": "
<< ErrorMessage << "\n";
diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp
index 02fa36680f..982443a2ce 100644
--- a/tools/macho-dump/macho-dump.cpp
+++ b/tools/macho-dump/macho-dump.cpp
@@ -19,6 +19,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/system_error.h"
using namespace llvm;
using namespace llvm::object;
@@ -365,10 +366,11 @@ int main(int argc, char **argv) {
// Load the input file.
std::string ErrorStr;
+ error_code ec;
OwningPtr<MemoryBuffer> InputBuffer(
- MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorStr));
+ MemoryBuffer::getFileOrSTDIN(InputFile, ec));
if (!InputBuffer)
- return Error("unable to read input: '" + ErrorStr + "'");
+ return Error("unable to read input: '" + ec.message() + "'");
// Construct the Mach-O wrapper object.
OwningPtr<MachOObject> InputObject(