Skip to content

Commit

Permalink
Remove uninitialized member from Base
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Oct 4, 2024
1 parent 9bbd134 commit a5d2d42
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 163 deletions.
3 changes: 0 additions & 3 deletions claripy/algorithm/simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ def simplify(expr: T) -> T:
log.debug("Unable to simplify expression")
return expr

# Copy some parameters (that should really go to the Annotation backend)
simplified._uninitialized = expr.uninitialized

# dealing with annotations
if expr.annotations:
ast_args = tuple(a for a in expr.args if isinstance(a, Base))
Expand Down
28 changes: 0 additions & 28 deletions claripy/ast/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ class Base:
# Caching
_cached_encoded_name: bytes | None

# Extra information
_uninitialized: bool

__slots__ = [
"op",
"args",
Expand All @@ -141,7 +138,6 @@ class Base:
"_relocatable_annotations",
"_errored",
"_cached_encoded_name",
"_uninitialized",
"__weakref__",
]

Expand All @@ -156,7 +152,6 @@ def __new__( # pylint:disable=redefined-builtin
symbolic: bool | None = None,
variables: frozenset[str] | None = None,
errored: set[Backend] | None = None,
uninitialized: bool = False,
annotations: tuple[Annotation, ...] = (),
skip_child_annotations: bool = False,
length: int | None = None,
Expand Down Expand Up @@ -230,7 +225,6 @@ def __new__( # pylint:disable=redefined-builtin
symbolic=symbolic,
length=length,
errored=errored,
uninitialized=uninitialized,
annotations=annotations,
encoded_name=encoded_name,
depth=depth,
Expand All @@ -253,7 +247,6 @@ def make_like(
annotations: tuple[Annotation, ...] | None = None,
variables: frozenset[str] | None = None,
symbolic: bool | None = None,
uninitialized: bool = False,
skip_child_annotations: bool = False,
length: int | None = None,
) -> Self:
Expand All @@ -266,7 +259,6 @@ def make_like(
and annotations
and variables is None
and symbolic is None
and uninitialized is False
and skip_child_annotations
and length is not None
):
Expand Down Expand Up @@ -294,7 +286,6 @@ def make_like(
symbolic=self.symbolic,
annotations=annotations,
length=length,
uninitialized=self._uninitialized,
)

result._hash = h
Expand All @@ -309,8 +300,6 @@ def make_like(
annotations = self.annotations if not args or not any(self is arg for arg in args) else ()
if variables is None and op in all_operations:
variables = self.variables
if uninitialized is None:
uninitialized = self._uninitialized
if symbolic is None and op in all_operations:
symbolic = self.symbolic

Expand All @@ -319,7 +308,6 @@ def make_like(
args if simplified is None else simplified.args,
annotations=annotations,
variables=variables,
uninitialized=uninitialized,
symbolic=symbolic,
skip_child_annotations=skip_child_annotations,
length=length,
Expand All @@ -335,7 +323,6 @@ def __a_init__(
length: int | None = None,
simplified: SimplificationLevel = SimplificationLevel.UNSIMPLIFIED,
errored: set[Backend] | None = None,
uninitialized: bool = False,
annotations: tuple[Annotation, ...] | None = None,
encoded_name: bytes | None = None,
depth: int | None = None,
Expand Down Expand Up @@ -368,8 +355,6 @@ def __a_init__(

self._simplified = simplified

self._uninitialized = uninitialized

if len(self.args) == 0:
raise ClaripyOperationError("AST with no arguments!")

Expand Down Expand Up @@ -1061,16 +1046,3 @@ def cardinality(self) -> int:
@property
def concrete(self) -> bool:
return not self.symbolic

@property
def uninitialized(self) -> bool:
"""
Whether this AST comes from an uninitialized dereference or not. It's only used in under-constrained symbolic
execution mode.
:returns: True/False/None (unspecified).
"""

# TODO: It should definitely be moved to the proposed Annotation backend.

return self._uninitialized
4 changes: 2 additions & 2 deletions claripy/ast/bv.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ def SI(
)


def TSI(bits, name=None, uninitialized=False, explicit_name=None):
def TSI(bits, name=None, explicit_name=None):
name = "unnamed" if name is None else name
return BVS(name, bits, uninitialized=uninitialized, explicit_name=explicit_name)
return BVS(name, bits, explicit_name=explicit_name)


def ESI(bits, **kwargs):
Expand Down
5 changes: 1 addition & 4 deletions claripy/ast/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ def indexOf(self, pattern, start_idx):
return StrIndexOf(self, pattern, start_idx)


def StringS(name, uninitialized=False, explicit_name=False, **kwargs):
def StringS(name, explicit_name=False, **kwargs):
"""
Create a new symbolic string (analogous to z3.String())
:param name: The name of the symbolic string (i. e. the name of the variable)
:param uninitialized: Whether this value should be counted as an "uninitialized" value in the course of an
analysis.
:param bool explicit_name: If False, an identifier is appended to the name to ensure uniqueness.
:returns: The String object representing the symbolic string
Expand All @@ -63,7 +61,6 @@ def StringS(name, uninitialized=False, explicit_name=False, **kwargs):
"StringS",
(n,),
symbolic=True,
uninitialized=uninitialized,
variables=frozenset((n,)),
**kwargs,
)
Expand Down
4 changes: 2 additions & 2 deletions claripy/backends/backend_vsa/backend_vsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ def widen(self, ast):
return ret

@staticmethod
def CreateTopStridedInterval(bits, name=None, uninitialized=False):
return StridedInterval.top(bits, name, uninitialized=uninitialized)
def CreateTopStridedInterval(bits, name=None):
return StridedInterval.top(bits, name)

def constraint_to_si(self, expr):
return Balancer(self, expr).compat_ret
Expand Down
Loading

0 comments on commit a5d2d42

Please sign in to comment.