Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ExprErr and GraphErr location #84

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ fn main() {
if !args.funcs.is_empty() {
if args.funcs.iter().any(|analyze_for| {
FunctionNode::from(func)
.name(&mut analyzer)
.name(&analyzer)
.unwrap()
.starts_with(analyze_for)
}) {
Expand Down Expand Up @@ -509,7 +509,7 @@ fn main() {
let funcs = contract.funcs(&analyzer);
for func in funcs.into_iter() {
if !args.funcs.is_empty() {
if args.funcs.contains(&func.name(&mut analyzer).unwrap()) {
if args.funcs.contains(&func.name(&analyzer).unwrap()) {
let ctx = func.body_ctx(&mut analyzer);
let analysis = analyzer
.bounds_for_all(arena, &file_mapping, ctx, config)
Expand Down
24 changes: 0 additions & 24 deletions crates/graph/src/graph_elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,6 @@ pub trait AsDotStr {
) -> String;
}

#[derive(Debug, Clone, Ord, Eq, PartialEq, PartialOrd)]
pub enum GraphError {
/// The analyzer thought the node was suppose to be one type, but it was a different one
NodeConfusion(String),
/// Call depth limit reached
MaxStackDepthReached(String),
/// Fork width limit reached
MaxStackWidthReached(String),
/// Tried to set the subcontext of a context that already had a subcontext
ChildRedefinition(String),
/// Tried to update a variable that is in an old context
VariableUpdateInOldContext(String),
/// Variable is detached from all contexts
DetachedVariable(String),
/// Expected a single element, found multiple
ExpectedSingle(String),
/// Expected a vector with a certain number of elements, but it was a different number of elements
StackLengthMismatch(String),
/// A variable had a cyclic reference to another variable and we were unable to break the cycle
UnbreakableRecursion(String),
/// The analyzer thought the node was suppose to be one type, but it was a different one
UnknownVariable(String),
}

#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Node {
/// An analyzed function body/context
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/block.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{nodes::Concrete, range::elem::Elem, AsDotStr, GraphBackend, GraphError, Node};
use shared::{NodeIdx, RangeArena};
use crate::{nodes::Concrete, range::elem::Elem, AsDotStr, GraphBackend, Node};
use shared::{GraphError, NodeIdx, RangeArena};

use ethers_core::types::{Address, H256, U256};

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{nodes::Concrete, AnalyzerBackend, GraphBackend, GraphError, Node, SolcRange, VarType};
use crate::{nodes::Concrete, AnalyzerBackend, GraphBackend, Node, SolcRange, VarType};

use crate::range::elem::*;
use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

use ethers_core::types::{Address, H256, I256, U256};
use solang_parser::pt::{Expression, Loc, Type};
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/concrete.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{nodes::Builtin, AnalyzerBackend, GraphBackend, GraphError, Node, VarType};
use shared::NodeIdx;
use crate::{nodes::Builtin, AnalyzerBackend, GraphBackend, Node, VarType};
use shared::{GraphError, NodeIdx};

use ethers_core::types::{Address, H256, I256, U256};

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/expr_ret.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
nodes::{context::ContextVarNode, Concrete},
range::elem::Elem,
AsDotStr, GraphBackend, GraphError, Node, VarType,
AsDotStr, GraphBackend, Node, VarType,
};
use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

/// The reason a context was killed
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/node.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
nodes::{Concrete, Context, ContextVarNode, KilledKind},
range::elem::Elem,
AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node,
AnalyzerBackend, AsDotStr, GraphBackend, Node,
};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

use solang_parser::pt::Loc;

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/querying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::{
nodes::{
ContextNode, ContractNode, FunctionNode, SourceUnitNode, SourceUnitPartNode, StructNode,
},
AnalyzerBackend, ContextEdge, Edge, GraphBackend, GraphError,
AnalyzerBackend, ContextEdge, Edge, GraphBackend,
};

use shared::Search;
use shared::{GraphError, Search};
use std::collections::{BTreeMap, BTreeSet};

impl ContextNode {
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/solving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use crate::{
dl::{DLSolver, SolveStatus},
Atomize, SolverAtom,
},
AnalyzerBackend, GraphBackend, GraphError,
AnalyzerBackend, GraphBackend,
};
use std::borrow::Cow;

use shared::RangeArena;
use shared::{GraphError, RangeArena};

use std::collections::BTreeMap;

Expand Down
3 changes: 2 additions & 1 deletion crates/graph/src/nodes/context/typing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{
nodes::{ContextNode, FunctionNode},
AnalyzerBackend, GraphBackend, GraphError,
AnalyzerBackend, GraphBackend,
};
use shared::GraphError;

impl ContextNode {
/// Checks if its an anonymous function call (i.e. loop)
Expand Down
4 changes: 3 additions & 1 deletion crates/graph/src/nodes/context/underlying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ use crate::{
ModifierState,
},
solvers::dl::DLSolver,
AnalyzerBackend, GraphError,
AnalyzerBackend,
};

use shared::GraphError;

use solang_parser::pt::Loc;
use std::collections::BTreeSet;

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/var/node.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
nodes::{Concrete, ContextNode, ContextVar, TmpConstruction, VarNode},
range::{elem::*, range_string::ToRangeString, Range},
AsDotStr, ContextEdge, Edge, GraphBackend, GraphError, Node,
AsDotStr, ContextEdge, Edge, GraphBackend, Node,
};

use shared::{NodeIdx, RangeArena, Search, StorageLocation};
use shared::{GraphError, NodeIdx, RangeArena, Search, StorageLocation};

use petgraph::{visit::EdgeRef, Direction};
use solang_parser::pt::Loc;
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/var/ranging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::range::elem::*;
use crate::{
nodes::{Concrete, ContextVarNode},
range::{range_string::ToRangeString, Range, RangeEval},
AnalyzerBackend, GraphBackend, GraphError, SolcRange, VarType,
AnalyzerBackend, GraphBackend, SolcRange, VarType,
};

use shared::RangeArena;
use shared::{GraphError, RangeArena};

use solang_parser::pt::Loc;

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/var/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use crate::{
elem::{RangeElem, RangeExpr, RangeOp},
RangeEval,
},
AnalyzerBackend, ContextEdge, Edge, GraphBackend, GraphError, Node, VarType,
AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node, VarType,
};

use shared::{RangeArena, Search, StorageLocation};
use shared::{GraphError, RangeArena, Search, StorageLocation};

use ethers_core::types::{I256, U256};
use petgraph::{visit::EdgeRef, Direction};
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/var/underlying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::{
EnumNode, Field, FunctionNode, FunctionParam, FunctionReturn, StructNode, TyNode,
},
range::Range,
AnalyzerBackend, GraphBackend, GraphError, Node, SolcRange, TypeNode, VarType,
AnalyzerBackend, GraphBackend, Node, SolcRange, TypeNode, VarType,
};

use crate::range::elem::*;
use shared::{NodeIdx, StorageLocation};
use shared::{GraphError, NodeIdx, StorageLocation};

use solang_parser::pt::Loc;

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/context/var/versioning.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
nodes::{ContextNode, ContextVarNode},
ContextEdge, Edge, GraphBackend, GraphError,
ContextEdge, Edge, GraphBackend,
};

use shared::NodeIdx;
use shared::{GraphError, NodeIdx};

use petgraph::{visit::EdgeRef, Direction};

Expand Down
3 changes: 2 additions & 1 deletion crates/graph/src/nodes/context/variables.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{
nodes::{ContextNode, ContextVarNode, ExprRet},
AnalyzerBackend, ContextEdge, Edge, GraphBackend, GraphError, Node,
AnalyzerBackend, ContextEdge, Edge, GraphBackend, Node,
};
use shared::GraphError;

use solang_parser::pt::Loc;

Expand Down
3 changes: 2 additions & 1 deletion crates/graph/src/nodes/context/versioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use crate::ContextEdge;
use crate::Edge;
use crate::{
nodes::{CallFork, ContextNode, FunctionNode, KilledKind},
AnalyzerBackend, GraphBackend, GraphError, Node,
AnalyzerBackend, GraphBackend, Node,
};
use petgraph::visit::EdgeRef;
use petgraph::Direction;
use shared::GraphError;

use solang_parser::pt::Loc;

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/contract_ty.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
nodes::{Concrete, FunctionNode, SourceUnitNode, SourceUnitPartNode, StructNode, VarNode},
range::elem::Elem,
AnalyzerBackend, AsDotStr, Edge, GraphBackend, GraphError, Node,
AnalyzerBackend, AsDotStr, Edge, GraphBackend, Node,
};
use shared::{NodeIdx, RangeArena, Search};
use shared::{GraphError, NodeIdx, RangeArena, Search};

