pub fn create_global_var_metadata(cx: &CrateContext,
                                  node_id: ast::NodeId,
                                  global: ValueRef) {
    if cx.dbg_cx().is_none() {
        return;
    }

    // Don't create debuginfo for globals inlined from other crates. The other
    // crate should already contain debuginfo for it. More importantly, the
    // global might not even exist in un-inlined form anywhere which would lead
    // to a linker errors.
    if cx.external_srcs().borrow().contains_key(&node_id) {
        return;
    }

    let node_def_id = cx.tcx().map.local_def_id(node_id);
    let (var_scope, span) = get_namespace_and_span_for_item(cx, node_def_id);

    let (file_metadata, line_number) = if span != syntax_pos::DUMMY_SP {
        let loc = span_start(cx, span);
        (file_metadata(cx, &loc.file.name, &loc.file.abs_path), loc.line as c_uint)
    } else {
        (NO_FILE_METADATA, UNKNOWN_LINE_NUMBER)
    };

    let is_local_to_unit = is_node_local_to_unit(cx, node_id);
    let variable_type = cx.tcx().node_id_to_type(node_id);
    let type_metadata = type_metadata(cx, variable_type, span);
    let var_name = cx.tcx().item_name(node_def_id).to_string();
    let linkage_name = mangled_name_of_item(cx, node_def_id, "");

    let var_name = CString::new(var_name).unwrap();
    let linkage_name = CString::new(linkage_name).unwrap();
    unsafe {
        llvm::LLVMDIBuilderCreateStaticVariable(DIB(cx),
                                                var_scope,
                                                var_name.as_ptr(),
                                                linkage_name.as_ptr(),
                                                file_metadata,
                                                line_number,
                                                type_metadata,
                                                is_local_to_unit,
                                                global,
                                                ptr::null_mut());
    }
}
/// Creates debug information for the given global variable.
///
/// Adds the created metadata nodes directly to the crate's IR.
Creates debug information for the given global variable.
Adds the created metadata nodes directly to the crate's IR.
Creates debug information for the given global variable . Adds the created metadata nodes directly to the crate ' s IR .
pub fn create_global_var_metadata(cx: &CrateContext,
                                  node_id: ast::NodeId,
                                  global: ValueRef) {
    if cx.dbg_cx().is_none() {
        return;
    }
    // Don't create debuginfo for globals inlined from other crates. The other
    // crate should already contain debuginfo for it. More importantly, the
    // global might not even exist in un-inlined form anywhere which would lead
    // to a linker errors.
    if cx.external_srcs().borrow().contains_key(&node_id) {
        return;
    }
    let node_def_id = cx.tcx().map.local_def_id(node_id);
    let (var_scope, span) = get_namespace_and_span_for_item(cx, node_def_id);
    let (file_metadata, line_number) = if span != syntax_pos::DUMMY_SP {
        let loc = span_start(cx, span);
        (file_metadata(cx, &loc.file.name, &loc.file.abs_path), loc.line as c_uint)
    } else {
        (NO_FILE_METADATA, UNKNOWN_LINE_NUMBER)
    };
    let is_local_to_unit = is_node_local_to_unit(cx, node_id);
    let variable_type = cx.tcx().node_id_to_type(node_id);
    let type_metadata = type_metadata(cx, variable_type, span);
    let var_name = cx.tcx().item_name(node_def_id).to_string();
    let linkage_name = mangled_name_of_item(cx, node_def_id, "");
    let var_name = CString::new(var_name).unwrap();
    let linkage_name = CString::new(linkage_name).unwrap();
    unsafe {
        llvm::LLVMDIBuilderCreateStaticVariable(DIB(cx),
                                                var_scope,
                                                var_name.as_ptr(),
                                                linkage_name.as_ptr(),
                                                file_metadata,
                                                line_number,
                                                type_metadata,
                                                is_local_to_unit,
                                                global,
                                                ptr::null_mut());
    }
}
pub fn create_global_var_metadata ( cx : & CrateContext , node_id : ast :: NodeId , global : ValueRef ) { if cx . dbg_cx ( ) . is_none ( ) { return ; } // Don't create debuginfo for globals inlined from other crates. The other // crate should already contain debuginfo for it. More importantly, the // global might not even exist in un-inlined form anywhere which would lead // to a linker errors. if cx . external_srcs ( ) . borrow ( ) . contains_key ( & node_id ) { return ; } let node_def_id = cx . tcx ( ) . map . local_def_id ( node_id ) ; let ( var_scope , span ) = get_namespace_and_span_for_item ( cx , node_def_id ) ; let ( file_metadata , line_number ) = if span != syntax_pos :: DUMMY_SP { let loc = span_start ( cx , span ) ; ( file_metadata ( cx , & loc . file . name , & loc . file . abs_path ) , loc . line as c_uint ) } else { ( NO_FILE_METADATA , UNKNOWN_LINE_NUMBER ) } ; let is_local_to_unit = is_node_local_to_unit ( cx , node_id ) ; let variable_type = cx . tcx ( ) . node_id_to_type ( node_id ) ; let type_metadata = type_metadata ( cx , variable_type , span ) ; let var_name = cx . tcx ( ) . item_name ( node_def_id ) . to_string ( ) ; let linkage_name = mangled_name_of_item ( cx , node_def_id , " " ) ; let var_name = CString :: new ( var_name ) . unwrap ( ) ; let linkage_name = CString :: new ( linkage_name ) . unwrap ( ) ; unsafe { llvm :: LLVMDIBuilderCreateStaticVariable ( DIB ( cx ) , var_scope , var_name . as_ptr ( ) , linkage_name . as_ptr ( ) , file_metadata , line_number , type_metadata , is_local_to_unit , global , ptr :: null_mut ( ) ) ; } }
Creates debug information for the given global variable.
Creates debug information for the given global variable .
cx
&CrateContext
node_id
ast::NodeId
global
ValueRef
cx
&CrateContext
node_id
ast::NodeId
global
ValueRef