]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/debuginfo/mod.rs
Rollup merge of #69609 - TimDiekmann:excess, r=Amanieu
[rust.git] / src / librustc_codegen_llvm / debuginfo / mod.rs
index 46f186191e3ab8d1562080dc44e847d0a46c0acb..6515d5e3bec7ff655877dfdad89c2bd4875b4cc7 100644 (file)
 use std::ffi::CString;
 
 use rustc::ty::layout::{self, HasTyCtxt, LayoutOf, Size};
+use rustc_ast::ast;
 use rustc_codegen_ssa::traits::*;
 use rustc_span::symbol::Symbol;
 use rustc_span::{self, BytePos, Span};
 use smallvec::SmallVec;
-use syntax::ast;
 
 mod create_scope_map;
 pub mod gdb;
@@ -51,7 +51,6 @@
 pub use self::create_scope_map::compute_mir_scopes;
 pub use self::metadata::create_global_var_metadata;
 pub use self::metadata::extend_scope_to_file;
-pub use self::source_loc::set_source_location;
 
 #[allow(non_upper_case_globals)]
 const DW_TAG_auto_variable: c_uint = 0x100;
@@ -193,13 +192,14 @@ fn dbg_var_addr(
         }
     }
 
-    fn set_source_location(
-        &mut self,
-        debug_context: &mut FunctionDebugContext<&'ll DIScope>,
-        scope: &'ll DIScope,
-        span: Span,
-    ) {
-        set_source_location(debug_context, &self, scope, span)
+    fn set_source_location(&mut self, scope: &'ll DIScope, span: Span) {
+        debug!("set_source_location: {}", self.sess().source_map().span_to_string(span));
+
+        let dbg_loc = self.cx().create_debug_loc(scope, span);
+
+        unsafe {
+            llvm::LLVMSetCurrentDebugLocation(self.llbuilder, dbg_loc);
+        }
     }
     fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
         gdb::insert_reference_to_gdb_debug_scripts_section_global(self)
@@ -333,7 +333,6 @@ fn create_function_debug_context(
         };
         let mut fn_debug_context = FunctionDebugContext {
             scopes: IndexVec::from_elem(null_scope, &mir.source_scopes),
-            source_locations_enabled: false,
             defining_crate: def_id.krate,
         };
 
@@ -560,7 +559,7 @@ fn create_dbg_var(
                 file_metadata,
                 loc.line as c_uint,
                 type_metadata,
-                self.sess().opts.optimize != config::OptLevel::No,
+                true,
                 DIFlags::FlagZero,
                 argument_index,
                 align.bytes() as u32,