use petgraph::{visit::EdgeRef, Direction};
use solang_parser::pt::{ContractDefinition, ContractTy, Identifier, Loc};
Expand Down
6 changes: 2 additions & 4 deletions crates/graph/src/nodes/enum_ty.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::{
nodes::Concrete, range::elem::Elem, AsDotStr, GraphBackend, GraphError, Node, SolcRange,
};
use crate::{nodes::Concrete, range::elem::Elem, AsDotStr, GraphBackend, Node, SolcRange};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

use ethers_core::types::U256;
use solang_parser::pt::{EnumDefinition, Identifier, Loc};
Expand Down
6 changes: 2 additions & 4 deletions crates/graph/src/nodes/err_ty.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::{
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node,
};
use crate::{nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, Node};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};
use solang_parser::pt::{ErrorDefinition, ErrorParameter, Expression, Identifier, Loc};

#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
Expand Down
5 changes: 2 additions & 3 deletions crates/graph/src/nodes/func_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ use crate::{
nodes::Concrete,
nodes::{ContextNode, ContractNode, SourceUnitNode, SourceUnitPartNode},
range::elem::Elem,
AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, GraphError, Node, SolcRange,
VarType,
AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, Node, SolcRange, VarType,
};

use shared::{NodeIdx, RangeArena, Search, StorageLocation};
use shared::{GraphError, NodeIdx, RangeArena, Search, StorageLocation};

