3 use super::utils
::{debug_context, DIB}
;
4 use rustc_middle
::ty
::{self, Instance}
;
6 use crate::common
::CodegenCx
;
8 use crate::llvm
::debuginfo
::DIScope
;
9 use rustc_hir
::def_id
::DefId
;
10 use rustc_hir
::definitions
::DefPathData
;
12 pub fn mangled_name_of_instance
<'a
, 'tcx
>(
13 cx
: &CodegenCx
<'a
, 'tcx
>,
14 instance
: Instance
<'tcx
>,
17 tcx
.symbol_name(instance
)
20 pub fn item_namespace(cx
: &CodegenCx
<'ll
, '_
>, def_id
: DefId
) -> &'ll DIScope
{
21 if let Some(&scope
) = debug_context(cx
).namespace_map
.borrow().get(&def_id
) {
25 let def_key
= cx
.tcx
.def_key(def_id
);
26 let parent_scope
= def_key
28 .map(|parent
| item_namespace(cx
, DefId { krate: def_id.krate, index: parent }
));
30 let namespace_name
= match def_key
.disambiguated_data
.data
{
31 DefPathData
::CrateRoot
=> cx
.tcx
.crate_name(def_id
.krate
),
32 data
=> data
.as_symbol(),
34 let namespace_name
= namespace_name
.as_str();
37 llvm
::LLVMRustDIBuilderCreateNameSpace(
40 namespace_name
.as_ptr().cast(),
42 false, // ExportSymbols (only relevant for C++ anonymous namespaces)
46 debug_context(cx
).namespace_map
.borrow_mut().insert(def_id
, scope
);