diff --git a/cbackend.cpp b/cbackend.cpp index 867385a4..5de99366 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -4945,9 +4945,19 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None; #endif +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) std::string error; +#else // LLVM 3.6+ + std::error_code error; +#endif + llvm::tool_output_file *of = new llvm::tool_output_file(fn, error, flags); + +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) if (error.size()) { +#else // LLVM 3.6+ + if (error) { +#endif fprintf(stderr, "Error opening output file \"%s\".\n", fn); return false; } diff --git a/module.cpp b/module.cpp index a60a1490..be3b5fab 100644 --- a/module.cpp +++ b/module.cpp @@ -1088,9 +1088,20 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, #endif +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) std::string error; +#else // LLVM 3.6+ + std::error_code error; +#endif + llvm::tool_output_file *of = new llvm::tool_output_file(outFileName, error, flags); + +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) if (error.size()) { +#else // LLVM 3.6+ + if (error) { +#endif + fprintf(stderr, "Error opening output file \"%s\".\n", outFileName); return false; }