diff options
author | dim <dim@FreeBSD.org> | 2011-02-20 12:57:14 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-20 12:57:14 +0000 |
commit | cbb70ce070d220642b038ea101d9c0f9fbf860d6 (patch) | |
tree | d2b61ce94e654cb01a254d2195259db5f9cc3f3c /tools/llvm-bcanalyzer | |
parent | 4ace901e87dac5bbbac78ed325e75462e48e386e (diff) | |
download | FreeBSD-src-cbb70ce070d220642b038ea101d9c0f9fbf860d6.zip FreeBSD-src-cbb70ce070d220642b038ea101d9c0f9fbf860d6.tar.gz |
Vendor import of llvm trunk r126079:
http://llvm.org/svn/llvm-project/llvm/trunk@126079
Diffstat (limited to 'tools/llvm-bcanalyzer')
-rw-r--r-- | tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 30 |
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"); |