use rustc_hir::def_id::DefId;
use rustc_middle::ty::DefIdTree;
use crate::context::CodegenCx;
use crate::llvm;
use crate::llvm::debuginfo::{DIArray, DIBuilder, DIDescriptor, DIScope};
use super::namespace::item_namespace;
use super::CrateDebugContext;
pub(crate) fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool {
!cx.tcx.is_reachable_non_generic(def_id)
}
#[allow(non_snake_case)]
pub(crate) fn create_DIArray<'ll>(
builder: &DIBuilder<'ll>,
arr: &[Option<&'ll DIDescriptor>],
) -> &'ll DIArray {
unsafe { llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) }
}
#[inline]
pub(crate) fn debug_context<'a, 'll, 'tcx>(
cx: &'a CodegenCx<'ll, 'tcx>,
) -> &'a CrateDebugContext<'ll, 'tcx> {
cx.dbg_cx.as_ref().unwrap()
}
#[inline]
#[allow(non_snake_case)]
pub(crate) fn DIB<'a, 'll>(cx: &'a CodegenCx<'ll, '_>) -> &'a DIBuilder<'ll> {
cx.dbg_cx.as_ref().unwrap().builder
}
pub(crate) fn get_namespace_for_item<'ll, 'tcx>(
cx: &CodegenCx<'ll, 'tcx>,
def_id: DefId,
) -> &'ll DIScope {
item_namespace(
cx,
cx.tcx
.parent(def_id)
.expect("get_namespace_for_item: missing parent?"),
)
}