rapx/cli/analyze.rs
1use clap::{Args, Subcommand, ValueEnum};
2use std::path::PathBuf;
3
4#[derive(Debug, Clone, Args)]
5pub struct AdgArgs {
6 #[arg(long)]
7 /// Include private APIs in the API graph. By default, only public APIs are included.
8 pub include_private: bool,
9 #[arg(long)]
10 /// Include unsafe APIs in API graph. By default, only safe APIs are included.
11 pub include_unsafe: bool,
12 /// Include Drop trait in API graph. By default, Drop is not included.
13 #[arg(long)]
14 pub include_drop: bool,
15 /// The maximum number of iterations to search for generic APIs.
16 #[arg(long, default_value_t = 10)]
17 pub max_iteration: usize,
18 /// The path to dump the API graph to. Output format is decided by extension suffix.
19 /// default PATH = `./api_graph.dot`.
20 #[arg(long, default_missing_value = "./api_graph.dot", value_name = "PATH")]
21 pub dump: Option<PathBuf>,
22}
23
24#[derive(Debug, Clone, Copy, ValueEnum)]
25pub enum AliasStrategyKind {
26 /// meet-over-paths (default)
27 Mop,
28 /// maximum-fixed-point
29 Mfp,
30}
31
32// use command string to automatically generate help messages
33#[derive(Debug, Clone, Subcommand)]
34pub enum AnalysisKind {
35 /// perform alias analysis (meet-over-paths by default)
36 Alias {
37 /// specify the alias analysis strategy
38 #[arg(short, long, default_value = "mop")]
39 strategy: AliasStrategyKind,
40 },
41 /// generate API dependency graphs
42 Adg(AdgArgs),
43 /// generate unsafety propagation graphs for each module
44 Upg,
45 /// generate unsafety propagation graphs for each module of the Rust standard library
46 UpgStd,
47 /// generate callgraphs
48 Callgraph,
49 /// generate dataflow graphs
50 Dataflow {
51 /// print debug information during dataflow analysis
52 #[arg(short, long)]
53 debug: bool,
54 },
55 /// analyze if the type holds a piece of memory on heap
56 OwnedHeap,
57 /// extract path constraints
58 Pathcond,
59 /// perform range analysis
60 Range {
61 /// print debug information during range analysis
62 #[arg(short, long)]
63 debug: bool,
64 },
65 /// print basic information of the crate, e.g., the number of APIs
66 Scan,
67 /// print the SSA form of the crate
68 Ssa,
69 /// print the MIR of the crate
70 Mir,
71 /// print the MIR of the crate in dot format
72 DotMir,
73}