From e5e1e1181c9b5d34042a8da155977c5799182420 Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Wed, 25 Sep 2024 00:25:08 -0700 Subject: [PATCH] Remove uninitialized, discrete_set, discrete_set_max_cardinality from BVS args --- claripy/ast/base.py | 10 ++++------ claripy/ast/bv.py | 18 +----------------- claripy/backends/backend_vsa/backend_vsa.py | 7 ++----- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/claripy/ast/base.py b/claripy/ast/base.py index a874b6727..7bfbe3b8a 100644 --- a/claripy/ast/base.py +++ b/claripy/ast/base.py @@ -178,7 +178,7 @@ def __new__( # pylint:disable=redefined-builtin symbolic: bool | None = None, variables: frozenset[str] | None = None, errored: set[Backend] | None = None, - uninitialized: bool | None = None, + uninitialized: bool = False, annotations: tuple[Annotation, ...] = (), skip_child_annotations: bool = False, length: int | None = None, @@ -275,7 +275,7 @@ def make_like( annotations: tuple[Annotation, ...] | None = None, variables: frozenset[str] | None = None, symbolic: bool | None = None, - uninitialized: bool | None = None, + uninitialized: bool = False, skip_child_annotations: bool = False, length: int | None = None, ) -> Self: @@ -288,7 +288,7 @@ def make_like( and annotations and variables is None and symbolic is None - and uninitialized is None + and uninitialized is False and skip_child_annotations and length is not None ): @@ -357,7 +357,7 @@ def __a_init__( length: int | None = None, simplified: SimplificationLevel = SimplificationLevel.UNSIMPLIFIED, errored: set[Backend] | None = None, - uninitialized: bool | None = None, + uninitialized: bool = False, annotations: tuple[Annotation, ...] | None = None, encoded_name: bytes | None = None, depth: int | None = None, @@ -775,8 +775,6 @@ def _op_repr( if args[3] is not None: fmt = "%#x" if isinstance(args[3], int) else "%s" extras.append("stride=%s" % (fmt % args[3])) - if args[4] is True: - extras.append("UNINITIALIZED") return "{}{}".format(args[0], "{{{}}}".format(", ".join(extras)) if extras else "") if op == "BoolV": diff --git a/claripy/ast/bv.py b/claripy/ast/bv.py index cf606dbe8..c5cda08c0 100644 --- a/claripy/ast/bv.py +++ b/claripy/ast/bv.py @@ -202,10 +202,7 @@ def BVS( # pylint:disable=redefined-builtin min=None, max=None, stride=None, - uninitialized=False, explicit_name=None, - discrete_set=False, - discrete_set_max_card=None, **kwargs, ) -> BV: """ @@ -219,12 +216,7 @@ def BVS( # pylint:disable=redefined-builtin :param min: The minimum value of the symbol, used only for value-set analysis :param max: The maximum value of the symbol, used only for value-set analysis :param stride: The stride of the symbol, used only for value-set analysis - :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. - :param bool discrete_set: If True, a DiscreteStridedIntervalSet will be used instead of a normal StridedInterval. - :param int discrete_set_max_card: The maximum cardinality of the discrete set. It is ignored if discrete_set is set - to False or None. :returns: a BV object representing this symbol. """ @@ -240,16 +232,12 @@ def BVS( # pylint:disable=redefined-builtin n = _make_name(name, size, False if explicit_name is None else explicit_name) encoded_name = n.encode() - if not discrete_set: - discrete_set_max_card = None - return BV( "BVS", - (n, min, max, stride, uninitialized, discrete_set, discrete_set_max_card), + (n, min, max, stride), variables=frozenset((n,)), length=size, symbolic=True, - uninitialized=uninitialized, encoded_name=encoded_name, **kwargs, ) @@ -307,8 +295,6 @@ def SI( stride=None, to_conv=None, explicit_name=None, - discrete_set=False, - discrete_set_max_card=None, ): name = "unnamed" if name is None else name if to_conv is not None: @@ -325,8 +311,6 @@ def SI( max=upper_bound, stride=stride, explicit_name=explicit_name, - discrete_set=discrete_set, - discrete_set_max_card=discrete_set_max_card, ) diff --git a/claripy/backends/backend_vsa/backend_vsa.py b/claripy/backends/backend_vsa/backend_vsa.py index 6568a939b..0ed09b273 100644 --- a/claripy/backends/backend_vsa/backend_vsa.py +++ b/claripy/backends/backend_vsa/backend_vsa.py @@ -308,18 +308,15 @@ def SGE(a, b): return a.SGE(b) @staticmethod - def BVS(ast): + def BVS(ast: Base): size = ast.size() - name, mn, mx, stride, uninitialized, discrete_set, max_card = ast.args + name, mn, mx, stride = ast.args return CreateStridedInterval( name=name, bits=size, lower_bound=mn, upper_bound=mx, stride=stride, - uninitialized=uninitialized, - discrete_set=discrete_set, - discrete_set_max_cardinality=max_card, ) def If(self, cond, t, f):