diff options
author | Dan Gohman <gohman@apple.com> | 2010-09-13 18:02:47 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-09-13 18:02:47 +0000 |
commit | c32a2260a6145000581a74fd61ba57bdcc4cb951 (patch) | |
tree | d91f7d2d2739849a2d9b12fb3053a28fae6ee13b | |
parent | 9b10dfb7d6ffb0e4466f908cd7d18212a45cfdac (diff) | |
download | external_llvm-c32a2260a6145000581a74fd61ba57bdcc4cb951.zip external_llvm-c32a2260a6145000581a74fd61ba57bdcc4cb951.tar.gz external_llvm-c32a2260a6145000581a74fd61ba57bdcc4cb951.tar.bz2 |
Use ParseIRFile to auto-detect LLVM Assembly automatically.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113765 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/llvm-diff/llvm-diff.cpp | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/tools/llvm-diff/llvm-diff.cpp b/tools/llvm-diff/llvm-diff.cpp index 579b60f..b932ccc 100644 --- a/tools/llvm-diff/llvm-diff.cpp +++ b/tools/llvm-diff/llvm-diff.cpp @@ -17,13 +17,12 @@ #include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/Type.h" -#include "llvm/Assembly/Parser.h" -#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/IRReader.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/SourceMgr.h" @@ -34,32 +33,14 @@ using namespace llvm; -/// Reads a module from a file. If the filename ends in .ll, it is -/// interpreted as an assembly file; otherwise, it is interpreted as -/// bitcode. On error, messages are written to stderr and null is -/// returned. +/// Reads a module from a file. On error, messages are written to stderr +/// and null is returned. static Module *ReadModule(LLVMContext &Context, StringRef Name) { - // LLVM assembly path. - if (Name.endswith(".ll")) { - SMDiagnostic Diag; - Module *M = ParseAssemblyFile(Name, Diag, Context); - if (M) return M; - + SMDiagnostic Diag; + Module *M = ParseIRFile(Name, Diag, Context); + if (!M) Diag.Print("llvmdiff", errs()); - return 0; - } - - // Bitcode path. - MemoryBuffer *Buffer = MemoryBuffer::getFile(Name); - - // ParseBitcodeFile takes ownership of the buffer if it succeeds. - std::string Error; - Module *M = ParseBitcodeFile(Buffer, Context, &Error); - if (M) return M; - - errs() << "error parsing " << Name << ": " << Error; - delete Buffer; - return 0; + return M; } namespace { |