Remove internal mutability from source_locations_enabled
This commit is contained in:
parent
f1fe9253e2
commit
ab8f1527e4
4 changed files with 9 additions and 10 deletions
|
@ -32,7 +32,7 @@ use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, Variable
|
||||||
VariableKind, FunctionDebugContextData};
|
VariableKind, FunctionDebugContextData};
|
||||||
|
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::RefCell;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
|
|
||||||
use syntax_pos::{self, Span, Pos};
|
use syntax_pos::{self, Span, Pos};
|
||||||
|
@ -158,7 +158,7 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
variable_kind: VariableKind,
|
variable_kind: VariableKind,
|
||||||
span: Span,
|
span: Span,
|
||||||
) {
|
) {
|
||||||
assert!(!dbg_context.get_ref(span).source_locations_enabled.get());
|
assert!(!dbg_context.get_ref(span).source_locations_enabled);
|
||||||
let cx = self.cx();
|
let cx = self.cx();
|
||||||
|
|
||||||
let file = span_start(cx, span).file;
|
let file = span_start(cx, span).file;
|
||||||
|
@ -327,7 +327,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
// Initialize fn debug context (including scope map and namespace map)
|
// Initialize fn debug context (including scope map and namespace map)
|
||||||
let fn_debug_context = FunctionDebugContextData {
|
let fn_debug_context = FunctionDebugContextData {
|
||||||
fn_metadata,
|
fn_metadata,
|
||||||
source_locations_enabled: Cell::new(false),
|
source_locations_enabled: false,
|
||||||
defining_crate: def_id.krate,
|
defining_crate: def_id.krate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub fn set_source_location<D>(
|
||||||
FunctionDebugContext::RegularContext(ref data) => data
|
FunctionDebugContext::RegularContext(ref data) => data
|
||||||
};
|
};
|
||||||
|
|
||||||
let dbg_loc = if function_debug_context.source_locations_enabled.get() {
|
let dbg_loc = if function_debug_context.source_locations_enabled {
|
||||||
debug!("set_source_location: {}", bx.sess().source_map().span_to_string(span));
|
debug!("set_source_location: {}", bx.sess().source_map().span_to_string(span));
|
||||||
let loc = span_start(bx.cx(), span);
|
let loc = span_start(bx.cx(), span);
|
||||||
InternalDebugLocation::new(scope.unwrap(), loc.line, loc.col.to_usize())
|
InternalDebugLocation::new(scope.unwrap(), loc.line, loc.col.to_usize())
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use syntax_pos::{BytePos, Span};
|
use syntax_pos::{BytePos, Span};
|
||||||
use rustc::hir::def_id::CrateNum;
|
use rustc::hir::def_id::CrateNum;
|
||||||
use std::cell::Cell;
|
|
||||||
|
|
||||||
pub enum FunctionDebugContext<D> {
|
pub enum FunctionDebugContext<D> {
|
||||||
RegularContext(FunctionDebugContextData<D>),
|
RegularContext(FunctionDebugContextData<D>),
|
||||||
|
@ -36,10 +35,10 @@ impl<D> FunctionDebugContext<D> {
|
||||||
/// they are disabled when beginning to codegen a new function. This functions
|
/// they are disabled when beginning to codegen a new function. This functions
|
||||||
/// switches source location emitting on and must therefore be called before the
|
/// switches source location emitting on and must therefore be called before the
|
||||||
/// first real statement/expression of the function is codegened.
|
/// first real statement/expression of the function is codegened.
|
||||||
pub fn start_emitting_source_locations<D>(dbg_context: &FunctionDebugContext<D>) {
|
pub fn start_emitting_source_locations<D>(dbg_context: &mut FunctionDebugContext<D>) {
|
||||||
match *dbg_context {
|
match *dbg_context {
|
||||||
FunctionDebugContext::RegularContext(ref data) => {
|
FunctionDebugContext::RegularContext(ref mut data) => {
|
||||||
data.source_locations_enabled.set(true)
|
data.source_locations_enabled = true;
|
||||||
},
|
},
|
||||||
_ => { /* safe to ignore */ }
|
_ => { /* safe to ignore */ }
|
||||||
}
|
}
|
||||||
|
@ -47,7 +46,7 @@ pub fn start_emitting_source_locations<D>(dbg_context: &FunctionDebugContext<D>)
|
||||||
|
|
||||||
pub struct FunctionDebugContextData<D> {
|
pub struct FunctionDebugContextData<D> {
|
||||||
pub fn_metadata: D,
|
pub fn_metadata: D,
|
||||||
pub source_locations_enabled: Cell<bool>,
|
pub source_locations_enabled: bool,
|
||||||
pub defining_crate: CrateNum,
|
pub defining_crate: CrateNum,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,7 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
|
||||||
// Up until here, IR instructions for this function have explicitly not been annotated with
|
// Up until here, IR instructions for this function have explicitly not been annotated with
|
||||||
// source code location, so we don't step into call setup code. From here on, source location
|
// source code location, so we don't step into call setup code. From here on, source location
|
||||||
// emitting should be enabled.
|
// emitting should be enabled.
|
||||||
debuginfo::start_emitting_source_locations(&fx.debug_context);
|
debuginfo::start_emitting_source_locations(&mut fx.debug_context);
|
||||||
|
|
||||||
let rpo = traversal::reverse_postorder(&mir);
|
let rpo = traversal::reverse_postorder(&mir);
|
||||||
let mut visited = BitSet::new_empty(mir.basic_blocks().len());
|
let mut visited = BitSet::new_empty(mir.basic_blocks().len());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue