pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                                node_id: ast::NodeId,
                                                env_pointer: ValueRef,
                                                env_index: usize,
                                                captured_by_ref: bool,
                                                span: Span) {
    if bcx.unreachable.get() ||
       fn_should_be_ignored(bcx.fcx) ||
       bcx.sess().opts.debuginfo != FullDebugInfo {
        return;
    }

    let cx = bcx.ccx();

    let ast_item = cx.tcx().map.find(node_id);

    let variable_name = match ast_item {
        None => {
            span_bug!(span, "debuginfo::create_captured_var_metadata: node not found");
        }
        Some(hir_map::NodeLocal(pat)) => {
            match pat.node {
                PatKind::Binding(_, ref path1, _) => {
                    path1.node
                }
                _ => {
                    span_bug!(span,
                              "debuginfo::create_captured_var_metadata() - \
                               Captured var-id refers to unexpected \
                               hir_map variant: {:?}",
                              ast_item);
                }
            }
        }
        _ => {
            span_bug!(span,
                      "debuginfo::create_captured_var_metadata() - \
                       Captured var-id refers to unexpected \
                       hir_map variant: {:?}",
                      ast_item);
        }
    };

    let variable_type = common::node_id_type(bcx, node_id);
    let scope_metadata = bcx.fcx.debug_context.get_ref(span).fn_metadata;

    // env_pointer is the alloca containing the pointer to the environment,
    // so it's type is **EnvironmentType. In order to find out the type of
    // the environment we have to "dereference" two times.
    let llvm_env_data_type = common::val_ty(env_pointer).element_type()
                                                        .element_type();
    let byte_offset_of_var_in_env = machine::llelement_offset(cx,
                                                              llvm_env_data_type,
                                                              env_index);

    let address_operations = unsafe {
        [llvm::LLVMDIBuilderCreateOpDeref(),
         llvm::LLVMDIBuilderCreateOpPlus(),
         byte_offset_of_var_in_env as i64,
         llvm::LLVMDIBuilderCreateOpDeref()]
    };

    let address_op_count = if captured_by_ref {
        address_operations.len()
    } else {
        address_operations.len() - 1
    };

    let variable_access = VariableAccess::IndirectVariable {
        alloca: env_pointer,
        address_operations: &address_operations[..address_op_count]
    };

    declare_local(bcx,
                  variable_name,
                  variable_type,
                  scope_metadata,
                  variable_access,
                  VariableKind::CapturedVariable,
                  span);
}
/// Creates debug information for a variable captured in a closure.
///
/// Adds the created metadata nodes directly to the crate's IR.
Creates debug information for a variable captured in a closure.
Adds the created metadata nodes directly to the crate's IR.
Creates debug information for a variable captured in a closure . Adds the created metadata nodes directly to the crate ' s IR .
pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                                node_id: ast::NodeId,
                                                env_pointer: ValueRef,
                                                env_index: usize,
                                                captured_by_ref: bool,
                                                span: Span) {
    if bcx.unreachable.get() ||
       fn_should_be_ignored(bcx.fcx) ||
       bcx.sess().opts.debuginfo != FullDebugInfo {
        return;
    }
    let cx = bcx.ccx();
    let ast_item = cx.tcx().map.find(node_id);
    let variable_name = match ast_item {
        None => {
            span_bug!(span, "debuginfo::create_captured_var_metadata: node not found");
        }
        Some(hir_map::NodeLocal(pat)) => {
            match pat.node {
                PatKind::Binding(_, ref path1, _) => {
                    path1.node
                }
                _ => {
                    span_bug!(span,
                              "debuginfo::create_captured_var_metadata() - \
                               Captured var-id refers to unexpected \
                               hir_map variant: {:?}",
                              ast_item);
                }
            }
        }
        _ => {
            span_bug!(span,
                      "debuginfo::create_captured_var_metadata() - \
                       Captured var-id refers to unexpected \
                       hir_map variant: {:?}",
                      ast_item);
        }
    };
    let variable_type = common::node_id_type(bcx, node_id);
    let scope_metadata = bcx.fcx.debug_context.get_ref(span).fn_metadata;
    // env_pointer is the alloca containing the pointer to the environment,
    // so it's type is **EnvironmentType. In order to find out the type of
    // the environment we have to "dereference" two times.
    let llvm_env_data_type = common::val_ty(env_pointer).element_type()
                                                        .element_type();
    let byte_offset_of_var_in_env = machine::llelement_offset(cx,
                                                              llvm_env_data_type,
                                                              env_index);
    let address_operations = unsafe {
        [llvm::LLVMDIBuilderCreateOpDeref(),
         llvm::LLVMDIBuilderCreateOpPlus(),
         byte_offset_of_var_in_env as i64,
         llvm::LLVMDIBuilderCreateOpDeref()]
    };
    let address_op_count = if captured_by_ref {
        address_operations.len()
    } else {
        address_operations.len() - 1
    };
    let variable_access = VariableAccess::IndirectVariable {
        alloca: env_pointer,
        address_operations: &address_operations[..address_op_count]
    };
    declare_local(bcx,
                  variable_name,
                  variable_type,
                  scope_metadata,
                  variable_access,
                  VariableKind::CapturedVariable,
                  span);
}
pub fn create_captured_var_metadata < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > , node_id : ast :: NodeId , env_pointer : ValueRef , env_index : usize , captured_by_ref : bool , span : Span ) { if bcx . unreachable . get ( ) || fn_should_be_ignored ( bcx . fcx ) || bcx . sess ( ) . opts . debuginfo != FullDebugInfo { return ; } let cx = bcx . ccx ( ) ; let ast_item = cx . tcx ( ) . map . find ( node_id ) ; let variable_name = match ast_item { None => { span_bug ! ( span " " ) ; } Some ( hir_map :: NodeLocal ( pat ) ) => { match pat . node { PatKind :: Binding ( _ , ref path1 , _ ) => { path1 . node } _ => { span_bug ! ( span " \
 \
 " ast_item ) ; } } } _ => { span_bug ! ( span " \
 \
 " ast_item ) ; } } ; let variable_type = common :: node_id_type ( bcx , node_id ) ; let scope_metadata = bcx . fcx . debug_context . get_ref ( span ) . fn_metadata ; // env_pointer is the alloca containing the pointer to the environment, // so it's type is **EnvironmentType. In order to find out the type of // the environment we have to "dereference" two times. let llvm_env_data_type = common :: val_ty ( env_pointer ) . element_type ( ) . element_type ( ) ; let byte_offset_of_var_in_env = machine :: llelement_offset ( cx , llvm_env_data_type , env_index ) ; let address_operations = unsafe { [ llvm :: LLVMDIBuilderCreateOpDeref ( ) , llvm :: LLVMDIBuilderCreateOpPlus ( ) , byte_offset_of_var_in_env as i64 , llvm :: LLVMDIBuilderCreateOpDeref ( ) ] } ; let address_op_count = if captured_by_ref { address_operations . len ( ) } else { address_operations . len ( ) - 1 } ; let variable_access = VariableAccess :: IndirectVariable { alloca : env_pointer , address_operations : & address_operations [ .. address_op_count ] } ; declare_local ( bcx , variable_name , variable_type , scope_metadata , variable_access , VariableKind :: CapturedVariable , span ) ; }
Creates debug information for a variable captured in a closure.
Creates debug information for a variable captured in a closure .
bcx
Block<'blk, 'tcx>
node_id
ast::NodeId
env_pointer
ValueRef
env_index
usize
captured_by_ref
bool
span
Span
bcx
Block<'blk, 'tcx>
node_id
ast::NodeId
env_pointer
ValueRef
env_index
usize
captured_by_ref
bool
span
Span