Extract DIBuilderExt::create_expression
This commit is contained in:
21
compiler/rustc_codegen_llvm/src/debuginfo/di_builder.rs
Normal file
21
compiler/rustc_codegen_llvm/src/debuginfo/di_builder.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::DIBuilder;
|
||||
|
||||
/// Extension trait for defining safe wrappers and helper methods on
|
||||
/// `&DIBuilder<'ll>`, without requiring it to be defined in the same crate.
|
||||
pub(crate) trait DIBuilderExt<'ll> {
|
||||
fn as_di_builder(&self) -> &DIBuilder<'ll>;
|
||||
|
||||
fn create_expression(&self, addr_ops: &[u64]) -> &'ll llvm::Metadata {
|
||||
let this = self.as_di_builder();
|
||||
unsafe { llvm::LLVMDIBuilderCreateExpression(this, addr_ops.as_ptr(), addr_ops.len()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ll> DIBuilderExt<'ll> for &DIBuilder<'ll> {
|
||||
fn as_di_builder(&self) -> &DIBuilder<'ll> {
|
||||
self
|
||||
}
|
||||
|
||||
// All other methods have default bodies that rely on `as_di_builder`.
|
||||
}
|
||||
@@ -29,6 +29,7 @@ use smallvec::SmallVec;
|
||||
use tracing::debug;
|
||||
|
||||
use self::create_scope_map::compute_mir_scopes;
|
||||
pub(crate) use self::di_builder::DIBuilderExt;
|
||||
pub(crate) use self::metadata::build_global_var_di_node;
|
||||
use self::metadata::{
|
||||
UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER, file_metadata, spanned_type_di_node, type_di_node,
|
||||
@@ -44,6 +45,7 @@ use crate::llvm::debuginfo::{
|
||||
use crate::llvm::{self, Value};
|
||||
|
||||
mod create_scope_map;
|
||||
mod di_builder;
|
||||
mod dwarf_const;
|
||||
mod gdb;
|
||||
pub(crate) mod metadata;
|
||||
@@ -181,9 +183,7 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
|
||||
}
|
||||
|
||||
let di_builder = DIB(self.cx());
|
||||
let addr_expr = unsafe {
|
||||
llvm::LLVMDIBuilderCreateExpression(di_builder, addr_ops.as_ptr(), addr_ops.len())
|
||||
};
|
||||
let addr_expr = di_builder.create_expression(&addr_ops);
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderInsertDeclareRecordAtEnd(
|
||||
di_builder,
|
||||
|
||||
Reference in New Issue
Block a user