use petgraph::{visit::EdgeRef, Direction};
use solang_parser::{
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/msg.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
nodes::{Builtin, Concrete, ContextNode, ContextVar},
range::elem::Elem,
AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node,
AnalyzerBackend, AsDotStr, GraphBackend, Node,
};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

use ethers_core::types::{Address, U256};
use solang_parser::pt::Loc;
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/source_unit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
nodes::{Concrete, ContractNode, FunctionNode, SourceUnitPartNode, StructNode, VarNode},
range::elem::Elem,
AsDotStr, GraphBackend, GraphError, Node,
AsDotStr, GraphBackend, Node,
};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

#[derive(Default, Clone, Debug, PartialOrd, PartialEq, Ord, Eq)]
pub struct SourceUnit {
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/source_unit_part.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
nodes::{Concrete, ContractNode, FunctionNode, StructNode, VarNode},
range::elem::Elem,
AsDotStr, GraphBackend, GraphError, Node,
AsDotStr, GraphBackend, Node,
};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

#[derive(Default, Clone, Debug, PartialOrd, PartialEq, Ord, Eq)]
pub struct SourceUnitPart {
Expand Down
6 changes: 3 additions & 3 deletions crates/graph/src/nodes/struct_ty.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, Edge, GraphBackend, GraphError,
Node, VarType,
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, Edge, GraphBackend, Node,
VarType,
};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

use petgraph::{visit::EdgeRef, Direction};
use solang_parser::pt::{Expression, Identifier, Loc, StructDefinition, VariableDeclaration};
Expand Down
5 changes: 2 additions & 3 deletions crates/graph/src/nodes/ty_ty.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::{
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, GraphError, Node,
VarType,
nodes::Concrete, range::elem::Elem, AnalyzerBackend, AsDotStr, GraphBackend, Node, VarType,
};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

use solang_parser::pt::{Expression, Identifier, Loc, TypeDefinition};

Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/nodes/var_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::{
Concrete, ContextVar, ContextVarNode, ContractNode, SourceUnitNode, SourceUnitPartNode,
},
range::elem::Elem,
AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, GraphError, Node, VarType,
AnalyzerBackend, AsDotStr, ContextEdge, Edge, GraphBackend, Node, VarType,
};

use shared::{NodeIdx, RangeArena, Search};
use shared::{GraphError, NodeIdx, RangeArena, Search};

use petgraph::{visit::EdgeRef, Direction};
use solang_parser::pt::{
Expand Down
4 changes: 2 additions & 2 deletions crates/graph/src/range/elem/concrete.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
nodes::{Concrete, ContextVarNode},
range::elem::{Elem, RangeArenaLike, RangeElem},
GraphBackend, GraphError,
GraphBackend,
};

use shared::{NodeIdx, RangeArena};
use shared::{GraphError, NodeIdx, RangeArena};

use std::hash::{Hash, Hasher};

Expand Down
Loading
Loading