-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: derive data dependency graph from function body
- Loading branch information
Showing
9 changed files
with
450 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
untrusted_value_taint_checker/src/analysis/hir/crate_function_finder.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use rustc_middle::ty; | ||
use rustc_hir::intravisit::Visitor as HirVisitor; | ||
|
||
|
||
pub struct FunctionInfo { | ||
pub function_name: String, | ||
pub body_id: rustc_hir::BodyId, | ||
pub local_def_id: rustc_hir::def_id::LocalDefId, | ||
pub span: rustc_span::Span, | ||
} | ||
|
||
pub struct CrateFunctionFinder<'tcx> { | ||
tcx: ty::TyCtxt<'tcx>, | ||
internal_functions: Vec<FunctionInfo>, | ||
} | ||
|
||
impl<'tcx> CrateFunctionFinder<'tcx> { | ||
pub fn new(tcx: ty::TyCtxt<'tcx>) -> Self { | ||
Self { | ||
tcx, | ||
internal_functions: Vec::default(), | ||
} | ||
} | ||
pub fn results(self) -> Vec<FunctionInfo> { | ||
self.internal_functions | ||
} | ||
} | ||
|
||
impl<'v, 'tcx> HirVisitor<'v> for CrateFunctionFinder<'tcx> { | ||
fn visit_fn( | ||
&mut self, | ||
_kind: rustc_hir::intravisit::FnKind<'v>, | ||
_decl: &'v rustc_hir::FnDecl<'v>, | ||
body_id: rustc_hir::BodyId, | ||
span: rustc_span::Span, | ||
local_def_id: rustc_hir::def_id::LocalDefId, | ||
) -> Self::Result { | ||
let function_name = self.tcx.def_path_str(local_def_id); | ||
self.internal_functions.push(FunctionInfo { | ||
body_id, | ||
span, | ||
local_def_id, | ||
function_name, | ||
}); | ||
} | ||
} |
Oops, something went wrong.