MCPcopy Create free account
hub / github.com/Rust-API/Rust-API-Bypass-Checker / for_function

Method for_function

src/analysis/memory/constant_value.rs:97–121  ·  view source on GitHub ↗

Returns a constant value that is a reference to a function

(
        function_id: usize,
        def_id: DefId,
        generic_args: Option<GenericArgsRef<'tcx>>,
        tcx: TyCtxt<'tcx>,
        known_names_cache: &mut KnownNamesCache,
    )

Source from the content-addressed store, hash-verified

95impl ConstantValue {
96 /// Returns a constant value that is a reference to a function
97 pub fn for_function<'a, 'tcx, 'compiler>(
98 function_id: usize,
99 def_id: DefId,
100 generic_args: Option<GenericArgsRef<'tcx>>,
101 tcx: TyCtxt<'tcx>,
102 known_names_cache: &mut KnownNamesCache,
103 ) -> ConstantValue {
104 let function_name = utils::summary_key_str(tcx, def_id).to_string();
105 let generic_arguments = if let Some(generic_args) = generic_args {
106 generic_args.types().map(|t| t.kind().into()).collect()
107 } else {
108 vec![]
109 };
110
111 let known_name = known_names_cache.get(tcx, def_id);
112 info!("The direct string of the function name is: {}",function_name);
113 info!("The known_name of the function: {:?}", known_name);
114 ConstantValue::Function(Rc::new(FunctionReference {
115 def_id: Some(def_id),
116 function_id: Some(function_id),
117 generic_arguments,
118 known_name,
119 function_name: Rc::new(function_name.clone()),
120 }))
121 }
122
123 pub fn is_top(&self) -> bool {
124 matches!(self, ConstantValue::Top)

Callers

nothing calls this directly

Calls 2

summary_key_strFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected