Let backends access span information
Sometimes, a backend may need to emit warnings, errors, or otherwise need to know the span of the current item in a basic block. So, add a set_span method to give the backend that information.
This commit is contained in:
parent
5849a7eca9
commit
c5bc95676b
3 changed files with 6 additions and 1 deletions
|
@ -16,7 +16,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::ty::layout::TyAndLayout;
|
use rustc_middle::ty::layout::TyAndLayout;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_span::sym;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_target::abi::{self, Align, Size};
|
use rustc_target::abi::{self, Align, Size};
|
||||||
use rustc_target::spec::{HasTargetSpec, Target};
|
use rustc_target::spec::{HasTargetSpec, Target};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -139,6 +139,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
unsafe { llvm::LLVMGetInsertBlock(self.llbuilder) }
|
unsafe { llvm::LLVMGetInsertBlock(self.llbuilder) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_span(&self, _span: Span) {}
|
||||||
|
|
||||||
fn position_at_end(&mut self, llbb: &'ll BasicBlock) {
|
fn position_at_end(&mut self, llbb: &'ll BasicBlock) {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMPositionBuilderAtEnd(self.llbuilder, llbb);
|
llvm::LLVMPositionBuilderAtEnd(self.llbuilder, llbb);
|
||||||
|
|
|
@ -55,6 +55,7 @@ impl<D> DebugScope<D> {
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
pub fn set_debug_loc(&self, bx: &mut Bx, source_info: mir::SourceInfo) {
|
pub fn set_debug_loc(&self, bx: &mut Bx, source_info: mir::SourceInfo) {
|
||||||
let (scope, span) = self.debug_loc(source_info);
|
let (scope, span) = self.debug_loc(source_info);
|
||||||
|
bx.set_span(span);
|
||||||
if let Some(scope) = scope {
|
if let Some(scope) = scope {
|
||||||
bx.set_source_location(scope, span);
|
bx.set_source_location(scope, span);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::MemFlags;
|
||||||
|
|
||||||
use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
|
use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
|
||||||
use rustc_middle::ty::Ty;
|
use rustc_middle::ty::Ty;
|
||||||
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::{Abi, Align, Scalar, Size};
|
use rustc_target::abi::{Abi, Align, Scalar, Size};
|
||||||
use rustc_target::spec::HasTargetSpec;
|
use rustc_target::spec::HasTargetSpec;
|
||||||
|
|
||||||
|
@ -44,6 +45,7 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
fn build_sibling_block(&self, name: &str) -> Self;
|
fn build_sibling_block(&self, name: &str) -> Self;
|
||||||
fn cx(&self) -> &Self::CodegenCx;
|
fn cx(&self) -> &Self::CodegenCx;
|
||||||
fn llbb(&self) -> Self::BasicBlock;
|
fn llbb(&self) -> Self::BasicBlock;
|
||||||
|
fn set_span(&self, span: Span);
|
||||||
|
|
||||||
fn position_at_end(&mut self, llbb: Self::BasicBlock);
|
fn position_at_end(&mut self, llbb: Self::BasicBlock);
|
||||||
fn ret_void(&mut self);
|
fn ret_void(&mut self);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue