about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorTim Neumann <mail@timnn.me>2017-07-21 14:29:23 +0200
committerTim Neumann <mail@timnn.me>2017-07-21 19:09:10 +0200
commit1ee87b3765b4cc0ab78aec25009e4e5295024f93 (patch)
tree8b01cdfdd1f4c4267953a46ff77229e3489de9ea /src/rustllvm/RustWrapper.cpp
parenta53676762bbe492154926393b187f0ee49df6e98 (diff)
downloadrust-1ee87b3765b4cc0ab78aec25009e4e5295024f93.tar.gz
rust-1ee87b3765b4cc0ab78aec25009e4e5295024f93.zip
rustllvm: split DebugLoc in UnpackOptimizationDiagnostic
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp23
1 files changed, 20 insertions, 3 deletions
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<llvm::DiagnosticInfoOptimizationBase *>(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<DIScope>(loc.getScope())->getFilename();
+  }
+#endif
+
   RawRustStringOstream MessageOS(MessageOut);
   MessageOS << Opt->getMsg();
 }