prepare-builtins: Fix build with LLVM 3.7

llvm-svn: 240552
This commit is contained in:
Tom Stellard 2015-06-24 17:03:50 +00:00
parent 9d3f89a7bb
commit 4957e4057d
1 changed files with 19 additions and 6 deletions

View File

@ -14,6 +14,10 @@
#include <system_error> #include <system_error>
#define LLVM_360 \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 6)
using namespace llvm; using namespace llvm;
static cl::opt<std::string> static cl::opt<std::string>
@ -30,7 +34,7 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "libclc builtin preparation tool\n"); cl::ParseCommandLineOptions(argc, argv, "libclc builtin preparation tool\n");
std::string ErrorMessage; std::string ErrorMessage;
std::auto_ptr<Module> M; Module *M;
{ {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr = ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
@ -39,15 +43,24 @@ int main(int argc, char **argv) {
if (std::error_code ec = BufferOrErr.getError()) if (std::error_code ec = BufferOrErr.getError())
ErrorMessage = ec.message(); ErrorMessage = ec.message();
else { else {
ErrorOr<Module *> ModuleOrErr = #if LLVM_360
ErrorOr<Module *>
#else
ErrorOr<std::unique_ptr<Module>>
#endif
ModuleOrErr =
parseBitcodeFile(BufferPtr.get()->getMemBufferRef(), Context); parseBitcodeFile(BufferPtr.get()->getMemBufferRef(), Context);
if (std::error_code ec = ModuleOrErr.getError()) if (std::error_code ec = ModuleOrErr.getError())
ErrorMessage = ec.message(); ErrorMessage = ec.message();
M.reset(ModuleOrErr.get()); #if LLVM_360
M = ModuleOrErr.get().get();
#else
M = ModuleOrErr.get().release();
#endif
} }
} }
if (M.get() == 0) { if (!M) {
errs() << argv[0] << ": "; errs() << argv[0] << ": ";
if (ErrorMessage.size()) if (ErrorMessage.size())
errs() << ErrorMessage << "\n"; errs() << ErrorMessage << "\n";
@ -81,7 +94,7 @@ int main(int argc, char **argv) {
exit(1); exit(1);
} }
WriteBitcodeToFile(M.get(), Out->os()); WriteBitcodeToFile(M, Out->os());
// Declare success. // Declare success.
Out->keep(); Out->keep();