From 357d1c9ab96a35c2970c832de23e2270067c1476 Mon Sep 17 00:00:00 2001 From: brock elmore Date: Fri, 8 Dec 2023 13:21:01 -0800 Subject: [PATCH] lint --- crates/analyzers/src/bounds.rs | 11 ++- crates/analyzers/src/func_analyzer/mod.rs | 11 +-- .../src/func_analyzer/report_display.rs | 13 +-- crates/analyzers/src/lib.rs | 2 +- crates/analyzers/src/var_analyzer/mod.rs | 7 +- .../src/var_analyzer/report_display.rs | 13 +-- crates/cli/src/main.rs | 97 +++++++++---------- crates/graph/src/graph_elements.rs | 30 +++--- crates/graph/src/lib.rs | 5 +- crates/graph/src/nodes/block.rs | 2 +- crates/graph/src/nodes/builtin.rs | 27 ++++-- crates/graph/src/nodes/concrete.rs | 16 +-- crates/graph/src/nodes/context/context_tys.rs | 4 +- crates/graph/src/nodes/context/expr_ret.rs | 3 +- crates/graph/src/nodes/context/mod.rs | 9 +- crates/graph/src/nodes/context/node.rs | 12 ++- crates/graph/src/nodes/context/querying.rs | 10 +- crates/graph/src/nodes/context/solving.rs | 29 ++++-- crates/graph/src/nodes/context/typing.rs | 14 +-- crates/graph/src/nodes/context/underlying.rs | 12 +-- crates/graph/src/nodes/context/var/mod.rs | 4 +- crates/graph/src/nodes/context/var/node.rs | 18 ++-- crates/graph/src/nodes/context/var/ranging.rs | 8 +- crates/graph/src/nodes/context/var/typing.rs | 24 +++-- .../graph/src/nodes/context/var/underlying.rs | 16 ++- .../graph/src/nodes/context/var/versioning.rs | 8 +- crates/graph/src/nodes/context/variables.rs | 22 +++-- crates/graph/src/nodes/context/versioning.rs | 19 ++-- crates/graph/src/nodes/contract_ty.rs | 16 ++- crates/graph/src/nodes/enum_ty.rs | 2 +- crates/graph/src/nodes/func_ty.rs | 26 +++-- crates/graph/src/nodes/mod.rs | 2 +- crates/graph/src/nodes/msg.rs | 7 +- crates/graph/src/nodes/struct_ty.rs | 13 ++- crates/graph/src/nodes/var_ty.rs | 15 ++- crates/graph/src/range/elem/concrete.rs | 7 +- crates/graph/src/range/elem/elem_enum.rs | 21 +--- crates/graph/src/range/elem/elem_trait.rs | 14 ++- crates/graph/src/range/elem/expr.rs | 15 +-- crates/graph/src/range/elem/map_or_array.rs | 10 +- crates/graph/src/range/elem/mod.rs | 5 +- crates/graph/src/range/elem/reference.rs | 11 ++- crates/graph/src/range/exec/add.rs | 2 +- crates/graph/src/range/exec/bitwise.rs | 2 +- crates/graph/src/range/exec/cast.rs | 2 +- crates/graph/src/range/exec/concat.rs | 2 +- crates/graph/src/range/exec/div.rs | 2 +- crates/graph/src/range/exec/exec_op.rs | 8 +- crates/graph/src/range/exec/exp.rs | 2 +- crates/graph/src/range/exec/logical.rs | 2 +- crates/graph/src/range/exec/max.rs | 2 +- crates/graph/src/range/exec/min.rs | 2 +- crates/graph/src/range/exec/mod.rs | 2 +- crates/graph/src/range/exec/modulo.rs | 2 +- crates/graph/src/range/exec/mul.rs | 4 +- crates/graph/src/range/exec/ord.rs | 4 +- crates/graph/src/range/exec/shift.rs | 2 +- crates/graph/src/range/exec/sub.rs | 2 +- crates/graph/src/range/exec_traits.rs | 10 +- crates/graph/src/range/mod.rs | 4 +- crates/graph/src/range/range_string.rs | 3 +- crates/graph/src/range/range_trait.rs | 18 ++-- crates/graph/src/range/solc_range.rs | 13 ++- crates/graph/src/solvers/atoms.rs | 21 ++-- crates/graph/src/solvers/brute.rs | 14 +-- crates/graph/src/solvers/dl.rs | 23 ++--- crates/graph/src/solvers/mod.rs | 4 +- crates/graph/src/var_type.rs | 26 +++-- crates/pyrometer/src/analyzer.rs | 24 +++-- crates/pyrometer/src/analyzer_backend.rs | 27 ++---- crates/pyrometer/src/builtin_fns.rs | 4 +- crates/pyrometer/src/graph_backend.rs | 23 ++--- crates/pyrometer/src/lib.rs | 4 +- crates/pyrometer/tests/helpers.rs | 6 +- crates/queries/src/lib.rs | 2 +- crates/shared/src/analyzer_like.rs | 11 +-- crates/shared/src/graph_like.rs | 21 ++-- crates/shared/src/lib.rs | 6 +- crates/shared/src/search.rs | 93 +++++++++++++++--- crates/solc-expressions/src/array.rs | 11 +-- crates/solc-expressions/src/bin_op.rs | 15 +-- crates/solc-expressions/src/cmp.rs | 11 ++- crates/solc-expressions/src/cond_op.rs | 9 +- .../src/context_builder/mod.rs | 18 ++-- crates/solc-expressions/src/env.rs | 8 +- .../src/func_call/internal_call.rs | 8 +- .../src/func_call/intrinsic_call.rs | 16 +-- crates/solc-expressions/src/func_call/mod.rs | 20 ++-- .../src/func_call/modifier.rs | 10 +- .../src/func_call/namespaced_call.rs | 8 +- crates/solc-expressions/src/lib.rs | 6 +- crates/solc-expressions/src/list.rs | 8 +- crates/solc-expressions/src/literal.rs | 10 +- crates/solc-expressions/src/loops.rs | 17 ++-- .../solc-expressions/src/member_access/mod.rs | 11 ++- crates/solc-expressions/src/require.rs | 12 ++- crates/solc-expressions/src/variable.rs | 8 +- crates/solc-expressions/src/yul/mod.rs | 6 +- .../solc-expressions/src/yul/yul_cond_op.rs | 22 +++-- crates/solc-expressions/src/yul/yul_funcs.rs | 16 +-- 100 files changed, 701 insertions(+), 558 deletions(-) diff --git a/crates/analyzers/src/bounds.rs b/crates/analyzers/src/bounds.rs index de485d00..1044558c 100644 --- a/crates/analyzers/src/bounds.rs +++ b/crates/analyzers/src/bounds.rs @@ -1,9 +1,7 @@ -use crate::{LocSpan, LocStrSpan, ReportConfig, VarBoundAnalysis, FunctionVarsBoundAnalysis}; +use crate::{FunctionVarsBoundAnalysis, LocSpan, LocStrSpan, ReportConfig, VarBoundAnalysis}; use graph::{ - GraphBackend, Range, RangeEval, SolcRange, - range_string::ToRangeString, - nodes::ContextNode, + nodes::ContextNode, range_string::ToRangeString, GraphBackend, Range, RangeEval, SolcRange, }; use ariadne::{Color, Fmt, Label, Span}; @@ -106,7 +104,10 @@ impl OrderedAnalysis { Self { analyses } } - pub fn from_func_analysis(fvba: FunctionVarsBoundAnalysis, analyzer: &impl GraphBackend) -> Self { + pub fn from_func_analysis( + fvba: FunctionVarsBoundAnalysis, + analyzer: &impl GraphBackend, + ) -> Self { let mut analyses = Self::default(); fvba.vars_by_ctx.iter().for_each(|(_ctx, bas)| { bas.iter().for_each(|ba| { diff --git a/crates/analyzers/src/func_analyzer/mod.rs b/crates/analyzers/src/func_analyzer/mod.rs index 560954a8..a5161b29 100644 --- a/crates/analyzers/src/func_analyzer/mod.rs +++ b/crates/analyzers/src/func_analyzer/mod.rs @@ -1,19 +1,18 @@ use crate::{ - bounds::range_parts, - VarBoundAnalysis, VarBoundAnalyzer, LocStrSpan, ReportConfig, - ReportKind, ReportDisplay, + bounds::range_parts, LocStrSpan, ReportConfig, ReportDisplay, ReportKind, VarBoundAnalysis, + VarBoundAnalyzer, }; use graph::{ - GraphBackend, AnalyzerBackend, nodes::{ContextNode, KilledKind}, range_string::ToRangeString, - solvers::{SolverAtom, Atomize} + solvers::{Atomize, SolverAtom}, + AnalyzerBackend, GraphBackend, }; use shared::Search; use ariadne::{Color, Config, Fmt, Label, Report, Span}; -use solang_parser::pt::{CodeLocation}; +use solang_parser::pt::CodeLocation; use std::collections::{BTreeMap, BTreeSet}; mod report_display; diff --git a/crates/analyzers/src/func_analyzer/report_display.rs b/crates/analyzers/src/func_analyzer/report_display.rs index 4df1c53e..9bead892 100644 --- a/crates/analyzers/src/func_analyzer/report_display.rs +++ b/crates/analyzers/src/func_analyzer/report_display.rs @@ -1,15 +1,8 @@ -use crate::{ - LocStrSpan, - ReportKind, - FunctionVarsBoundAnalysis, - ReportDisplay -}; +use crate::{FunctionVarsBoundAnalysis, LocStrSpan, ReportDisplay, ReportKind}; -use graph::{ - GraphBackend, -}; +use graph::GraphBackend; -use ariadne::{Color, Config, Fmt, Label, Report, Span, Cache}; +use ariadne::{Cache, Color, Config, Fmt, Label, Report, Span}; use std::collections::BTreeMap; diff --git a/crates/analyzers/src/lib.rs b/crates/analyzers/src/lib.rs index ed1d00e4..a2fbc7fe 100644 --- a/crates/analyzers/src/lib.rs +++ b/crates/analyzers/src/lib.rs @@ -1,7 +1,7 @@ pub mod bounds; -use graph::{GraphBackend, AnalyzerBackend}; use ariadne::{Cache, Label, Report, ReportKind, Span}; +use graph::{AnalyzerBackend, GraphBackend}; use shared::Search; use solang_parser::pt::Loc; use std::collections::BTreeMap; diff --git a/crates/analyzers/src/var_analyzer/mod.rs b/crates/analyzers/src/var_analyzer/mod.rs index 5141ce5a..09e0fdd4 100644 --- a/crates/analyzers/src/var_analyzer/mod.rs +++ b/crates/analyzers/src/var_analyzer/mod.rs @@ -1,11 +1,11 @@ use crate::{ bounds::{range_parts, AnalysisItem, RangePart}, - LocStrSpan, ReportConfig + LocStrSpan, ReportConfig, }; use graph::{ - GraphBackend, AnalyzerBackend, Range, SolcRange, - nodes::{ContextVarNode, ContextNode, KilledKind}, + nodes::{ContextNode, ContextVarNode, KilledKind}, + AnalyzerBackend, GraphBackend, Range, SolcRange, }; use shared::Search; @@ -15,7 +15,6 @@ use solang_parser::pt::{CodeLocation, StorageLocation}; use std::collections::BTreeMap; mod report_display; -pub use report_display::*; #[derive(PartialOrd, Eq, PartialEq, Ord, Clone, Debug)] pub struct CtxSwitch { diff --git a/crates/analyzers/src/var_analyzer/report_display.rs b/crates/analyzers/src/var_analyzer/report_display.rs index cf826e57..e53b7e10 100644 --- a/crates/analyzers/src/var_analyzer/report_display.rs +++ b/crates/analyzers/src/var_analyzer/report_display.rs @@ -1,16 +1,11 @@ use crate::{ - LocStrSpan, - ReportKind, - ReportDisplay, - VarBoundAnalysis, - bounds::{range_parts, AnalysisItem} + bounds::{range_parts, AnalysisItem}, + LocStrSpan, ReportDisplay, ReportKind, VarBoundAnalysis, }; -use graph::{ - GraphBackend, -}; +use graph::GraphBackend; -use ariadne::{Color, Config, Fmt, Label, Report, Span, Cache}; +use ariadne::{Cache, Color, Config, Fmt, Label, Report, Span}; impl ReportDisplay for VarBoundAnalysis { fn report_kind(&self) -> ReportKind { diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 9d6ae5ee..12774ae9 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -1,27 +1,24 @@ - -use shared::GraphDot; -use analyzers::{ - ReportDisplay, FunctionVarsBoundAnalyzer, ReportConfig -}; +use analyzers::{FunctionVarsBoundAnalyzer, ReportConfig, ReportDisplay}; use graph::{ - Edge, Range, - nodes::{ContractNode, FunctionNode, Concrete}, elem::{Elem, RangeElem}, - solvers::{SolcSolver, AtomicSolveStatus, BruteBinSearchSolver}, + nodes::{Concrete, ContractNode, FunctionNode}, + solvers::{AtomicSolveStatus, BruteBinSearchSolver, SolcSolver}, + Edge, Range, }; -use pyrometer::{Root, SourcePath, Analyzer}; -use shared::{Search}; +use pyrometer::{Analyzer, Root, SourcePath}; +use shared::GraphDot; +use shared::Search; use ariadne::sources; use clap::{ArgAction, Parser, ValueHint}; -use tracing_subscriber::prelude::*; use ethers_core::types::I256; +use tracing_subscriber::prelude::*; use std::{ collections::{BTreeMap, HashMap}, - path::PathBuf, env::{self}, - fs + fs, + path::PathBuf, }; #[derive(Parser, Debug)] @@ -279,46 +276,46 @@ fn main() { // TODO: clean this up to actually run on all contracts // if args.swq { - // println!("Creating SWQ graph for {} contracts", all_contracts.len()); - // let mut cond_graph: Option = None; - // for i in 0..all_contracts.len() { - // match (&mut cond_graph, analyzer.func_query(all_contracts[i])) { - // (Some(ref mut existing), Some(new)) => { - // existing.append_graph(new); - // } - // (None, Some(new)) => { - // cond_graph = Some(new); - // } - // _ => {} - // } - // } + // println!("Creating SWQ graph for {} contracts", all_contracts.len()); + // let mut cond_graph: Option = None; + // for i in 0..all_contracts.len() { + // match (&mut cond_graph, analyzer.func_query(all_contracts[i])) { + // (Some(ref mut existing), Some(new)) => { + // existing.append_graph(new); + // } + // (None, Some(new)) => { + // cond_graph = Some(new); + // } + // _ => {} + // } + // } - // if let Some(graph) = cond_graph { - // println!("{}", graph.dot_str()); - // graph.open_dot(); - // } else { - // println!("no graph"); - // } + // if let Some(graph) = cond_graph { + // println!("{}", graph.dot_str()); + // graph.open_dot(); + // } else { + // println!("no graph"); + // } // } else if args.swq_mermaid { - // println!("Creating SWQ graph for {} contracts", all_contracts.len()); - // let mut cond_graph: Option = None; - // for i in 0..all_contracts.len() { - // match (&mut cond_graph, analyzer.func_query(all_contracts[i])) { - // (Some(ref mut existing), Some(new)) => { - // existing.append_graph(new); - // } - // (None, Some(new)) => { - // cond_graph = Some(new); - // } - // _ => {} - // } - // } + // println!("Creating SWQ graph for {} contracts", all_contracts.len()); + // let mut cond_graph: Option = None; + // for i in 0..all_contracts.len() { + // match (&mut cond_graph, analyzer.func_query(all_contracts[i])) { + // (Some(ref mut existing), Some(new)) => { + // existing.append_graph(new); + // } + // (None, Some(new)) => { + // cond_graph = Some(new); + // } + // _ => {} + // } + // } - // if let Some(graph) = cond_graph { - // println!("{}", graph.mermaid_str()); - // } else { - // println!("no graph"); - // } + // if let Some(graph) = cond_graph { + // println!("{}", graph.mermaid_str()); + // } else { + // println!("no graph"); + // } // } else { let _t1 = std::time::Instant::now(); if args.contracts.is_empty() { diff --git a/crates/graph/src/graph_elements.rs b/crates/graph/src/graph_elements.rs index 9e0e99c4..73cd06ca 100644 --- a/crates/graph/src/graph_elements.rs +++ b/crates/graph/src/graph_elements.rs @@ -1,25 +1,24 @@ -use crate::{VarType, nodes::*}; +use crate::{nodes::*, VarType}; -use shared::{ NodeIdx, AnalyzerLike, GraphLike, Heirarchical}; +use shared::{AnalyzerLike, GraphLike, Heirarchical, NodeIdx}; use lazy_static::lazy_static; use solang_parser::pt::Identifier; use std::collections::HashMap; -pub trait GraphBackend: GraphLike< - Edge = Edge, - Node = Node, - -> {} -pub trait AnalyzerBackend: AnalyzerLike< - Builtin = Builtin, - MsgNode = MsgNode, - BlockNode = BlockNode, - FunctionParam = FunctionParam, - FunctionReturn = FunctionReturn, - Function = Function -> + GraphBackend {} +pub trait GraphBackend: GraphLike {} +pub trait AnalyzerBackend: + AnalyzerLike< + Builtin = Builtin, + MsgNode = MsgNode, + BlockNode = BlockNode, + FunctionParam = FunctionParam, + FunctionReturn = FunctionReturn, + Function = Function, + > + GraphBackend +{ +} pub trait AsDotStr { fn as_dot_str(&self, analyzer: &impl GraphBackend) -> String; @@ -373,4 +372,3 @@ pub enum ContextEdge { /// Unused Range, } - diff --git a/crates/graph/src/lib.rs b/crates/graph/src/lib.rs index 08006b17..2f35381d 100644 --- a/crates/graph/src/lib.rs +++ b/crates/graph/src/lib.rs @@ -1,11 +1,10 @@ mod graph_elements; -mod var_type; mod range; +mod var_type; pub mod nodes; pub mod solvers; - -pub use var_type::*; pub use graph_elements::*; pub use range::*; +pub use var_type::*; diff --git a/crates/graph/src/nodes/block.rs b/crates/graph/src/nodes/block.rs index 0e09c2f9..be71be01 100644 --- a/crates/graph/src/nodes/block.rs +++ b/crates/graph/src/nodes/block.rs @@ -1,4 +1,4 @@ -use crate::{GraphBackend, AsDotStr, Node, GraphError}; +use crate::{AsDotStr, GraphBackend, GraphError, Node}; use shared::NodeIdx; use ethers_core::types::{Address, H256, U256}; diff --git a/crates/graph/src/nodes/builtin.rs b/crates/graph/src/nodes/builtin.rs index 876fc282..0dde90b4 100644 --- a/crates/graph/src/nodes/builtin.rs +++ b/crates/graph/src/nodes/builtin.rs @@ -1,10 +1,10 @@ -use crate::{AnalyzerBackend, GraphBackend, SolcRange, VarType, Node, GraphError, nodes::Concrete}; +use crate::{nodes::Concrete, AnalyzerBackend, GraphBackend, GraphError, Node, SolcRange, VarType}; -use shared::NodeIdx; use crate::range::elem::*; +use shared::NodeIdx; -use solang_parser::pt::{Type, Expression, Loc}; -use ethers_core::types::{Address, H256, U256, I256}; +use ethers_core::types::{Address, H256, I256, U256}; +use solang_parser::pt::{Expression, Loc, Type}; /// A builtin node #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)] @@ -12,7 +12,10 @@ pub struct BuiltInNode(pub usize); impl BuiltInNode { /// Gets the underlying builtin from the graph - pub fn underlying<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a Builtin, GraphError> { + pub fn underlying<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> Result<&'a Builtin, GraphError> { match analyzer.node(*self) { Node::Builtin(b) => Ok(b), e => Err(GraphError::NodeConfusion(format!( @@ -85,7 +88,10 @@ impl BuiltInNode { } /// Returns whether the builtin is a sized array or bytes - pub fn maybe_array_size(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { + pub fn maybe_array_size( + &self, + analyzer: &impl GraphBackend, + ) -> Result, GraphError> { match self.underlying(analyzer)? { Builtin::SizedArray(s, _) => Ok(Some(*s)), Builtin::Bytes(s) => Ok(Some(U256::from(*s))), @@ -104,7 +110,10 @@ impl BuiltInNode { } /// Returns the zero range for this builtin type, i.e. uint256 -> [0, 0] - pub fn zero_range(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { + pub fn zero_range( + &self, + analyzer: &impl GraphBackend, + ) -> Result, GraphError> { Ok(self.underlying(analyzer)?.zero_range()) } } @@ -174,7 +183,7 @@ impl Builtin { } } - /// Possible types that this type could have been had a literal been parsed differently - i.e. a `1` + /// Possible types that this type could have been had a literal been parsed differently - i.e. a `1` /// could be uint8 to uint256. pub fn possible_builtins_from_ty_inf(&self) -> Vec { let mut builtins = vec![]; @@ -459,4 +468,4 @@ impl Builtin { ), } } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/concrete.rs b/crates/graph/src/nodes/concrete.rs index fb38973f..c8d4452d 100644 --- a/crates/graph/src/nodes/concrete.rs +++ b/crates/graph/src/nodes/concrete.rs @@ -1,4 +1,4 @@ -use crate::{AnalyzerBackend, GraphBackend, Node, GraphError, nodes::Builtin, VarType}; +use crate::{nodes::Builtin, AnalyzerBackend, GraphBackend, GraphError, Node, VarType}; use shared::NodeIdx; use ethers_core::types::{Address, H256, I256, U256}; @@ -9,7 +9,10 @@ pub struct ConcreteNode(pub usize); impl ConcreteNode { /// Gets the underlying node data for the [`Concrete`] - pub fn underlying<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a Concrete, GraphError> { + pub fn underlying<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> Result<&'a Concrete, GraphError> { match analyzer.node(*self) { Node::Concrete(c) => Ok(c), e => Err(GraphError::NodeConfusion(format!( @@ -49,7 +52,10 @@ impl ConcreteNode { } /// Returns the size of the array size if it is an array-like concrete - pub fn maybe_array_size(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { + pub fn maybe_array_size( + &self, + analyzer: &impl GraphBackend, + ) -> Result, GraphError> { Ok(self.underlying(analyzer)?.maybe_array_size()) } @@ -327,9 +333,7 @@ impl Concrete { } } } - Builtin::Int(size) => { - Some(Concrete::Int(size, I256::from_raw(val))) - } + Builtin::Int(size) => Some(Concrete::Int(size, I256::from_raw(val))), Builtin::Bytes(size) => { let mask = if size == 32 { U256::MAX diff --git a/crates/graph/src/nodes/context/context_tys.rs b/crates/graph/src/nodes/context/context_tys.rs index 0d625c72..cbd2b5ce 100644 --- a/crates/graph/src/nodes/context/context_tys.rs +++ b/crates/graph/src/nodes/context/context_tys.rs @@ -1,4 +1,4 @@ -use crate::nodes::{ContextNode, ContextVarNode, FunctionNode, ContractNode}; +use crate::nodes::{ContextNode, ContextVarNode, ContractNode, FunctionNode}; use shared::NodeIdx; use solang_parser::pt::Loc; @@ -81,4 +81,4 @@ pub struct ContextCache { pub associated_source: Option, /// Associated contract of this context pub associated_contract: Option, -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/expr_ret.rs b/crates/graph/src/nodes/context/expr_ret.rs index 9e1cf80a..a4fd2e64 100644 --- a/crates/graph/src/nodes/context/expr_ret.rs +++ b/crates/graph/src/nodes/context/expr_ret.rs @@ -1,7 +1,6 @@ -use crate::{GraphBackend, AsDotStr, GraphError, Node, VarType, nodes::context::ContextVarNode,}; +use crate::{nodes::context::ContextVarNode, AsDotStr, GraphBackend, GraphError, Node, VarType}; use shared::NodeIdx; - /// The reason a context was killed #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum KilledKind { diff --git a/crates/graph/src/nodes/context/mod.rs b/crates/graph/src/nodes/context/mod.rs index cebf990c..4e8ac1ac 100644 --- a/crates/graph/src/nodes/context/mod.rs +++ b/crates/graph/src/nodes/context/mod.rs @@ -4,16 +4,15 @@ mod node; mod underlying; mod var; +pub use context_tys::{CallFork, ContextCache, ModifierState}; +pub use expr_ret::{ExprRet, KilledKind}; pub use node::ContextNode; pub use underlying::Context; -pub use var::{ContextVarNode, TmpConstruction, ContextVar}; -pub use expr_ret::{KilledKind, ExprRet}; -pub use context_tys::{ ModifierState, ContextCache, CallFork }; - +pub use var::{ContextVar, ContextVarNode, TmpConstruction}; // ContextNode implementations are split to ease in maintainability mod querying; mod solving; mod typing; mod variables; -mod versioning; \ No newline at end of file +mod versioning; diff --git a/crates/graph/src/nodes/context/node.rs b/crates/graph/src/nodes/context/node.rs index a23e2fd7..e01331e2 100644 --- a/crates/graph/src/nodes/context/node.rs +++ b/crates/graph/src/nodes/context/node.rs @@ -1,7 +1,6 @@ use crate::{ - AsDotStr, AnalyzerBackend, - nodes::{ FunctionParamNode, ContextVarNode, Context, FunctionNode, KilledKind }, - GraphError, Node, GraphBackend + nodes::{Context, ContextVarNode, FunctionNode, FunctionParamNode, KilledKind}, + AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node, }; use shared::NodeIdx; @@ -62,7 +61,10 @@ impl ContextNode { } /// Gets an immutable reference to the underlying context in the graph - pub fn underlying<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a Context, GraphError> { + pub fn underlying<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> Result<&'a Context, GraphError> { match analyzer.node(*self) { Node::Context(c) => Ok(c), e => Err(GraphError::NodeConfusion(format!( @@ -155,4 +157,4 @@ impl From for ContextNode { fn from(idx: NodeIdx) -> Self { ContextNode(idx.index()) } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/querying.rs b/crates/graph/src/nodes/context/querying.rs index 1bedb637..b2f9f018 100644 --- a/crates/graph/src/nodes/context/querying.rs +++ b/crates/graph/src/nodes/context/querying.rs @@ -1,13 +1,13 @@ use crate::{ - AnalyzerBackend, GraphBackend, GraphError, Edge, ContextEdge, - nodes::{ContextNode, StructNode, ContractNode, FunctionNode}, + nodes::{ContextNode, ContractNode, FunctionNode, StructNode}, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, GraphError, }; use shared::{NodeIdx, Search}; -use std::collections::{BTreeSet, BTreeMap}; +use std::collections::{BTreeMap, BTreeSet}; impl ContextNode { - /// Gets the associated contract for the function for the context + /// Gets the associated contract for the function for the context pub fn associated_contract( &self, analyzer: &mut (impl GraphBackend + AnalyzerBackend), @@ -240,4 +240,4 @@ impl ContextNode { pub fn associated_fn_name(&self, analyzer: &impl GraphBackend) -> Result { self.associated_fn(analyzer)?.name(analyzer) } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/solving.rs b/crates/graph/src/nodes/context/solving.rs index 7cd18697..273d97c0 100644 --- a/crates/graph/src/nodes/context/solving.rs +++ b/crates/graph/src/nodes/context/solving.rs @@ -1,9 +1,12 @@ use crate::{ - solvers::{SolverAtom, Atomize, dl::{SolveStatus, DLSolver}}, + as_dot_str, + nodes::{ContextNode, ContextVarNode}, range::{elem::RangeOp, RangeEval}, - nodes::{ContextVarNode, ContextNode}, - Node, GraphError, GraphBackend, AnalyzerBackend, AsDotStr, - as_dot_str + solvers::{ + dl::{DLSolver, SolveStatus}, + Atomize, SolverAtom, + }, + AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node, }; use shared::NodeIdx; @@ -13,8 +16,8 @@ use petgraph::dot::Dot; use std::collections::BTreeMap; impl ContextNode { - /// Use a Difference Logic solver to see if it is unreachable - pub fn unreachable(&self, analyzer: &impl GraphBackend) -> Result { + /// Use a Difference Logic solver to see if it is unreachable + pub fn unreachable(&self, analyzer: &impl GraphBackend) -> Result { let mut solver = self.dl_solver(analyzer)?.clone(); match solver.solve_partial(analyzer)? { SolveStatus::Unsat => Ok(true), @@ -55,12 +58,18 @@ impl ContextNode { } /// Get the difference logic solver associated with this context - pub fn dl_solver<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a DLSolver, GraphError> { + pub fn dl_solver<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> Result<&'a DLSolver, GraphError> { Ok(&self.underlying(analyzer)?.dl_solver) } /// Returns a map of variable dependencies for this context - pub fn ctx_deps(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { + pub fn ctx_deps( + &self, + analyzer: &impl GraphBackend, + ) -> Result, GraphError> { Ok(self.underlying(analyzer)?.ctx_deps.clone()) } @@ -89,7 +98,7 @@ impl ContextNode { Ok(()) } - /// Creates a DAG of the context dependencies and opens it with graphviz + /// Creates a DAG of the context dependencies and opens it with graphviz pub fn deps_dag(&self, g: &impl GraphBackend) -> Result<(), GraphError> { let deps = self.ctx_deps(g)?; // #[derive(Debug, Copy, Clone)] @@ -209,4 +218,4 @@ impl ContextNode { .expect("failed to execute process"); Ok(()) } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/typing.rs b/crates/graph/src/nodes/context/typing.rs index ad3d3d2c..49e2612e 100644 --- a/crates/graph/src/nodes/context/typing.rs +++ b/crates/graph/src/nodes/context/typing.rs @@ -1,17 +1,17 @@ use crate::{ - GraphError, GraphBackend, AnalyzerBackend, - nodes::{ContextNode, FunctionNode} + nodes::{ContextNode, FunctionNode}, + AnalyzerBackend, GraphBackend, GraphError, }; impl ContextNode { - /// Returns whether this context is killed or returned + /// Returns whether this context is killed or returned pub fn killed_or_ret(&self, analyzer: &impl GraphBackend) -> Result { let underlying = self.underlying(analyzer)?; Ok(underlying.killed.is_some() || (!underlying.ret.is_empty() && underlying.modifier_state.is_none())) } - /// Returns whether the context is killed + /// Returns whether the context is killed pub fn is_returned(&self, analyzer: &impl GraphBackend) -> Result { Ok(!self.underlying(analyzer)?.ret.is_empty()) } @@ -27,8 +27,8 @@ impl ContextNode { Ok(underlying.child.is_some() || underlying.killed.is_some() || !underlying.ret.is_empty()) } - /// Check if this context is in an external function call - pub fn is_ext_fn(&self, analyzer: &impl GraphBackend) -> Result { + /// Check if this context is in an external function call + pub fn is_ext_fn(&self, analyzer: &impl GraphBackend) -> Result { Ok(self.underlying(analyzer)?.ext_fn_call.is_some()) } @@ -80,4 +80,4 @@ impl ContextNode { self.underlying_mut(analyzer)?.unchecked = false; Ok(()) } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/underlying.rs b/crates/graph/src/nodes/context/underlying.rs index aa3344d0..2901dc4f 100644 --- a/crates/graph/src/nodes/context/underlying.rs +++ b/crates/graph/src/nodes/context/underlying.rs @@ -1,16 +1,14 @@ use crate::{ - GraphError, AnalyzerBackend, - solvers::dl::DLSolver, nodes::{ - ExprRet, KilledKind, ContextCache, - FunctionNode, ContextVarNode, ContextNode, CallFork, + CallFork, ContextCache, ContextNode, ContextVarNode, ExprRet, FunctionNode, KilledKind, ModifierState, - } + }, + solvers::dl::DLSolver, + AnalyzerBackend, GraphError, }; use solang_parser::pt::Loc; - #[derive(Debug, Clone, Eq, PartialEq)] pub struct Context { /// The function associated with this context @@ -250,4 +248,4 @@ impl Context { pub fn as_string(&mut self) -> String { "Context".to_string() } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/var/mod.rs b/crates/graph/src/nodes/context/var/mod.rs index d4909ebe..1f665e95 100644 --- a/crates/graph/src/nodes/context/var/mod.rs +++ b/crates/graph/src/nodes/context/var/mod.rs @@ -1,8 +1,8 @@ mod node; mod ranging; -mod underlying; mod typing; +mod underlying; mod versioning; pub use node::*; -pub use underlying::*; \ No newline at end of file +pub use underlying::*; diff --git a/crates/graph/src/nodes/context/var/node.rs b/crates/graph/src/nodes/context/var/node.rs index ef691f92..023a05b3 100644 --- a/crates/graph/src/nodes/context/var/node.rs +++ b/crates/graph/src/nodes/context/var/node.rs @@ -1,14 +1,13 @@ use crate::{ - GraphBackend, AsDotStr, - GraphError, Node, ContextEdge, Edge, - nodes::{VarNode, ContextNode, ContextVar, TmpConstruction}, - range::{Range, range_string::ToRangeString, elem::RangeElem}, + nodes::{ContextNode, ContextVar, TmpConstruction, VarNode}, + range::{elem::RangeElem, range_string::ToRangeString, Range}, + AsDotStr, ContextEdge, Edge, GraphBackend, GraphError, Node, }; use shared::{NodeIdx, Search}; use petgraph::{visit::EdgeRef, Direction}; -use solang_parser::pt::{StorageLocation, Loc}; +use solang_parser::pt::{Loc, StorageLocation}; use std::collections::BTreeMap; @@ -88,7 +87,6 @@ impl ContextVarNode { ) -> Result<&'a Option, GraphError> { Ok(&self.underlying(analyzer)?.storage) } - pub fn loc(&self, analyzer: &impl GraphBackend) -> Result { Ok(self @@ -193,7 +191,10 @@ impl ContextVarNode { return_assignments } - pub fn tmp_of(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { + pub fn tmp_of( + &self, + analyzer: &impl GraphBackend, + ) -> Result, GraphError> { Ok(self.underlying(analyzer)?.tmp_of()) } @@ -248,7 +249,6 @@ impl ContextVarNode { .collect() } - pub fn dependent_on( &self, analyzer: &impl GraphBackend, @@ -301,4 +301,4 @@ impl ContextVarNode { Ok(tree) } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/var/ranging.rs b/crates/graph/src/nodes/context/var/ranging.rs index 0569cad2..504ae6f2 100644 --- a/crates/graph/src/nodes/context/var/ranging.rs +++ b/crates/graph/src/nodes/context/var/ranging.rs @@ -1,7 +1,7 @@ use crate::{ - AnalyzerBackend, GraphBackend, GraphError, SolcRange, VarType, - nodes::{ContextVarNode, ContextNode, Concrete}, + nodes::{Concrete, ContextNode, ContextVarNode}, range::{range_string::ToRangeString, Range}, + AnalyzerBackend, GraphBackend, GraphError, SolcRange, VarType, }; use crate::range::elem::*; @@ -9,7 +9,7 @@ use crate::range::elem::*; use solang_parser::pt::Loc; impl ContextVarNode { - #[tracing::instrument(level = "trace", skip_all)] + #[tracing::instrument(level = "trace", skip_all)] pub fn update_deps( &mut self, ctx: ContextNode, @@ -320,4 +320,4 @@ impl ContextVarNode { } Ok(()) } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/var/typing.rs b/crates/graph/src/nodes/context/var/typing.rs index 8aee4e98..dd625544 100644 --- a/crates/graph/src/nodes/context/var/typing.rs +++ b/crates/graph/src/nodes/context/var/typing.rs @@ -1,19 +1,19 @@ use crate::{ - AnalyzerBackend, GraphBackend, GraphError, VarType, Node, Edge, ContextEdge, - nodes::{ContextVarNode, ContextNode, Concrete, Builtin}, + nodes::{Builtin, Concrete, ContextNode, ContextVarNode}, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, GraphError, Node, VarType, }; use shared::Search; use petgraph::Direction; -use solang_parser::pt::{StorageLocation, Loc}; +use solang_parser::pt::{Loc, StorageLocation}; impl ContextVarNode { - pub fn ty<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a VarType, GraphError> { + pub fn ty<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a VarType, GraphError> { Ok(&self.underlying(analyzer)?.ty) } - pub fn is_mapping(&self, analyzer: &impl GraphBackend) -> Result { + pub fn is_mapping(&self, analyzer: &impl GraphBackend) -> Result { self.ty(analyzer)?.is_mapping(analyzer) } @@ -145,7 +145,11 @@ impl ContextVarNode { Ok(false) } - pub fn is_return_node_in_any(&self, ctxs: &[ContextNode], analyzer: &impl GraphBackend) -> bool { + pub fn is_return_node_in_any( + &self, + ctxs: &[ContextNode], + analyzer: &impl GraphBackend, + ) -> bool { ctxs.iter().any(|ctx| { ctx.underlying(analyzer) .unwrap() @@ -223,7 +227,11 @@ impl ContextVarNode { Ok(analyzer.add_node(Node::ContextVar(new_underlying)).into()) } - pub fn ty_eq(&self, other: &Self, analyzer: &mut impl GraphBackend) -> Result { + pub fn ty_eq( + &self, + other: &Self, + analyzer: &mut impl GraphBackend, + ) -> Result { self.ty(analyzer)?.ty_eq(other.ty(analyzer)?, analyzer) } @@ -306,4 +314,4 @@ impl ContextVarNode { pub fn is_int(&self, analyzer: &impl GraphBackend) -> Result { self.ty(analyzer)?.is_int(analyzer) } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/var/underlying.rs b/crates/graph/src/nodes/context/var/underlying.rs index 69bdf92a..45edabe3 100644 --- a/crates/graph/src/nodes/context/var/underlying.rs +++ b/crates/graph/src/nodes/context/var/underlying.rs @@ -1,13 +1,16 @@ use crate::{ - AnalyzerBackend, GraphBackend, GraphError, VarType, Node, SolcRange, TypeNode, + nodes::{ + BuiltInNode, Builtin, Concrete, ConcreteNode, ContextNode, ContextVarNode, ContractNode, + EnumNode, Field, FunctionNode, FunctionParam, FunctionReturn, StructNode, TyNode, + }, range::Range, - nodes::{ContextVarNode, ContextNode, Concrete, Builtin, ContractNode, FunctionNode, FunctionParam, FunctionReturn, BuiltInNode, EnumNode, Field, TyNode, StructNode, ConcreteNode}, + AnalyzerBackend, GraphBackend, GraphError, Node, SolcRange, TypeNode, VarType, }; use crate::range::elem::*; use shared::NodeIdx; -use solang_parser::pt::{StorageLocation, Loc}; +use solang_parser::pt::{Loc, StorageLocation}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct ContextVar { @@ -576,7 +579,10 @@ impl ContextVar { } } - pub fn maybe_new_from_func_ret(analyzer: &impl GraphBackend, ret: FunctionReturn) -> Option { + pub fn maybe_new_from_func_ret( + analyzer: &impl GraphBackend, + ret: FunctionReturn, + ) -> Option { if let Some(name) = ret.name { if let Some(ty) = VarType::try_from_idx(analyzer, ret.ty) { Some(ContextVar { @@ -625,4 +631,4 @@ impl ContextVar { Ok(None) } } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/var/versioning.rs b/crates/graph/src/nodes/context/var/versioning.rs index f3b4a9c0..483dac22 100644 --- a/crates/graph/src/nodes/context/var/versioning.rs +++ b/crates/graph/src/nodes/context/var/versioning.rs @@ -1,15 +1,14 @@ use crate::{ - GraphBackend, GraphError, Edge, ContextEdge, - nodes::{ContextVarNode, ContextNode}, + nodes::{ContextNode, ContextVarNode}, + ContextEdge, Edge, GraphBackend, GraphError, }; use shared::NodeIdx; use petgraph::{visit::EdgeRef, Direction}; - impl ContextVarNode { - pub fn latest_version(&self, analyzer: &impl GraphBackend) -> Self { + pub fn latest_version(&self, analyzer: &impl GraphBackend) -> Self { let mut latest = *self; while let Some(next) = latest.next_version(analyzer) { latest = next; @@ -194,4 +193,3 @@ impl ContextVarNode { } } } - diff --git a/crates/graph/src/nodes/context/variables.rs b/crates/graph/src/nodes/context/variables.rs index 0dae0097..e4d29266 100644 --- a/crates/graph/src/nodes/context/variables.rs +++ b/crates/graph/src/nodes/context/variables.rs @@ -1,6 +1,6 @@ use crate::{ - AnalyzerBackend, GraphBackend, Node, Edge, GraphError, ContextEdge, - nodes::{ContextVarNode, ContextNode, ExprRet}, + nodes::{ContextNode, ContextVarNode, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, GraphError, Node, }; use solang_parser::pt::Loc; @@ -8,8 +8,8 @@ use solang_parser::pt::Loc; use std::collections::BTreeMap; impl ContextNode { - /// Add a variable to this context - pub fn add_var( + /// Add a variable to this context + pub fn add_var( &self, var: ContextVarNode, analyzer: &mut (impl GraphBackend + AnalyzerBackend), @@ -20,7 +20,7 @@ impl ContextNode { Ok(()) } - /// Gets a variable by name in the context + /// Gets a variable by name in the context pub fn var_by_name(&self, analyzer: &impl GraphBackend, name: &str) -> Option { self.underlying(analyzer) .unwrap() @@ -46,7 +46,10 @@ impl ContextNode { } /// Gets all variables associated with a context - pub fn vars<'a>(&self, analyzer: &'a impl GraphBackend) -> &'a BTreeMap { + pub fn vars<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> &'a BTreeMap { &self.underlying(analyzer).unwrap().cache.vars } @@ -248,10 +251,13 @@ impl ContextNode { } /// Gets local vars that were assigned from an external function return - pub fn vars_assigned_from_ext_fn_ret(&self, analyzer: &impl GraphBackend) -> Vec { + pub fn vars_assigned_from_ext_fn_ret( + &self, + analyzer: &impl GraphBackend, + ) -> Vec { self.local_vars(analyzer) .iter() .flat_map(|(_name, var)| var.ext_return_assignments(analyzer)) .collect() } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/context/versioning.rs b/crates/graph/src/nodes/context/versioning.rs index a19aab1f..e56bf422 100644 --- a/crates/graph/src/nodes/context/versioning.rs +++ b/crates/graph/src/nodes/context/versioning.rs @@ -1,13 +1,13 @@ use crate::{ - AnalyzerBackend, GraphBackend, Node, GraphError, - nodes::{ContextNode, CallFork, KilledKind, FunctionNode} + nodes::{CallFork, ContextNode, FunctionNode, KilledKind}, + AnalyzerBackend, GraphBackend, GraphError, Node, }; use solang_parser::pt::Loc; impl ContextNode { - /// Query whether this context has a parent - pub fn has_parent(&self, analyzer: &impl GraphBackend) -> Result { + /// Query whether this context has a parent + pub fn has_parent(&self, analyzer: &impl GraphBackend) -> Result { Ok(self.underlying(analyzer)?.parent_ctx.is_some()) } @@ -27,7 +27,7 @@ impl ContextNode { } } - /// Gets the subcontexts of this context + /// Gets the subcontexts of this context pub fn subcontexts(&self, analyzer: &impl GraphBackend) -> Vec { let underlying = self.underlying(analyzer).unwrap(); match underlying.child { @@ -75,7 +75,7 @@ impl ContextNode { .collect()) } - /// Returns tail contexts associated with the context + /// Returns tail contexts associated with the context pub fn live_edges(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { if let Some(child) = self.underlying(analyzer)?.child { let mut lineage = vec![]; @@ -391,7 +391,10 @@ impl ContextNode { } /// Gets parent list - pub fn parent_list(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { + pub fn parent_list( + &self, + analyzer: &impl GraphBackend, + ) -> Result, GraphError> { let context = self.underlying(analyzer)?; let mut parents = vec![]; if let Some(parent_ctx) = context.parent_ctx { @@ -428,4 +431,4 @@ impl ContextNode { ) -> Result, GraphError> { todo!() } -} \ No newline at end of file +} diff --git a/crates/graph/src/nodes/contract_ty.rs b/crates/graph/src/nodes/contract_ty.rs index 3afd79de..2098ea69 100644 --- a/crates/graph/src/nodes/contract_ty.rs +++ b/crates/graph/src/nodes/contract_ty.rs @@ -1,4 +1,7 @@ -use crate::{AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node, Edge, nodes::{StructNode, FunctionNode, VarNode}}; +use crate::{ + nodes::{FunctionNode, StructNode, VarNode}, + AnalyzerBackend, AsDotStr, Edge, GraphBackend, GraphError, Node, +}; use shared::{NodeIdx, Search}; use petgraph::{visit::EdgeRef, Direction}; @@ -27,7 +30,10 @@ impl AsDotStr for ContractNode { impl ContractNode { /// Gets the underlying node data for the [`Contract`] - pub fn underlying<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a Contract, GraphError> { + pub fn underlying<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> Result<&'a Contract, GraphError> { match analyzer.node(*self) { Node::Contract(contract) => Ok(contract), e => Err(GraphError::NodeConfusion(format!( @@ -45,7 +51,11 @@ impl ContractNode { .collect() } - pub fn inherit(&self, inherits: Vec, analyzer: &mut (impl GraphBackend + AnalyzerBackend)) { + pub fn inherit( + &self, + inherits: Vec, + analyzer: &mut (impl GraphBackend + AnalyzerBackend), + ) { let src = self.associated_source(analyzer); let all_contracts = analyzer.search_children_include_via( src, diff --git a/crates/graph/src/nodes/enum_ty.rs b/crates/graph/src/nodes/enum_ty.rs index 6ca7041d..869547cb 100644 --- a/crates/graph/src/nodes/enum_ty.rs +++ b/crates/graph/src/nodes/enum_ty.rs @@ -1,4 +1,4 @@ -use crate::{AsDotStr, GraphBackend, SolcRange, GraphError, Node, nodes::Concrete}; +use crate::{nodes::Concrete, AsDotStr, GraphBackend, GraphError, Node, SolcRange}; use shared::NodeIdx; diff --git a/crates/graph/src/nodes/func_ty.rs b/crates/graph/src/nodes/func_ty.rs index efbae343..a25e3f1a 100644 --- a/crates/graph/src/nodes/func_ty.rs +++ b/crates/graph/src/nodes/func_ty.rs @@ -1,4 +1,8 @@ -use crate::{AnalyzerBackend, GraphBackend, AsDotStr, SolcRange, Edge, VarType, GraphError, Node, ContextEdge, nodes::{ContextNode, ContractNode}}; +use crate::{ + nodes::{ContextNode, ContractNode}, + AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, GraphError, Node, SolcRange, + VarType, +}; use shared::{NodeIdx, Search}; @@ -6,9 +10,8 @@ use petgraph::{visit::EdgeRef, Direction}; use solang_parser::{ helpers::CodeLocation, pt::{ - ParameterList, Statement, Type, VariableDefinition, - Base, Expression, FunctionAttribute, FunctionDefinition, FunctionTy, Identifier, - Loc, Parameter, StorageLocation, Visibility, + Base, Expression, FunctionAttribute, FunctionDefinition, FunctionTy, Identifier, Loc, + Parameter, ParameterList, Statement, StorageLocation, Type, VariableDefinition, Visibility, }, }; use std::collections::BTreeMap; @@ -16,7 +19,10 @@ use std::collections::BTreeMap; #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct FunctionNode(pub usize); impl FunctionNode { - pub fn underlying<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a Function, GraphError> { + pub fn underlying<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> Result<&'a Function, GraphError> { match analyzer.node(*self) { Node::Function(func) => Ok(func), e => Err(GraphError::NodeConfusion(format!( @@ -39,7 +45,10 @@ impl FunctionNode { } /// Gets an ordered list of modifiers for a given function - pub fn modifiers(&self, analyzer: &mut (impl GraphBackend + AnalyzerBackend)) -> Vec { + pub fn modifiers( + &self, + analyzer: &mut (impl GraphBackend + AnalyzerBackend), + ) -> Vec { if let Some(mods) = &self.underlying(analyzer).unwrap().cache.modifiers { mods.values().copied().collect() } else { @@ -249,7 +258,10 @@ impl FunctionNode { } } - pub fn associated_source(&self, analyzer: &mut (impl GraphBackend + AnalyzerBackend)) -> NodeIdx { + pub fn associated_source( + &self, + analyzer: &mut (impl GraphBackend + AnalyzerBackend), + ) -> NodeIdx { if let Some(src) = self.underlying(analyzer).unwrap().cache.associated_source { src } else { diff --git a/crates/graph/src/nodes/mod.rs b/crates/graph/src/nodes/mod.rs index 1f47295b..d4a53246 100644 --- a/crates/graph/src/nodes/mod.rs +++ b/crates/graph/src/nodes/mod.rs @@ -32,4 +32,4 @@ mod builtin; pub use builtin::*; mod context; -pub use context::*; \ No newline at end of file +pub use context::*; diff --git a/crates/graph/src/nodes/msg.rs b/crates/graph/src/nodes/msg.rs index de4e0600..4e1966a8 100644 --- a/crates/graph/src/nodes/msg.rs +++ b/crates/graph/src/nodes/msg.rs @@ -1,8 +1,11 @@ -use crate::{AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node, nodes::{Concrete, Builtin, ContextNode, ContextVar}}; +use crate::{ + nodes::{Builtin, Concrete, ContextNode, ContextVar}, + AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node, +}; use shared::NodeIdx; -use ethers_core::types::{U256, Address}; +use ethers_core::types::{Address, U256}; use solang_parser::pt::Loc; #[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] diff --git a/crates/graph/src/nodes/struct_ty.rs b/crates/graph/src/nodes/struct_ty.rs index f7fbdf64..2d4409bc 100644 --- a/crates/graph/src/nodes/struct_ty.rs +++ b/crates/graph/src/nodes/struct_ty.rs @@ -1,4 +1,4 @@ -use crate::{AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node, Edge, VarType}; +use crate::{AnalyzerBackend, AsDotStr, Edge, GraphBackend, GraphError, Node, VarType}; use shared::NodeIdx; @@ -9,7 +9,10 @@ use solang_parser::pt::{Expression, Identifier, Loc, StructDefinition, VariableD pub struct StructNode(pub usize); impl StructNode { - pub fn underlying<'a>(&self, analyzer: &'a impl GraphBackend) -> Result<&'a Struct, GraphError> { + pub fn underlying<'a>( + &self, + analyzer: &'a impl GraphBackend, + ) -> Result<&'a Struct, GraphError> { match analyzer.node(*self) { Node::Struct(st) => Ok(st), e => Err(GraphError::NodeConfusion(format!( @@ -42,7 +45,11 @@ impl StructNode { fields } - pub fn find_field(&self, analyzer: &impl GraphBackend, ident: &Identifier) -> Option { + pub fn find_field( + &self, + analyzer: &impl GraphBackend, + ident: &Identifier, + ) -> Option { analyzer .graph() .edges_directed(self.0.into(), Direction::Incoming) diff --git a/crates/graph/src/nodes/var_ty.rs b/crates/graph/src/nodes/var_ty.rs index 9c985e2a..794b595d 100644 --- a/crates/graph/src/nodes/var_ty.rs +++ b/crates/graph/src/nodes/var_ty.rs @@ -1,4 +1,7 @@ -use crate::{AsDotStr, AnalyzerBackend, GraphBackend, Node, Edge, VarType, ContextEdge, nodes::{ContextVar, ContractNode, ContextVarNode}, GraphError}; +use crate::{ + nodes::{ContextVar, ContextVarNode, ContractNode}, + AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, GraphError, Node, VarType, +}; use shared::{NodeIdx, Search}; @@ -75,7 +78,10 @@ impl VarNode { .map(ContractNode::from) } - pub fn maybe_associated_source_unit_part(&self, analyzer: &impl GraphBackend) -> Option { + pub fn maybe_associated_source_unit_part( + &self, + analyzer: &impl GraphBackend, + ) -> Option { if let Some(con) = self.maybe_associated_contract(analyzer) { Some(con.associated_source_unit_part(analyzer)) } else { @@ -95,7 +101,10 @@ impl VarNode { } } - pub fn maybe_associated_source(&self, analyzer: &(impl GraphBackend + Search)) -> Option { + pub fn maybe_associated_source( + &self, + analyzer: &(impl GraphBackend + Search), + ) -> Option { let sup = self.maybe_associated_source_unit_part(analyzer)?; analyzer.search_for_ancestor(sup, &Edge::Part) } diff --git a/crates/graph/src/range/elem/concrete.rs b/crates/graph/src/range/elem/concrete.rs index d86a85e4..37e3c6ff 100644 --- a/crates/graph/src/range/elem/concrete.rs +++ b/crates/graph/src/range/elem/concrete.rs @@ -1,6 +1,7 @@ use crate::{ - GraphBackend, GraphError, nodes::{Concrete, ContextVarNode}, - range::elem::{RangeElem, RangeOp, Elem} + nodes::{Concrete, ContextVarNode}, + range::elem::{Elem, RangeElem, RangeOp}, + GraphBackend, GraphError, }; use shared::NodeIdx; @@ -152,4 +153,4 @@ impl RangeElem for RangeConcrete { ) -> Result { Ok(false) } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/elem/elem_enum.rs b/crates/graph/src/range/elem/elem_enum.rs index 5b7015ef..03f8e358 100644 --- a/crates/graph/src/range/elem/elem_enum.rs +++ b/crates/graph/src/range/elem/elem_enum.rs @@ -1,9 +1,9 @@ -use solang_parser::pt::Loc; use crate::{ - GraphBackend, GraphError, nodes::{Concrete, ContextVarNode}, - range::elem::{RangeElem, RangeOp, Reference, RangeDyn, RangeConcrete, RangeExpr}, + range::elem::{RangeConcrete, RangeDyn, RangeElem, RangeExpr, RangeOp, Reference}, + GraphBackend, GraphError, }; +use solang_parser::pt::Loc; use shared::NodeIdx; @@ -11,18 +11,7 @@ use ethers_core::types::I256; use std::{ collections::BTreeMap, - ops::{ - Add, - Sub, - Mul, - Div, - Shl, - Shr, - Rem, - BitAnd, - BitOr, - BitXor, - } + ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Rem, Shl, Shr, Sub}, }; /// A core range element. @@ -592,4 +581,4 @@ impl Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/elem/elem_trait.rs b/crates/graph/src/range/elem/elem_trait.rs index e7139743..966b0a36 100644 --- a/crates/graph/src/range/elem/elem_trait.rs +++ b/crates/graph/src/range/elem/elem_trait.rs @@ -1,4 +1,8 @@ -use crate::{GraphBackend, nodes::ContextVarNode, range::elem::{RangeExpr, RangeOp, Elem}}; +use crate::{ + nodes::ContextVarNode, + range::elem::{Elem, RangeExpr, RangeOp}, + GraphBackend, +}; use shared::NodeIdx; @@ -7,7 +11,11 @@ use std::collections::BTreeMap; pub trait RangeElem { type GraphError; /// Flattens an element into an expression or concrete based purely on inputs, calldata, storage, or environment data variables - fn flatten(&self, maximize: bool, analyzer: &impl GraphBackend) -> Result, Self::GraphError>; + fn flatten( + &self, + maximize: bool, + analyzer: &impl GraphBackend, + ) -> Result, Self::GraphError>; /// Tries to evaluate a range element down to a concrete or maximally simplified expression to its maximum value fn maximize(&self, analyzer: &impl GraphBackend) -> Result, Self::GraphError>; /// Maximizes the element and caches the result for quicker use later @@ -67,4 +75,4 @@ pub trait RangeElem { op_set: &[RangeOp], analyzer: &impl GraphBackend, ) -> Result; -} \ No newline at end of file +} diff --git a/crates/graph/src/range/elem/expr.rs b/crates/graph/src/range/elem/expr.rs index d71d626d..0418bb19 100644 --- a/crates/graph/src/range/elem/expr.rs +++ b/crates/graph/src/range/elem/expr.rs @@ -1,14 +1,17 @@ use crate::{ - GraphBackend, GraphError, nodes::{Concrete, ContextVarNode}, - range::{elem::{RangeElem, RangeOp, Elem, MinMaxed}, exec_traits::*} + nodes::{Concrete, ContextVarNode}, + range::{ + elem::{Elem, MinMaxed, RangeElem, RangeOp}, + exec_traits::*, + }, + GraphBackend, GraphError, }; -use shared::{NodeIdx}; use ethers_core::types::U256; +use shared::NodeIdx; use std::collections::BTreeMap; - pub static SINGLETON_EQ_OPS: &[RangeOp] = &[ RangeOp::Eq, RangeOp::Neq, @@ -31,7 +34,6 @@ pub static EQ_OPS: &[RangeOp] = &[ pub static FLIP_INEQ_OPS: &[RangeOp] = &[RangeOp::Lt, RangeOp::Lte, RangeOp::Gt, RangeOp::Gte]; - /// A range expression composed of other range [`Elem`] #[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] pub struct RangeExpr { @@ -203,7 +205,6 @@ impl RangeElem for RangeExpr { } } - enum MaybeCollapsed { Collapsed(Elem), Not(Elem, Elem), @@ -574,4 +575,4 @@ fn collapse(l: Elem, op: RangeOp, r: Elem) -> MaybeCollapsed }, _ => MaybeCollapsed::Not(l, r), } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/elem/map_or_array.rs b/crates/graph/src/range/elem/map_or_array.rs index cbacbf12..66a7b028 100644 --- a/crates/graph/src/range/elem/map_or_array.rs +++ b/crates/graph/src/range/elem/map_or_array.rs @@ -1,4 +1,8 @@ -use crate::{GraphBackend, GraphError, nodes::{ContextVarNode, Concrete}, range::elem::{RangeElem, RangeOp, MinMaxed, Elem}}; +use crate::{ + nodes::{Concrete, ContextVarNode}, + range::elem::{Elem, MinMaxed, RangeElem, RangeOp}, + GraphBackend, GraphError, +}; use shared::NodeIdx; @@ -33,11 +37,9 @@ impl RangeDyn { } } - - impl RangeElem for RangeDyn { type GraphError = GraphError; - + fn range_eq(&self, _other: &Self) -> bool { false } diff --git a/crates/graph/src/range/elem/mod.rs b/crates/graph/src/range/elem/mod.rs index 06a596e3..1fe3a99d 100644 --- a/crates/graph/src/range/elem/mod.rs +++ b/crates/graph/src/range/elem/mod.rs @@ -1,17 +1,16 @@ mod concrete; mod elem_enum; +mod elem_trait; mod expr; mod map_or_array; mod reference; -mod elem_trait; pub use concrete::*; pub use elem_enum::*; +pub use elem_trait::*; pub use expr::*; pub use map_or_array::*; pub use reference::*; -pub use elem_trait::*; - #[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] pub enum MinMaxed { diff --git a/crates/graph/src/range/elem/reference.rs b/crates/graph/src/range/elem/reference.rs index 88131d37..57065f78 100644 --- a/crates/graph/src/range/elem/reference.rs +++ b/crates/graph/src/range/elem/reference.rs @@ -1,4 +1,11 @@ -use crate::{GraphBackend, GraphError, nodes::{ContextVarNode, Concrete}, TypeNode, VarType, range::{Range, elem::{RangeElem, RangeConcrete, RangeOp, MinMaxed, Elem}}}; +use crate::{ + nodes::{Concrete, ContextVarNode}, + range::{ + elem::{Elem, MinMaxed, RangeConcrete, RangeElem, RangeOp}, + Range, + }, + GraphBackend, GraphError, TypeNode, VarType, +}; use shared::NodeIdx; @@ -207,4 +214,4 @@ impl RangeElem for Reference { _e => Ok(false), } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/add.rs b/crates/graph/src/range/exec/add.rs index 571d4788..0e1bc7b3 100644 --- a/crates/graph/src/range/exec/add.rs +++ b/crates/graph/src/range/exec/add.rs @@ -108,4 +108,4 @@ impl RangeAdd for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/bitwise.rs b/crates/graph/src/range/exec/bitwise.rs index e437439b..97010932 100644 --- a/crates/graph/src/range/exec/bitwise.rs +++ b/crates/graph/src/range/exec/bitwise.rs @@ -163,4 +163,4 @@ impl RangeBitwise for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/cast.rs b/crates/graph/src/range/exec/cast.rs index e5da78ed..dbbdd5e6 100644 --- a/crates/graph/src/range/exec/cast.rs +++ b/crates/graph/src/range/exec/cast.rs @@ -255,4 +255,4 @@ impl RangeCast for Elem { _e => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/concat.rs b/crates/graph/src/range/exec/concat.rs index 75e26c5f..aa3ffb2f 100644 --- a/crates/graph/src/range/exec/concat.rs +++ b/crates/graph/src/range/exec/concat.rs @@ -146,4 +146,4 @@ impl RangeConcat for Elem { _e => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/div.rs b/crates/graph/src/range/exec/div.rs index 11c3f32c..62476206 100644 --- a/crates/graph/src/range/exec/div.rs +++ b/crates/graph/src/range/exec/div.rs @@ -143,4 +143,4 @@ impl RangeDiv for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/exec_op.rs b/crates/graph/src/range/exec/exec_op.rs index ea50e212..e255aeb2 100644 --- a/crates/graph/src/range/exec/exec_op.rs +++ b/crates/graph/src/range/exec/exec_op.rs @@ -1,8 +1,12 @@ -use crate::{GraphBackend, GraphError, nodes::Concrete, range::{elem::*, exec_traits::*}}; +use crate::{ + nodes::Concrete, + range::{elem::*, exec_traits::*}, + GraphBackend, GraphError, +}; use shared::NodeIdx; -use ethers_core::types::{ I256, U256 }; +use ethers_core::types::{I256, U256}; use solang_parser::pt::Loc; impl ExecOp for RangeExpr { diff --git a/crates/graph/src/range/exec/exp.rs b/crates/graph/src/range/exec/exp.rs index 70cb4dd9..97462da5 100644 --- a/crates/graph/src/range/exec/exp.rs +++ b/crates/graph/src/range/exec/exp.rs @@ -82,4 +82,4 @@ impl RangeExp for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/logical.rs b/crates/graph/src/range/exec/logical.rs index 93befcd9..5d3c6129 100644 --- a/crates/graph/src/range/exec/logical.rs +++ b/crates/graph/src/range/exec/logical.rs @@ -52,4 +52,4 @@ impl RangeUnary for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/max.rs b/crates/graph/src/range/exec/max.rs index 646f7b2d..c32eb45e 100644 --- a/crates/graph/src/range/exec/max.rs +++ b/crates/graph/src/range/exec/max.rs @@ -40,4 +40,4 @@ impl RangeMax for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/min.rs b/crates/graph/src/range/exec/min.rs index 761b34d5..338ed35a 100644 --- a/crates/graph/src/range/exec/min.rs +++ b/crates/graph/src/range/exec/min.rs @@ -40,4 +40,4 @@ impl RangeMin for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/mod.rs b/crates/graph/src/range/exec/mod.rs index 9efed125..4946baed 100644 --- a/crates/graph/src/range/exec/mod.rs +++ b/crates/graph/src/range/exec/mod.rs @@ -3,8 +3,8 @@ mod bitwise; mod cast; mod concat; mod div; -mod exp; mod exec_op; +mod exp; mod logical; mod max; mod min; diff --git a/crates/graph/src/range/exec/modulo.rs b/crates/graph/src/range/exec/modulo.rs index a021a8ac..66db9b60 100644 --- a/crates/graph/src/range/exec/modulo.rs +++ b/crates/graph/src/range/exec/modulo.rs @@ -1,7 +1,7 @@ use crate::nodes::Concrete; use crate::range::{elem::*, exec_traits::*}; -use ethers_core::types::{I256}; +use ethers_core::types::I256; impl RangeMod for RangeConcrete { fn range_mod(&self, other: &Self) -> Option> { diff --git a/crates/graph/src/range/exec/mul.rs b/crates/graph/src/range/exec/mul.rs index a671ee9e..63940124 100644 --- a/crates/graph/src/range/exec/mul.rs +++ b/crates/graph/src/range/exec/mul.rs @@ -3,8 +3,6 @@ use crate::range::{elem::*, exec_traits::*}; use ethers_core::types::{I256, U256}; - - impl RangeMul for RangeConcrete { fn range_mul(&self, other: &Self) -> Option> { match (self.val.into_u256(), other.val.into_u256()) { @@ -110,4 +108,4 @@ impl RangeMul for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/ord.rs b/crates/graph/src/range/exec/ord.rs index 04364730..4e867e25 100644 --- a/crates/graph/src/range/exec/ord.rs +++ b/crates/graph/src/range/exec/ord.rs @@ -1,8 +1,6 @@ use crate::nodes::Concrete; use crate::range::{elem::*, exec_traits::*}; - - impl RangeOrd for RangeConcrete { fn range_ord_eq(&self, other: &Self) -> Option> { match (self.val.into_u256(), other.val.into_u256()) { @@ -215,4 +213,4 @@ impl RangeOrd for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/shift.rs b/crates/graph/src/range/exec/shift.rs index f33e473e..cf68f6fc 100644 --- a/crates/graph/src/range/exec/shift.rs +++ b/crates/graph/src/range/exec/shift.rs @@ -160,4 +160,4 @@ impl RangeShift for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec/sub.rs b/crates/graph/src/range/exec/sub.rs index 1a32dd4d..dfe80219 100644 --- a/crates/graph/src/range/exec/sub.rs +++ b/crates/graph/src/range/exec/sub.rs @@ -146,4 +146,4 @@ impl RangeSub for Elem { _ => None, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/range/exec_traits.rs b/crates/graph/src/range/exec_traits.rs index 3fdc67ce..d970a133 100644 --- a/crates/graph/src/range/exec_traits.rs +++ b/crates/graph/src/range/exec_traits.rs @@ -1,14 +1,16 @@ -use crate::{GraphBackend, range::elem::Elem}; +use crate::{range::elem::Elem, GraphBackend}; use shared::NodeIdx; - - /// For execution of operations to be performed on range expressions pub trait ExecOp { type GraphError; /// Attempts to execute ops by evaluating expressions and applying the op for the left-hand-side /// and right-hand-side - fn exec_op(&self, maximize: bool, analyzer: &impl GraphBackend) -> Result, Self::GraphError> { + fn exec_op( + &self, + maximize: bool, + analyzer: &impl GraphBackend, + ) -> Result, Self::GraphError> { self.exec(self.spread(analyzer)?, maximize) } diff --git a/crates/graph/src/range/mod.rs b/crates/graph/src/range/mod.rs index 54932657..f61240b9 100644 --- a/crates/graph/src/range/mod.rs +++ b/crates/graph/src/range/mod.rs @@ -1,11 +1,9 @@ -pub mod exec_traits; pub mod elem; pub mod exec; +pub mod exec_traits; pub mod range_string; mod range_trait; mod solc_range; pub use range_trait::*; pub use solc_range::*; - - diff --git a/crates/graph/src/range/range_string.rs b/crates/graph/src/range/range_string.rs index d9941996..b50444f9 100644 --- a/crates/graph/src/range/range_string.rs +++ b/crates/graph/src/range/range_string.rs @@ -1,7 +1,7 @@ use crate::{ - GraphBackend, nodes::{Concrete, ContextVarNode}, range::elem::*, + GraphBackend, }; use solang_parser::pt::Loc; use std::collections::BTreeMap; @@ -42,7 +42,6 @@ pub trait ToRangeString { fn to_range_string(&self, maximize: bool, analyzer: &impl GraphBackend) -> RangeElemString; } - impl ToRangeString for Elem { fn def_string(&self, analyzer: &impl GraphBackend) -> RangeElemString { match self { diff --git a/crates/graph/src/range/range_trait.rs b/crates/graph/src/range/range_trait.rs index f4314b9d..c24b2de2 100644 --- a/crates/graph/src/range/range_trait.rs +++ b/crates/graph/src/range/range_trait.rs @@ -1,15 +1,21 @@ -use crate::{GraphBackend, range::elem::RangeElem}; +use crate::{range::elem::RangeElem, GraphBackend}; use shared::NodeIdx; pub trait Range { - type GraphError; + type GraphError; type ElemTy: RangeElem + Clone; /// Evaluate both the minimum and the maximum - cache along the way fn cache_eval(&mut self, analyzer: &impl GraphBackend) -> Result<(), Self::GraphError>; /// Evaluate the range minimum - fn evaled_range_min(&self, analyzer: &impl GraphBackend) -> Result; + fn evaled_range_min( + &self, + analyzer: &impl GraphBackend, + ) -> Result; /// Evaluate the range maximum - fn evaled_range_max(&self, analyzer: &impl GraphBackend) -> Result; + fn evaled_range_max( + &self, + analyzer: &impl GraphBackend, + ) -> Result; /// Simplify the minimum, leaving references in place fn simplified_range_min( &self, @@ -42,7 +48,7 @@ pub trait Range { fn range_exclusions(&self) -> Vec where Self: std::marker::Sized; - /// Set the range minimum + /// Set the range minimum fn set_range_min(&mut self, new: Self::ElemTy); /// Set the range maximum fn set_range_max(&mut self, new: Self::ElemTy); @@ -68,4 +74,4 @@ pub trait RangeEval>: Range { fn contains(&self, other: &Self, analyzer: &impl GraphBackend) -> bool; fn contains_elem(&self, other: &T, analyzer: &impl GraphBackend) -> bool; fn overlaps(&self, other: &Self, analyzer: &impl GraphBackend) -> bool; -} \ No newline at end of file +} diff --git a/crates/graph/src/range/solc_range.rs b/crates/graph/src/range/solc_range.rs index ea499259..83593952 100644 --- a/crates/graph/src/range/solc_range.rs +++ b/crates/graph/src/range/solc_range.rs @@ -1,7 +1,7 @@ use crate::{ + nodes::{Builtin, Concrete, ContextNode, ContextVarNode}, + range::{elem::*, range_string::*, Range, RangeEval}, AsDotStr, GraphBackend, GraphError, - nodes::{ContextVarNode, ContextNode, Builtin, Concrete}, - range::{RangeEval, Range, elem::*, range_string::*} }; use shared::NodeIdx; @@ -68,7 +68,12 @@ impl SolcRange { } /// Update a particular context variable with the latest version - pub fn update_deps(&mut self, node: ContextVarNode, ctx: ContextNode, analyzer: &impl GraphBackend) { + pub fn update_deps( + &mut self, + node: ContextVarNode, + ctx: ContextNode, + analyzer: &impl GraphBackend, + ) { let deps = self.dependent_on(); let mapping: BTreeMap = deps .into_iter() @@ -734,4 +739,4 @@ impl RangeEval> for SolcRange { _ => false, } } -} \ No newline at end of file +} diff --git a/crates/graph/src/solvers/atoms.rs b/crates/graph/src/solvers/atoms.rs index a0d70a08..c91259bf 100644 --- a/crates/graph/src/solvers/atoms.rs +++ b/crates/graph/src/solvers/atoms.rs @@ -1,20 +1,12 @@ use crate::{ - GraphBackend, nodes::{Concrete, ContextVarNode}, range::{ - elem::{ - RangeElem, - RangeOp, - Elem, - RangeExpr, - Reference - }, - range_string::{ToRangeString, RangeElemString}, + elem::{Elem, RangeElem, RangeExpr, RangeOp, Reference}, + range_string::{RangeElemString, ToRangeString}, }, + GraphBackend, }; - - use ethers_core::types::U256; use std::collections::BTreeMap; @@ -270,7 +262,10 @@ impl Atomize for Elem { }; AtomOrPart::Atom(atom) } - (Elem::Reference(Reference { .. }), Elem::Reference(Reference { .. })) => { + ( + Elem::Reference(Reference { .. }), + Elem::Reference(Reference { .. }), + ) => { let ty = if DL_OPS.contains(&expr.op) { OpType::DL } else if CONST_OPS.contains(&expr.op) { @@ -329,7 +324,7 @@ impl Atomize for Elem { use Elem::*; match self { - Reference(_) => None, //{ println!("was dyn"); None}, + Reference(_) => None, //{ println!("was dyn"); None}, Null => None, //{ println!("was null"); None}, Concrete(_c) => None, //{ println!("was conc: {}", c.val.as_human_string()); None }, ConcreteDyn(_) => None, //{ println!("was concDyn"); None}, diff --git a/crates/graph/src/solvers/brute.rs b/crates/graph/src/solvers/brute.rs index 38057178..01ea3f71 100644 --- a/crates/graph/src/solvers/brute.rs +++ b/crates/graph/src/solvers/brute.rs @@ -1,9 +1,11 @@ use crate::{ - GraphBackend, AnalyzerBackend, GraphError, - SolcRange, Range, RangeEval, - elem::{RangeElem, Elem}, - nodes::{ContextVarNode, Concrete, VarNode}, - solvers::{dl::{SolveStatus, DLSolver}, Atomize, SolverAtom}, + elem::{Elem, RangeElem}, + nodes::{Concrete, ContextVarNode, VarNode}, + solvers::{ + dl::{DLSolver, SolveStatus}, + Atomize, SolverAtom, + }, + AnalyzerBackend, GraphBackend, GraphError, Range, RangeEval, SolcRange, }; use ethers_core::types::U256; @@ -861,4 +863,4 @@ impl SolcSolver for BruteBinSearchSolver { analyzer, ) } -} \ No newline at end of file +} diff --git a/crates/graph/src/solvers/dl.rs b/crates/graph/src/solvers/dl.rs index 83828341..be29164f 100644 --- a/crates/graph/src/solvers/dl.rs +++ b/crates/graph/src/solvers/dl.rs @@ -1,23 +1,17 @@ use crate::{ - GraphBackend, GraphError, nodes::{Concrete, ContextVarNode}, range::elem::*, solvers::{AtomOrPart, Atomize, OpType, SolverAtom}, + GraphBackend, GraphError, }; -use ethers_core::types::{U256, I256}; +use ethers_core::types::{I256, U256}; use itertools::Itertools; use petgraph::{ - stable_graph::StableGraph, graph::NodeIndex, - visit::{ - EdgeRef, - IntoNodeIdentifiers, - NodeIndexable, - VisitMap, - Visitable, - }, - Directed + stable_graph::StableGraph, + visit::{EdgeRef, IntoNodeIdentifiers, NodeIndexable, VisitMap, Visitable}, + Directed, }; use std::collections::BTreeMap; @@ -203,7 +197,10 @@ impl DLSolver { self.normalized_constraints.values().cloned().collect() } - pub fn solve_partial(&mut self, analyzer: &impl GraphBackend) -> Result { + pub fn solve_partial( + &mut self, + analyzer: &impl GraphBackend, + ) -> Result { let mut dep_to_solve_ty: BTreeMap> = BTreeMap::default(); self.constraints.iter().for_each(|constraint| { let deps = constraint.dependent_on(); @@ -940,4 +937,4 @@ fn bellman_ford_initialize_relax( } } (distance, predecessor) -} \ No newline at end of file +} diff --git a/crates/graph/src/solvers/mod.rs b/crates/graph/src/solvers/mod.rs index a233e5ad..9711d3e3 100644 --- a/crates/graph/src/solvers/mod.rs +++ b/crates/graph/src/solvers/mod.rs @@ -1,6 +1,6 @@ -pub mod dl; mod atoms; mod brute; +pub mod dl; -pub use brute::*; pub use atoms::*; +pub use brute::*; diff --git a/crates/graph/src/var_type.rs b/crates/graph/src/var_type.rs index 2b59199c..dcbc1b61 100644 --- a/crates/graph/src/var_type.rs +++ b/crates/graph/src/var_type.rs @@ -1,16 +1,18 @@ use crate::{ - AnalyzerBackend, GraphBackend, AsDotStr, - range::{elem::{Elem, Reference, RangeElem}, Range, SolcRange}, - GraphError, Node, nodes::{ - ContextVarNode, FunctionNode, TyNode, BuiltInNode, - ConcreteNode, Builtin, Concrete, StructNode, EnumNode, ContractNode - } + BuiltInNode, Builtin, Concrete, ConcreteNode, ContextVarNode, ContractNode, EnumNode, + FunctionNode, StructNode, TyNode, + }, + range::{ + elem::{Elem, RangeElem, Reference}, + Range, SolcRange, + }, + AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node, }; use shared::NodeIdx; -use ethers_core::types::{Address, U256, H256}; +use ethers_core::types::{Address, H256, U256}; #[derive(Debug, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)] pub enum VarType { @@ -496,8 +498,9 @@ impl VarType { let Concrete::Bytes(_, val) = min.val else { return Ok(None); }; - let Some(idx) = index.evaled_range_min(analyzer)?.unwrap().maybe_concrete() else { - return Ok(None) + let Some(idx) = index.evaled_range_min(analyzer)?.unwrap().maybe_concrete() + else { + return Ok(None); }; let Concrete::Uint(_, idx) = idx.val else { return Ok(None); @@ -642,7 +645,10 @@ impl VarType { } } - pub fn maybe_array_size(&self, analyzer: &impl GraphBackend) -> Result, GraphError> { + pub fn maybe_array_size( + &self, + analyzer: &impl GraphBackend, + ) -> Result, GraphError> { match self { Self::BuiltIn(node, _) => node.maybe_array_size(analyzer), Self::Concrete(node) => node.maybe_array_size(analyzer), diff --git a/crates/pyrometer/src/analyzer.rs b/crates/pyrometer/src/analyzer.rs index 95388ab7..b3b5b4b7 100644 --- a/crates/pyrometer/src/analyzer.rs +++ b/crates/pyrometer/src/analyzer.rs @@ -1,24 +1,28 @@ use crate::builtin_fns; use analyzers::LocStrSpan; -use solc_expressions::{ContextBuilder,IntoExprErr, ExprErr}; -use graph::{Edge, Node, nodes::*, VarType, ContextEdge}; -use shared::{Search, GraphLike, AnalyzerLike, NodeIdx}; +use graph::{nodes::*, ContextEdge, Edge, Node, VarType}; +use shared::{AnalyzerLike, GraphLike, NodeIdx, Search}; +use solc_expressions::{ContextBuilder, ExprErr, IntoExprErr}; +use ariadne::{Cache, Color, Config, Fmt, Label, Report, ReportKind, Source, Span}; +use petgraph::{graph::*, Directed}; +use serde_json::Value; use solang_parser::{ diagnostics::Diagnostic, helpers::CodeLocation, pt::{ ContractDefinition, ContractPart, EnumDefinition, ErrorDefinition, Expression, - FunctionDefinition, FunctionTy, SourceUnit, SourceUnitPart, StructDefinition, TypeDefinition, - Using, UsingList, VariableDefinition, Identifier, Import, - } + FunctionDefinition, FunctionTy, Identifier, Import, SourceUnit, SourceUnitPart, + StructDefinition, TypeDefinition, Using, UsingList, VariableDefinition, + }, }; -use ariadne::{Cache, Color, Config, Fmt, Label, Report, ReportKind, Span, Source}; -use petgraph::{graph::*, Directed}; -use serde_json::Value; -use std::{path::{PathBuf, Path}, collections::{BTreeMap, HashMap}, fs}; +use std::{ + collections::{BTreeMap, HashMap}, + fs, + path::{Path, PathBuf}, +}; /// A path to either a single solidity file or a Solc Standard JSON file #[derive(Debug, Clone)] diff --git a/crates/pyrometer/src/analyzer_backend.rs b/crates/pyrometer/src/analyzer_backend.rs index 610b44ec..3c7fcf4f 100644 --- a/crates/pyrometer/src/analyzer_backend.rs +++ b/crates/pyrometer/src/analyzer_backend.rs @@ -1,30 +1,22 @@ use crate::Analyzer; use graph::{ - AnalyzerBackend, Node, Edge, VarType, - nodes::{ - Concrete, - FunctionParamNode, - ConcreteNode, - MsgNode, - BlockNode, - FunctionParam, - FunctionReturn, - Builtin, - Function, - } + nodes::{ + BlockNode, Builtin, Concrete, ConcreteNode, Function, FunctionParam, FunctionParamNode, + FunctionReturn, MsgNode, + }, + AnalyzerBackend, Edge, Node, VarType, }; -use shared::{AnalyzerLike, NodeIdx, GraphLike}; -use solc_expressions::{IntoExprErr, ExprErr}; +use shared::{AnalyzerLike, GraphLike, NodeIdx}; +use solc_expressions::{ExprErr, IntoExprErr}; use ethers_core::types::U256; -use solang_parser::{pt::Expression, helpers::CodeLocation}; +use solang_parser::{helpers::CodeLocation, pt::Expression}; use std::collections::HashMap; impl AnalyzerBackend for Analyzer {} - impl AnalyzerLike for Analyzer { type Expr = Expression; type ExprErr = ExprErr; @@ -36,7 +28,6 @@ impl AnalyzerLike for Analyzer { type FunctionReturn = FunctionReturn; type Builtin = Builtin; - fn builtin_fn_nodes(&self) -> &HashMap { &self.builtin_fn_nodes } @@ -232,4 +223,4 @@ impl AnalyzerLike for Analyzer { None } } -} \ No newline at end of file +} diff --git a/crates/pyrometer/src/builtin_fns.rs b/crates/pyrometer/src/builtin_fns.rs index 83175f73..d996a30f 100644 --- a/crates/pyrometer/src/builtin_fns.rs +++ b/crates/pyrometer/src/builtin_fns.rs @@ -1,6 +1,4 @@ -use graph::nodes::{ - Builtin, Function, FunctionParam, FunctionReturn -}; +use graph::nodes::{Builtin, Function, FunctionParam, FunctionReturn}; use shared::{AnalyzerLike, GraphLike}; use solang_parser::pt::{FunctionAttribute, Identifier, Loc, StorageLocation, Visibility}; diff --git a/crates/pyrometer/src/graph_backend.rs b/crates/pyrometer/src/graph_backend.rs index 588368eb..d47b89e1 100644 --- a/crates/pyrometer/src/graph_backend.rs +++ b/crates/pyrometer/src/graph_backend.rs @@ -1,26 +1,21 @@ use crate::Analyzer; -use shared::{GraphDot, NodeIdx, GraphLike, Search}; use graph::{ - ContextEdge, AnalyzerBackend, as_dot_str, AsDotStr, GraphBackend, Node, Edge, - nodes::ContextNode, + as_dot_str, nodes::ContextNode, AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, + Node, }; +use shared::{GraphDot, GraphLike, NodeIdx, Search}; -use petgraph::{ - Direction, Graph, Directed, - graph::EdgeIndex, - dot::Dot, - visit::EdgeRef, -}; +use petgraph::{dot::Dot, graph::EdgeIndex, visit::EdgeRef, Directed, Direction, Graph}; use std::{ collections::BTreeSet, - sync::{Mutex, Arc}, + sync::{Arc, Mutex}, }; impl GraphLike for Analyzer { - type Node = Node; - type Edge = Edge; + type Node = Node; + type Edge = Edge; fn graph_mut(&mut self) -> &mut Graph { &mut self.graph } @@ -557,8 +552,6 @@ flowchart BT dot_str.push(edges_str); dot_str.join("\n") } - - } struct G<'a> { @@ -608,4 +601,4 @@ pub fn mermaid_node( } node_str -} \ No newline at end of file +} diff --git a/crates/pyrometer/src/lib.rs b/crates/pyrometer/src/lib.rs index 99454bef..bedfe8d6 100644 --- a/crates/pyrometer/src/lib.rs +++ b/crates/pyrometer/src/lib.rs @@ -1,8 +1,6 @@ mod analyzer; -mod builtin_fns; mod analyzer_backend; +mod builtin_fns; mod graph_backend; pub use analyzer::*; - - diff --git a/crates/pyrometer/tests/helpers.rs b/crates/pyrometer/tests/helpers.rs index 1d159513..75c8a1f0 100644 --- a/crates/pyrometer/tests/helpers.rs +++ b/crates/pyrometer/tests/helpers.rs @@ -1,11 +1,11 @@ +use analyzers::FunctionVarsBoundAnalyzer; use analyzers::ReportConfig; use analyzers::ReportDisplay; -use analyzers::FunctionVarsBoundAnalyzer; -use shared::Search; use ariadne::sources; +use graph::{nodes::FunctionNode, Edge}; use pyrometer::{Analyzer, SourcePath}; use shared::NodeIdx; -use graph::{nodes::FunctionNode, Edge}; +use shared::Search; use std::collections::BTreeMap; use std::collections::HashMap; use std::path::PathBuf; diff --git a/crates/queries/src/lib.rs b/crates/queries/src/lib.rs index 3ac5e78c..325bbed8 100644 --- a/crates/queries/src/lib.rs +++ b/crates/queries/src/lib.rs @@ -1 +1 @@ -//! Currently Empty \ No newline at end of file +//! Currently Empty diff --git a/crates/shared/src/analyzer_like.rs b/crates/shared/src/analyzer_like.rs index 028cd523..9d323e7e 100644 --- a/crates/shared/src/analyzer_like.rs +++ b/crates/shared/src/analyzer_like.rs @@ -22,8 +22,6 @@ pub trait AnalyzerLike: GraphLike { /// Type of a builtin type Builtin; - - /// Gets the builtin functions map fn builtin_fns(&self) -> &HashMap; /// Mutably gets the builtin functions map @@ -43,10 +41,12 @@ pub trait AnalyzerLike: GraphLike { fn add_expr_err(&mut self, err: Self::ExprErr); fn expr_errs(&self) -> Vec; - fn builtin_fn_inputs(&self) -> &HashMap, Vec)>; + fn builtin_fn_inputs( + &self, + ) -> &HashMap, Vec)>; fn builtins(&self) -> &HashMap; fn builtins_mut(&mut self) -> &mut HashMap; - + fn builtin_or_add(&mut self, builtin: Self::Builtin) -> NodeIdx; // { // if let Some(idx) = self.builtins().get(&builtin) { @@ -91,7 +91,6 @@ pub trait AnalyzerLike: GraphLike { // } // } - fn add_if_err(&mut self, err: Result) -> Option { match err { Ok(t) => Some(t), @@ -101,4 +100,4 @@ pub trait AnalyzerLike: GraphLike { } } } -} \ No newline at end of file +} diff --git a/crates/shared/src/graph_like.rs b/crates/shared/src/graph_like.rs index 10015bab..5d6f2972 100644 --- a/crates/shared/src/graph_like.rs +++ b/crates/shared/src/graph_like.rs @@ -1,15 +1,14 @@ -use crate::Heirarchical; use crate::AnalyzerLike; +use crate::Heirarchical; -use std::{ - sync::{Arc, Mutex}, - collections::BTreeSet -}; use petgraph::{ + graph::{EdgeIndex, Graph, NodeIndex}, Directed, - graph::{Graph, EdgeIndex, NodeIndex} }; - +use std::{ + collections::BTreeSet, + sync::{Arc, Mutex}, +}; pub type NodeIdx = NodeIndex; pub type EdgeIdx = EdgeIndex; @@ -53,10 +52,10 @@ pub trait GraphLike { /// A trait that constructs dot-like visualization strings (either mermaid or graphviz) pub trait GraphDot: GraphLike { /// Open a dot using graphviz - fn open_dot(&self) + fn open_dot(&self) where Self: std::marker::Sized, - Self: AnalyzerLike + Self: AnalyzerLike, { use std::env::temp_dir; use std::fs; @@ -83,7 +82,7 @@ pub trait GraphDot: GraphLike { .expect("failed to execute process"); } - /// Creates a subgraph for visually identifying contexts and subcontexts + /// Creates a subgraph for visually identifying contexts and subcontexts fn cluster_str( &self, node: NodeIdx, @@ -113,4 +112,4 @@ pub trait GraphDot: GraphLike { where Self: std::marker::Sized, Self: AnalyzerLike; -} \ No newline at end of file +} diff --git a/crates/shared/src/lib.rs b/crates/shared/src/lib.rs index 5391d213..88f88d06 100644 --- a/crates/shared/src/lib.rs +++ b/crates/shared/src/lib.rs @@ -1,7 +1,7 @@ -mod graph_like; mod analyzer_like; +mod graph_like; mod search; -pub use search::*; +pub use analyzer_like::*; pub use graph_like::*; -pub use analyzer_like::*; \ No newline at end of file +pub use search::*; diff --git a/crates/shared/src/search.rs b/crates/shared/src/search.rs index fd5757e4..c048f7a4 100644 --- a/crates/shared/src/search.rs +++ b/crates/shared/src/search.rs @@ -1,18 +1,28 @@ -use std::collections::{BTreeSet, BTreeMap}; +use std::collections::{BTreeMap, BTreeSet}; -use crate::{NodeIdx, GraphLike}; -use petgraph::{visit::EdgeRef, graph::*, Direction}; +use crate::{GraphLike, NodeIdx}; +use petgraph::{graph::*, visit::EdgeRef, Direction}; pub trait Heirarchical { fn heirarchical_num(&self) -> usize; } -impl Search for T where T: GraphLike, ::Edge: Ord + PartialEq + Heirarchical + Copy {} +impl Search for T +where + T: GraphLike, + ::Edge: Ord + PartialEq + Heirarchical + Copy, +{ +} /// A trait for searching through a graph pub trait Search: GraphLike - where ::Edge: PartialEq + Heirarchical + Copy +where + ::Edge: PartialEq + Heirarchical + Copy, { - fn search_for_ancestor(&self, start: NodeIdx, edge_ty: &::Edge) -> Option { + fn search_for_ancestor( + &self, + start: NodeIdx, + edge_ty: &::Edge, + ) -> Option { tracing::trace!("searching for ancestor"); let edges = self.graph().edges_directed(start, Direction::Outgoing); if let Some(edge) = edges.clone().find(|edge| edge.weight() == edge_ty) { @@ -26,7 +36,11 @@ pub trait Search: GraphLike } } - fn search_for_ancestor_multi(&self, start: NodeIdx, edge_tys: &[::Edge]) -> Option { + fn search_for_ancestor_multi( + &self, + start: NodeIdx, + edge_tys: &[::Edge], + ) -> Option { tracing::trace!("searching for ancestor_multi"); let edges = self.graph().edges_directed(start, Direction::Outgoing); if let Some(edge) = edges.clone().find(|edge| edge_tys.contains(edge.weight())) { @@ -40,7 +54,11 @@ pub trait Search: GraphLike } } - fn search_children_same_heirarchy(&self, start: NodeIdx, edge_ty: &::Edge) -> BTreeSet { + fn search_children_same_heirarchy( + &self, + start: NodeIdx, + edge_ty: &::Edge, + ) -> BTreeSet { tracing::trace!("search_children_same_heirarchy"); let num = edge_ty.heirarchical_num(); let edges = self @@ -71,7 +89,11 @@ pub trait Search: GraphLike /// i.e.: a -my_edge-> b -other_edge-> c -my_edge-> d /// /// This function would build a set { b, d } if we are looking for `my_edge` and start at a. - fn search_children(&self, start: NodeIdx, edge_ty: &::Edge) -> BTreeSet { + fn search_children( + &self, + start: NodeIdx, + edge_ty: &::Edge, + ) -> BTreeSet { tracing::trace!("search_children"); let mut seen = Default::default(); self.search_children_prevent_cycle(start, edge_ty, &mut seen) @@ -428,7 +450,15 @@ pub trait Search: GraphLike fn edges_for_nodes( &self, nodes: &BTreeSet, - ) -> BTreeSet<(NodeIdx, NodeIdx, ::Edge, EdgeIndex)> where ::Edge: Ord { + ) -> BTreeSet<( + NodeIdx, + NodeIdx, + ::Edge, + EdgeIndex, + )> + where + ::Edge: Ord, + { tracing::trace!("children_edges"); nodes @@ -437,7 +467,12 @@ pub trait Search: GraphLike self.graph() .edges_directed(*node, Direction::Incoming) .map(|edge| (edge.source(), edge.target(), *edge.weight(), edge.id())) - .collect::::Edge, EdgeIndex)>>() + .collect::::Edge, + EdgeIndex, + )>>() }) .collect() } @@ -446,7 +481,15 @@ pub trait Search: GraphLike fn children_edges( &self, start: NodeIdx, - ) -> BTreeSet<(NodeIdx, NodeIdx, ::Edge, EdgeIndex)> where ::Edge: Ord { + ) -> BTreeSet<( + NodeIdx, + NodeIdx, + ::Edge, + EdgeIndex, + )> + where + ::Edge: Ord, + { tracing::trace!("children_edges"); let mut seen = Default::default(); self.children_edges_prevent_cycle(start, &mut seen) @@ -456,7 +499,15 @@ pub trait Search: GraphLike &self, start: NodeIdx, seen: &mut BTreeSet, - ) -> BTreeSet<(NodeIdx, NodeIdx, ::Edge, EdgeIndex)> where ::Edge: Ord { + ) -> BTreeSet<( + NodeIdx, + NodeIdx, + ::Edge, + EdgeIndex, + )> + where + ::Edge: Ord, + { if seen.contains(&start) { return Default::default(); } else { @@ -464,7 +515,12 @@ pub trait Search: GraphLike } let edges = self.graph().edges_directed(start, Direction::Incoming); - let mut this_children_edges: BTreeSet<(NodeIdx, NodeIdx, ::Edge, EdgeIndex)> = edges + let mut this_children_edges: BTreeSet<( + NodeIdx, + NodeIdx, + ::Edge, + EdgeIndex, + )> = edges .clone() .map(|edge| (edge.source(), edge.target(), *edge.weight(), edge.id())) .collect(); @@ -472,7 +528,12 @@ pub trait Search: GraphLike this_children_edges.extend( edges .flat_map(|edge| self.children_edges_prevent_cycle(edge.source(), seen)) - .collect::::Edge, EdgeIndex)>>(), + .collect::::Edge, + EdgeIndex, + )>>(), ); this_children_edges } @@ -534,4 +595,4 @@ pub trait Search: GraphLike Some(map) } } -} \ No newline at end of file +} diff --git a/crates/solc-expressions/src/array.rs b/crates/solc-expressions/src/array.rs index 9d51681f..a870b1e5 100644 --- a/crates/solc-expressions/src/array.rs +++ b/crates/solc-expressions/src/array.rs @@ -1,12 +1,9 @@ -use crate::{ - ContextBuilder, IntoExprErr, - ExprErr, member_access::MemberAccess, require::Require, -}; +use crate::{member_access::MemberAccess, require::Require, ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{Builtin, ContextVar, ContextVarNode, ContextNode, ExprRet}, - elem::RangeOp + elem::RangeOp, + nodes::{Builtin, ContextNode, ContextVar, ContextVarNode, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, Node, VarType, }; use solang_parser::{ diff --git a/crates/solc-expressions/src/bin_op.rs b/crates/solc-expressions/src/bin_op.rs index 117b7f9c..8df465ea 100644 --- a/crates/solc-expressions/src/bin_op.rs +++ b/crates/solc-expressions/src/bin_op.rs @@ -1,9 +1,12 @@ -use crate::{ContextBuilder, IntoExprErr, ExprErr, require::Require}; +use crate::{require::Require, ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{BuiltInNode, Builtin, ContextNode, ContextVarNode, ContextVar, TmpConstruction, Concrete, KilledKind, ExprRet, }, - elem::*, Range, RangeEval, SolcRange + elem::*, + nodes::{ + BuiltInNode, Builtin, Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet, + KilledKind, TmpConstruction, + }, + AnalyzerBackend, ContextEdge, Edge, Node, Range, RangeEval, SolcRange, VarType, }; use ethers_core::types::{I256, U256}; @@ -302,8 +305,8 @@ pub trait BinOp: AnalyzerBackend + Sized { // }), Elem::from(Concrete::from(U256::from(1))).cast( Elem::from(Reference::new(tmp_rhs.into())), // .range_min(self) - // .into_expr_err(loc)? - // .expect("No range minimum?"), + // .into_expr_err(loc)? + // .expect("No range minimum?"), ), ); diff --git a/crates/solc-expressions/src/cmp.rs b/crates/solc-expressions/src/cmp.rs index b3fe62ad..a773584c 100644 --- a/crates/solc-expressions/src/cmp.rs +++ b/crates/solc-expressions/src/cmp.rs @@ -1,9 +1,12 @@ -use crate::{ContextBuilder, IntoExprErr, ExprErr}; +use crate::{ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Node, VarType, GraphError, - nodes::{BuiltInNode, Builtin, ContextNode, ContextVarNode, ContextVar, TmpConstruction, Concrete, ExprRet, }, - elem::*, Range, SolcRange + elem::*, + nodes::{ + BuiltInNode, Builtin, Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet, + TmpConstruction, + }, + AnalyzerBackend, GraphError, Node, Range, SolcRange, VarType, }; use solang_parser::pt::{Expression, Loc}; diff --git a/crates/solc-expressions/src/cond_op.rs b/crates/solc-expressions/src/cond_op.rs index 4b271aed..00ac50e9 100644 --- a/crates/solc-expressions/src/cond_op.rs +++ b/crates/solc-expressions/src/cond_op.rs @@ -1,15 +1,16 @@ -use crate::{ContextBuilder, IntoExprErr, ExprErr, require::Require}; +use crate::{require::Require, ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, ContextEdge, - nodes::{Context, ContextNode, } + nodes::{Context, ContextNode}, + AnalyzerBackend, ContextEdge, Edge, Node, }; use shared::NodeIdx; use solang_parser::pt::CodeLocation; use solang_parser::pt::{Expression, Loc, Statement}; -impl CondOp for T where T: AnalyzerBackend + Require + Sized {} +impl CondOp for T where T: AnalyzerBackend + Require + Sized +{} pub trait CondOp: AnalyzerBackend + Require + Sized { #[tracing::instrument(level = "trace", skip_all)] fn cond_op_stmt( diff --git a/crates/solc-expressions/src/context_builder/mod.rs b/crates/solc-expressions/src/context_builder/mod.rs index f49d60b0..25bb1696 100644 --- a/crates/solc-expressions/src/context_builder/mod.rs +++ b/crates/solc-expressions/src/context_builder/mod.rs @@ -1,19 +1,22 @@ use crate::{ - yul::YulBuilder, func_call::FuncCaller, loops::Looper, ExprParser, IntoExprErr, ExprErr + func_call::FuncCaller, loops::Looper, yul::YulBuilder, ExprErr, ExprParser, IntoExprErr, }; use graph::{ - GraphBackend, AnalyzerBackend, Edge, Node, VarType, ContextEdge, GraphError, - nodes::{FunctionReturnNode, FunctionParamNode, Context, KilledKind, Builtin, FunctionNode, ContextNode, ContextVarNode, ContextVar, Concrete, ExprRet, }, - elem::*, Range + elem::*, + nodes::{ + Builtin, Concrete, Context, ContextNode, ContextVar, ContextVarNode, ExprRet, FunctionNode, + FunctionParamNode, FunctionReturnNode, KilledKind, + }, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, GraphError, Node, Range, VarType, }; use shared::NodeIdx; use ethers_core::types::{I256, U256}; use petgraph::{visit::EdgeRef, Direction}; use solang_parser::{ - pt::{VariableDeclaration, YulStatement, Expression, Loc, Statement}, - helpers::CodeLocation + helpers::CodeLocation, + pt::{Expression, Loc, Statement, VariableDeclaration, YulStatement}, }; impl ContextBuilder for T where @@ -987,7 +990,8 @@ pub trait ContextBuilder: fn delete_match( ctx: ContextNode, loc: &Loc, - analyzer: &mut (impl GraphBackend + AnalyzerBackend), + analyzer: &mut (impl GraphBackend + + AnalyzerBackend), ret: ExprRet, ) { match ret { diff --git a/crates/solc-expressions/src/env.rs b/crates/solc-expressions/src/env.rs index ea18f207..13e82ce1 100644 --- a/crates/solc-expressions/src/env.rs +++ b/crates/solc-expressions/src/env.rs @@ -1,11 +1,11 @@ -use crate::{func_call::FuncCaller, IntoExprErr, ExprErr}; +use crate::{func_call::FuncCaller, ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, ContextEdge, - nodes::{Builtin, ContextNode, ContextVar, Concrete, ExprRet, } + nodes::{Builtin, Concrete, ContextNode, ContextVar, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, Node, }; -use solang_parser::pt::{Loc, Expression, Identifier}; +use solang_parser::pt::{Expression, Identifier, Loc}; impl Env for T where T: AnalyzerBackend + Sized {} pub trait Env: AnalyzerBackend + Sized { diff --git a/crates/solc-expressions/src/func_call/internal_call.rs b/crates/solc-expressions/src/func_call/internal_call.rs index 443d11d4..029fce88 100644 --- a/crates/solc-expressions/src/func_call/internal_call.rs +++ b/crates/solc-expressions/src/func_call/internal_call.rs @@ -1,10 +1,8 @@ -use crate::{ - ContextBuilder, IntoExprErr, ExprErr, FuncCaller -}; +use crate::{ContextBuilder, ExprErr, FuncCaller, IntoExprErr}; use graph::{ - GraphBackend, AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{Builtin, ContextNode, ContextVarNode, ContextVar, Concrete, ExprRet, }, + nodes::{Builtin, Concrete, ContextNode, ContextVar, ContextVarNode, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, VarType, }; use solang_parser::pt::{Expression, Identifier, Loc, NamedArgument}; diff --git a/crates/solc-expressions/src/func_call/intrinsic_call.rs b/crates/solc-expressions/src/func_call/intrinsic_call.rs index d62ce87d..4f585e82 100644 --- a/crates/solc-expressions/src/func_call/intrinsic_call.rs +++ b/crates/solc-expressions/src/func_call/intrinsic_call.rs @@ -1,15 +1,17 @@ use crate::{ - ContextBuilder, IntoExprErr, ExprErr, FuncCaller, - require::Require, array::Array, - member_access::MemberAccess, + array::Array, member_access::MemberAccess, require::Require, ContextBuilder, ExprErr, + FuncCaller, IntoExprErr, }; use graph::{ - GraphBackend, AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{TyNode, StructNode, BuiltInNode, Builtin, Context, ContextNode, ContextVarNode, ContextVar, Concrete, ExprRet, }, - elem::*, Range, SolcRange + elem::*, + nodes::{ + BuiltInNode, Builtin, Concrete, Context, ContextNode, ContextVar, ContextVarNode, ExprRet, + StructNode, TyNode, + }, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, Range, SolcRange, VarType, }; -use shared::{Search, NodeIdx}; +use shared::{NodeIdx, Search}; use ethers_core::types::U256; use solang_parser::pt::{Expression, Loc}; diff --git a/crates/solc-expressions/src/func_call/mod.rs b/crates/solc-expressions/src/func_call/mod.rs index bac2a516..e1d0e5e7 100644 --- a/crates/solc-expressions/src/func_call/mod.rs +++ b/crates/solc-expressions/src/func_call/mod.rs @@ -1,22 +1,22 @@ use crate::{ - ContextBuilder, IntoExprErr, ExprErr, - namespaced_call::NameSpaceFuncCaller, - internal_call::InternalFuncCaller, - intrinsic_call::IntrinsicFuncCaller + internal_call::InternalFuncCaller, intrinsic_call::IntrinsicFuncCaller, + namespaced_call::NameSpaceFuncCaller, ContextBuilder, ExprErr, IntoExprErr, }; use graph::{ - GraphBackend, AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{FunctionNode, ModifierState, FunctionParamNode, FunctionReturnNode, CallFork, Context, ContextNode, ContextVarNode, ContextVar, ExprRet, }, - Range, + nodes::{ + CallFork, Context, ContextNode, ContextVar, ContextVarNode, ExprRet, FunctionNode, + FunctionParamNode, FunctionReturnNode, ModifierState, + }, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, Range, VarType, }; use shared::NodeIdx; -use std::cell::RefCell; -use std::rc::Rc; use solang_parser::helpers::CodeLocation; -use std::collections::BTreeMap; use solang_parser::pt::{Expression, Loc, NamedArgument, StorageLocation}; +use std::cell::RefCell; +use std::collections::BTreeMap; +use std::rc::Rc; pub mod internal_call; pub mod intrinsic_call; diff --git a/crates/solc-expressions/src/func_call/modifier.rs b/crates/solc-expressions/src/func_call/modifier.rs index 8a6e21f5..a6d56a05 100644 --- a/crates/solc-expressions/src/func_call/modifier.rs +++ b/crates/solc-expressions/src/func_call/modifier.rs @@ -1,10 +1,8 @@ -use crate::{ - IntoExprErr, ExprErr, FuncCaller -}; +use crate::{ExprErr, FuncCaller, IntoExprErr}; use graph::{ - GraphBackend, AnalyzerBackend, - nodes::{FunctionNode, ContextNode, ExprRet, } + nodes::{ContextNode, ExprRet, FunctionNode}, + AnalyzerBackend, GraphBackend, }; use solang_parser::pt::{Expression, Loc}; @@ -30,4 +28,4 @@ pub trait ModifierCaller: todo!() } -} \ No newline at end of file +} diff --git a/crates/solc-expressions/src/func_call/namespaced_call.rs b/crates/solc-expressions/src/func_call/namespaced_call.rs index 8fa6eb7b..1086c7d9 100644 --- a/crates/solc-expressions/src/func_call/namespaced_call.rs +++ b/crates/solc-expressions/src/func_call/namespaced_call.rs @@ -1,13 +1,11 @@ use crate::{ - FuncCaller, - ContextBuilder, IntoExprErr, ExprErr, - member_access::MemberAccess, - intrinsic_call::IntrinsicFuncCaller + intrinsic_call::IntrinsicFuncCaller, member_access::MemberAccess, ContextBuilder, ExprErr, + FuncCaller, IntoExprErr, }; use graph::{ + nodes::{BuiltInNode, ContextNode, ContextVarNode, ExprRet, FunctionNode}, AnalyzerBackend, GraphBackend, Node, - nodes::{BuiltInNode, FunctionNode, ContextNode, ContextVarNode, ExprRet, } }; use shared::NodeIdx; diff --git a/crates/solc-expressions/src/lib.rs b/crates/solc-expressions/src/lib.rs index 5b7d450d..5c25648a 100644 --- a/crates/solc-expressions/src/lib.rs +++ b/crates/solc-expressions/src/lib.rs @@ -20,8 +20,8 @@ pub use bin_op::*; pub use cmp::*; pub use cond_op::*; pub use context_builder::*; -pub use func_call::*; pub use env::*; +pub use func_call::*; pub use list::*; pub use literal::*; pub use loops::*; @@ -144,9 +144,7 @@ impl ExprErr { GraphError(_loc, graph::GraphError::MaxStackWidthReached(msg), ..) => msg, GraphError(_loc, graph::GraphError::ChildRedefinition(msg), ..) => msg, GraphError(_loc, graph::GraphError::DetachedVariable(msg), ..) => msg, - GraphError(_loc, graph::GraphError::VariableUpdateInOldContext(msg), ..) => { - msg - } + GraphError(_loc, graph::GraphError::VariableUpdateInOldContext(msg), ..) => msg, GraphError(_loc, graph::GraphError::ExpectedSingle(msg), ..) => msg, GraphError(_loc, graph::GraphError::StackLengthMismatch(msg), ..) => msg, GraphError(_loc, graph::GraphError::UnbreakableRecursion(msg), ..) => msg, diff --git a/crates/solc-expressions/src/list.rs b/crates/solc-expressions/src/list.rs index 5b94b01c..c4b6b5a8 100644 --- a/crates/solc-expressions/src/list.rs +++ b/crates/solc-expressions/src/list.rs @@ -1,11 +1,11 @@ -use crate::{ContextBuilder, IntoExprErr, ExprErr}; +use crate::{ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{ContextNode, ContextVar, ExprRet, } + nodes::{ContextNode, ContextVar, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, Node, VarType, }; -use solang_parser::pt::{Parameter, ParameterList, Loc, Expression}; +use solang_parser::pt::{Expression, Loc, Parameter, ParameterList}; impl List for T where T: AnalyzerBackend + Sized {} diff --git a/crates/solc-expressions/src/literal.rs b/crates/solc-expressions/src/literal.rs index d8c1f25f..242834ae 100644 --- a/crates/solc-expressions/src/literal.rs +++ b/crates/solc-expressions/src/literal.rs @@ -1,13 +1,13 @@ -use crate::{IntoExprErr, ExprErr}; +use crate::{ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, ContextEdge, - nodes::{Builtin, ConcreteNode, ContextNode, ContextVarNode, ContextVar, Concrete, ExprRet, }, elem::*, + nodes::{Builtin, Concrete, ConcreteNode, ContextNode, ContextVar, ContextVarNode, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, Node, }; -use ethers_core::types::{H256, I256, U256, Address}; -use solang_parser::pt::{Identifier, HexLiteral, Loc}; +use ethers_core::types::{Address, H256, I256, U256}; +use solang_parser::pt::{HexLiteral, Identifier, Loc}; use std::str::FromStr; diff --git a/crates/solc-expressions/src/loops.rs b/crates/solc-expressions/src/loops.rs index dd64713b..c7aec51a 100644 --- a/crates/solc-expressions/src/loops.rs +++ b/crates/solc-expressions/src/loops.rs @@ -1,14 +1,19 @@ -use crate::{ContextBuilder, IntoExprErr, ExprErr}; +use crate::{ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - GraphBackend, AnalyzerBackend, Node, - nodes::{Context, ContextNode, }, + nodes::{Context, ContextNode}, + AnalyzerBackend, GraphBackend, Node, }; -use solang_parser::pt::{Loc, Expression, Statement}; +use solang_parser::pt::{Expression, Loc, Statement}; -impl Looper for T where T: AnalyzerBackend + Sized + GraphBackend {} -pub trait Looper: GraphBackend + AnalyzerBackend + Sized { +impl Looper for T where + T: AnalyzerBackend + Sized + GraphBackend +{ +} +pub trait Looper: + GraphBackend + AnalyzerBackend + Sized +{ #[tracing::instrument(level = "trace", skip_all)] fn for_loop( &mut self, diff --git a/crates/solc-expressions/src/member_access/mod.rs b/crates/solc-expressions/src/member_access/mod.rs index 682768b7..798f3a72 100644 --- a/crates/solc-expressions/src/member_access/mod.rs +++ b/crates/solc-expressions/src/member_access/mod.rs @@ -1,9 +1,12 @@ -use crate::{ContextBuilder, Variable, Env, IntoExprErr, ExprErr}; +use crate::{ContextBuilder, Env, ExprErr, IntoExprErr, Variable}; use graph::{ - AnalyzerBackend, Edge, Node, VarType, ContextEdge, TypeNode, - nodes::{BuiltInNode, Builtin, FunctionNode, StructNode, EnumNode, TyNode, ContractNode, ContextNode, ContextVarNode, ContextVar, Concrete, ExprRet, }, - elem::*, Range, SolcRange + elem::*, + nodes::{ + BuiltInNode, Builtin, Concrete, ContextNode, ContextVar, ContextVarNode, ContractNode, + EnumNode, ExprRet, FunctionNode, StructNode, TyNode, + }, + AnalyzerBackend, ContextEdge, Edge, Node, Range, SolcRange, TypeNode, VarType, }; use shared::NodeIdx; diff --git a/crates/solc-expressions/src/require.rs b/crates/solc-expressions/src/require.rs index 6a6b57df..2d2469c4 100644 --- a/crates/solc-expressions/src/require.rs +++ b/crates/solc-expressions/src/require.rs @@ -1,9 +1,13 @@ -use crate::{ContextBuilder, BinOp, Variable, IntoExprErr, ExprErr}; +use crate::{BinOp, ContextBuilder, ExprErr, IntoExprErr, Variable}; use graph::{ - AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{BuiltInNode, Builtin, ConcreteNode, ContextNode, ContextVarNode, ContextVar, TmpConstruction, Concrete, KilledKind, ExprRet, }, - elem::*, Range, RangeEval, SolcRange, range_string::ToRangeString, + elem::*, + nodes::{ + BuiltInNode, Builtin, Concrete, ConcreteNode, ContextNode, ContextVar, ContextVarNode, + ExprRet, KilledKind, TmpConstruction, + }, + range_string::ToRangeString, + AnalyzerBackend, ContextEdge, Edge, Node, Range, RangeEval, SolcRange, VarType, }; use ethers_core::types::I256; diff --git a/crates/solc-expressions/src/variable.rs b/crates/solc-expressions/src/variable.rs index 502de6b6..ba91ba49 100644 --- a/crates/solc-expressions/src/variable.rs +++ b/crates/solc-expressions/src/variable.rs @@ -1,11 +1,11 @@ -use crate::{ContextBuilder, env::Env, IntoExprErr, ExprErr}; +use crate::{env::Env, ContextBuilder, ExprErr, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, ContextEdge, - nodes::{VarNode, ContextNode, ContextVar, ExprRet, } + nodes::{ContextNode, ContextVar, ExprRet, VarNode}, + AnalyzerBackend, ContextEdge, Edge, Node, }; -use solang_parser::pt::{Identifier, Expression}; +use solang_parser::pt::{Expression, Identifier}; impl Variable for T where T: AnalyzerBackend + Sized {} diff --git a/crates/solc-expressions/src/yul/mod.rs b/crates/solc-expressions/src/yul/mod.rs index 2a0a98c2..ddcba561 100644 --- a/crates/solc-expressions/src/yul/mod.rs +++ b/crates/solc-expressions/src/yul/mod.rs @@ -1,8 +1,8 @@ -use crate::{ContextBuilder, ExprParser, IntoExprErr, ExprErr}; +use crate::{ContextBuilder, ExprErr, ExprParser, IntoExprErr}; use graph::{ - AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{Builtin, Context, ContextNode, ContextVarNode, ContextVar, ExprRet, }, + nodes::{Builtin, Context, ContextNode, ContextVar, ContextVarNode, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, Node, VarType, }; use solang_parser::{ diff --git a/crates/solc-expressions/src/yul/yul_cond_op.rs b/crates/solc-expressions/src/yul/yul_cond_op.rs index 2616e18b..8faf7127 100644 --- a/crates/solc-expressions/src/yul/yul_cond_op.rs +++ b/crates/solc-expressions/src/yul/yul_cond_op.rs @@ -1,21 +1,25 @@ -use crate::{YulBuilder, ContextBuilder, IntoExprErr, ExprErr, require::Require}; +use crate::{require::Require, ContextBuilder, ExprErr, IntoExprErr, YulBuilder}; use graph::{ - AnalyzerBackend, Edge, Node, ContextEdge, - nodes::{ConcreteNode, Context, ContextNode, ContextVarNode, ContextVar, Concrete, ExprRet, }, - elem::* + elem::*, + nodes::{Concrete, ConcreteNode, Context, ContextNode, ContextVar, ContextVarNode, ExprRet}, + AnalyzerBackend, ContextEdge, Edge, Node, }; use shared::NodeIdx; use ethers_core::types::U256; use solang_parser::pt::{ - Identifier, YulBlock, YulFunctionCall, YulSwitchOptions, CodeLocation, - Expression, Loc, YulExpression, YulStatement + CodeLocation, Expression, Identifier, Loc, YulBlock, YulExpression, YulFunctionCall, + YulStatement, YulSwitchOptions, }; -impl YulCondOp for T where T: AnalyzerBackend + Require + Sized -{} -pub trait YulCondOp: AnalyzerBackend + Require + Sized { +impl YulCondOp for T where + T: AnalyzerBackend + Require + Sized +{ +} +pub trait YulCondOp: + AnalyzerBackend + Require + Sized +{ #[tracing::instrument(level = "trace", skip_all)] fn yul_cond_op_stmt( &mut self, diff --git a/crates/solc-expressions/src/yul/yul_funcs.rs b/crates/solc-expressions/src/yul/yul_funcs.rs index 473bc4f4..ad712560 100644 --- a/crates/solc-expressions/src/yul/yul_funcs.rs +++ b/crates/solc-expressions/src/yul/yul_funcs.rs @@ -1,18 +1,20 @@ -use crate::{ContextBuilder, Cmp, Env, YulBuilder, BinOp, IntoExprErr, ExprErr}; +use crate::{BinOp, Cmp, ContextBuilder, Env, ExprErr, IntoExprErr, YulBuilder}; use graph::{ - GraphBackend, AnalyzerBackend, Edge, Node, VarType, ContextEdge, - nodes::{Builtin, ConcreteNode, ContextNode, ContextVarNode, ContextVar, Concrete, KilledKind, ExprRet, }, - elem::*, SolcRange + elem::*, + nodes::{ + Builtin, Concrete, ConcreteNode, ContextNode, ContextVar, ContextVarNode, ExprRet, + KilledKind, + }, + AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, SolcRange, VarType, }; use ethers_core::types::U256; -use solang_parser::pt::{YulExpression, YulFunctionCall, Expression, Loc, StorageLocation}; +use solang_parser::pt::{Expression, Loc, StorageLocation, YulExpression, YulFunctionCall}; use std::cell::RefCell; use std::rc::Rc; - impl YulFuncCaller for T where T: AnalyzerBackend + Sized + GraphBackend { @@ -745,4 +747,4 @@ pub trait YulFuncCaller: Ok(()) } } -} \ No newline at end of file +}