summaryrefslogtreecommitdiffstats
path: root/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp')
-rw-r--r--tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
index 9c0d675..980f278 100644
--- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
+++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
@@ -27,6 +27,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/OwningPtr.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Bitcode/BitstreamReader.h"
#include "llvm/Bitcode/LLVMBitCodes.h"
@@ -37,7 +38,8 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/System/Signals.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/system_error.h"
#include <cstdio>
#include <map>
#include <algorithm>
@@ -57,15 +59,22 @@ static cl::opt<bool> NoHistogram("disable-histogram",
static cl::opt<bool>
NonSymbolic("non-symbolic",
- cl::desc("Emit numberic info in dump even if"
+ cl::desc("Emit numeric info in dump even if"
" symbolic info is available"));
-/// CurStreamType - If we can sniff the flavor of this stream, we can produce
-/// better dump info.
-static enum {
+namespace {
+
+/// CurStreamTypeType - A type for CurStreamType
+enum CurStreamTypeType {
UnknownBitstream,
LLVMIRBitstream
-} CurStreamType;
+};
+
+}
+
+/// CurStreamType - If we can sniff the flavor of this stream, we can produce
+/// better dump info.
+static CurStreamTypeType CurStreamType;
/// GetBlockName - Return a symbolic block name if known, otherwise return
@@ -254,6 +263,7 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
switch(CodeID) {
default:return 0;
case bitc::METADATA_ATTACHMENT: return "METADATA_ATTACHMENT";
+ case bitc::METADATA_ATTACHMENT2: return "METADATA_ATTACHMENT2";
}
case bitc::METADATA_BLOCK_ID:
switch(CodeID) {
@@ -268,7 +278,6 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
case bitc::METADATA_NODE2: return "METADATA_NODE2";
case bitc::METADATA_FN_NODE2: return "METADATA_FN_NODE2";
case bitc::METADATA_NAMED_NODE2: return "METADATA_NAMED_NODE2";
- case bitc::METADATA_ATTACHMENT2: return "METADATA_ATTACHMENT2";
}
}
}
@@ -473,10 +482,11 @@ 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());
+ OwningPtr<MemoryBuffer> MemBuf;
- if (MemBuf == 0)
- return Error("Error reading '" + InputFilename + "'.");
+ if (error_code ec =
+ MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), MemBuf))
+ return Error("Error reading '" + InputFilename + "': " + ec.message());
if (MemBuf->getBufferSize() & 3)
return Error("Bitcode stream should be a multiple of 4 bytes in length");
OpenPOWER on IntegriCloud