3 use super::{CrateDebugContext};
4 use super::namespace::item_namespace;
6 use rustc::hir::def_id::DefId;
7 use rustc::ty::DefIdTree;
10 use crate::llvm::debuginfo::{DIScope, DIBuilder, DIDescriptor, DIArray};
11 use crate::common::{CodegenCx};
12 use rustc_codegen_ssa::traits::*;
16 pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool
18 // The is_local_to_unit flag indicates whether a function is local to the
19 // current compilation unit (i.e., if it is *static* in the C-sense). The
20 // *reachable* set should provide a good approximation of this, as it
21 // contains everything that might leak out of the current crate (by being
22 // externally visible or by being inlined into something externally
23 // visible). It might better to use the `exported_items` set from
24 // `driver::CrateAnalysis` in the future, but (atm) this set is not
25 // available in the codegen pass.
26 !cx.tcx.is_reachable_non_generic(def_id)
29 #[allow(non_snake_case)]
30 pub fn create_DIArray(
31 builder: &DIBuilder<'ll>,
32 arr: &[Option<&'ll DIDescriptor>],
35 llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32)
39 /// Returns syntax_pos::Loc corresponding to the beginning of the span
40 pub fn span_start(cx: &CodegenCx<'_, '_>, span: Span) -> syntax_pos::Loc {
41 cx.sess().source_map().lookup_char_pos(span.lo())
45 pub fn debug_context(cx: &'a CodegenCx<'ll, 'tcx>) -> &'a CrateDebugContext<'ll, 'tcx> {
46 cx.dbg_cx.as_ref().unwrap()
50 #[allow(non_snake_case)]
51 pub fn DIB(cx: &'a CodegenCx<'ll, '_>) -> &'a DIBuilder<'ll> {
52 cx.dbg_cx.as_ref().unwrap().builder
55 pub fn get_namespace_for_item(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
56 item_namespace(cx, cx.tcx.parent(def_id)
57 .expect("get_namespace_for_item: missing parent?"))