From 1ee87b3765b4cc0ab78aec25009e4e5295024f93 Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Fri, 21 Jul 2017 14:29:23 +0200 Subject: rustllvm: split DebugLoc in UnpackOptimizationDiagnostic --- src/rustllvm/RustWrapper.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/rustllvm') diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 896c8224508..94185b5432d 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -906,8 +906,8 @@ extern "C" void LLVMRustWriteTwineToString(LLVMTwineRef T, RustStringRef Str) { extern "C" void LLVMRustUnpackOptimizationDiagnostic( LLVMDiagnosticInfoRef DI, RustStringRef PassNameOut, - LLVMValueRef *FunctionOut, LLVMDebugLocRef *DebugLocOut, - RustStringRef MessageOut) { + LLVMValueRef *FunctionOut, unsigned* Line, unsigned* Column, + RustStringRef FilenameOut, RustStringRef MessageOut) { // Undefined to call this not on an optimization diagnostic! llvm::DiagnosticInfoOptimizationBase *Opt = static_cast(unwrap(DI)); @@ -915,7 +915,24 @@ extern "C" void LLVMRustUnpackOptimizationDiagnostic( RawRustStringOstream PassNameOS(PassNameOut); PassNameOS << Opt->getPassName(); *FunctionOut = wrap(&Opt->getFunction()); - *DebugLocOut = wrap(&Opt->getDebugLoc()); + + RawRustStringOstream FilenameOS(FilenameOut); +#if LLVM_VERSION_GE(5,0) + DiagnosticLocation loc = Opt->getLocation(); + if (loc.isValid()) { + *Line = loc.getLine(); + *Column = loc.getColumn(); + FilenameOS << loc.getFilename(); + } +#else + const DebugLoc &loc = Opt->getDebugLoc(); + if (loc) { + *Line = loc.getLine(); + *Column = loc.getCol(); + FilenameOS << cast(loc.getScope())->getFilename(); + } +#endif + RawRustStringOstream MessageOS(MessageOut); MessageOS << Opt->getMsg(); } -- cgit 1.4.1-3-g733a5