fix(builder.rs): Add cfg(feature = "master") to set_location

This commit is contained in:
tempdragon 2024-02-28 10:04:25 +08:00
parent 5b053a3c3c
commit 6170f48e3f
2 changed files with 10 additions and 14 deletions

View File

@ -26,7 +26,6 @@ use rustc_codegen_ssa::traits::{
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::mir::Rvalue;
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers, TyAndLayout}; use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers, TyAndLayout};
use rustc_span::Span; use rustc_span::Span;
@ -401,9 +400,8 @@ impl<'gcc, 'tcx> BackendTypes for Builder<'_, 'gcc, 'tcx> {
pub fn set_rval_location<'a, 'gcc, 'tcx>(bx: &mut Builder<'a,'gcc,'tcx>, r:RValue<'gcc>) -> RValue<'gcc> { pub fn set_rval_location<'a, 'gcc, 'tcx>(bx: &mut Builder<'a,'gcc,'tcx>, r:RValue<'gcc>) -> RValue<'gcc> {
if bx.loc.is_some(){ if bx.loc.is_some(){
unsafe { #[cfg(feature = "master")]
r.set_location(bx.loc.unwrap()); r.set_location(bx.loc.unwrap());
}
} }
r r
@ -545,9 +543,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
fn fmul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { fn fmul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
let i=a * b; let i=a * b;
if self.loc.is_some() { if self.loc.is_some() {
unsafe{ #[cfg(feature = "master")]
i.set_location(self.loc.clone().unwrap()); i.set_location(self.loc.clone().unwrap());
}
} }
i i
} }
@ -666,7 +663,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let ret = self.cx.gcc_or(a, b, self.loc); let ret = self.cx.gcc_or(a, b, self.loc);
if self.loc.is_some() { if self.loc.is_some() {
unsafe { ret.set_location(self.loc.unwrap()); } #[cfg(feature = "master")]
ret.set_location(self.loc.unwrap());
} }
ret ret
} }

View File

@ -32,10 +32,8 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
_fragment: Option<Range<Size>>, _fragment: Option<Range<Size>>,
) { ) {
// Not sure if this is correct, probably wrong but still keep it here. // Not sure if this is correct, probably wrong but still keep it here.
unsafe { #[cfg(feature = "master")]
#[cfg(feature = "master")] variable_alloca.set_location(dbg_loc);
variable_alloca.set_location(dbg_loc);
}
} }
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) { fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
@ -45,7 +43,7 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
/// Currently, this function is not yet implemented. It seems that the /// Currently, this function is not yet implemented. It seems that the
/// debug name and the mangled name should both be included in the LValues. /// debug name and the mangled name should both be included in the LValues.
/// Besides, a function to get the rvalue type(m_is_lvalue) should also be included. /// Besides, a function to get the rvalue type(m_is_lvalue) should also be included.
fn set_var_name(&mut self, value: RValue<'gcc>, name: &str) { fn set_var_name(&mut self, _value: RValue<'gcc>, _name: &str) {
//unimplemented!(); //unimplemented!();
} }
@ -264,7 +262,7 @@ impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
} }
rustc_span::RealFileName::Remapped { rustc_span::RealFileName::Remapped {
local_path, local_path,
virtual_name, virtual_name:_,
} => if let Some(name) = local_path.as_ref() { } => if let Some(name) = local_path.as_ref() {
if let Some(name) = name.to_str(){ if let Some(name) = name.to_str(){
self.context.new_location( self.context.new_location(