lhs = lhs->unwrap_any_unmergeable ();
rhs = rhs->unwrap_any_unmergeable ();
- /* Nothing can be known about unknown values. */
- if (lhs->get_kind () == SK_UNKNOWN
- || rhs->get_kind () == SK_UNKNOWN)
+ /* Nothing can be known about unknown/poisoned values. */
+ if (!lhs->can_have_associated_state_p ()
+ || !rhs->can_have_associated_state_p ())
/* Not a contradiction. */
return true;
{
equiv_class_id result (-1);
- gcc_assert (sval->get_kind () != SK_UNKNOWN);
+ gcc_assert (sval->can_have_associated_state_p ());
/* Convert all NULL pointers to (void *) to avoid state explosions
involving all of the various (foo *)NULL vs (bar *)NULL. */
if (model == NULL)
return;
- /* Reject attempts to set state on UNKNOWN. */
- if (sval->get_kind () == SK_UNKNOWN)
+ /* Reject attempts to set state on UNKNOWN/POISONED. */
+ if (!sval->can_have_associated_state_p ())
return;
equiv_class &ec = model->get_constraints ()->get_equiv_class (sval);
if (get_state (sval, ext_state) == state)
return false;
+ gcc_assert (sval->can_have_associated_state_p ());
+
/* Special-case state 0 as the default value. */
if (state == 0)
{
/* Ops on "unknown" are also unknown. */
if (arg->get_kind () == SK_UNKNOWN)
return get_or_create_unknown_svalue (type);
+ /* Likewise for "poisoned". */
+ else if (const poisoned_svalue *poisoned_sval
+ = arg->dyn_cast_poisoned_svalue ())
+ return get_or_create_poisoned_svalue (poisoned_sval->get_poison_kind (),
+ type);
+
+ gcc_assert (arg->can_have_associated_state_p ());
switch (op)
{
get_or_create_binop (size_type_node, op,
binop->get_arg1 (), arg1));
- /* Ops on "unknown" are also unknown (unless we can use one of the
- identities above). */
- if (arg0->get_kind () == SK_UNKNOWN
- || arg1->get_kind () == SK_UNKNOWN)
- return get_or_create_unknown_svalue (type);
-
/* etc. */
return NULL;
if (const svalue *folded = maybe_fold_binop (type, op, arg0, arg1))
return folded;
+ /* Ops on "unknown"/"poisoned" are unknown (unless we were able to fold
+ it via an identity in maybe_fold_binop). */
+ if (!arg0->can_have_associated_state_p ()
+ || !arg1->can_have_associated_state_p ())
+ return get_or_create_unknown_svalue (type);
+
binop_svalue::key_t key (type, op, arg0, arg1);
if (binop_svalue **slot = m_binop_values_map.get (key))
return *slot;
const svalue *parent_svalue,
const region *subregion)
{
- /* Subvalues of "unknown" are unknown. */
- if (parent_svalue->get_kind () == SK_UNKNOWN)
+ /* Subvalues of "unknown"/"poisoned" are unknown. */
+ if (!parent_svalue->can_have_associated_state_p ())
return get_or_create_unknown_svalue (type);
/* If we have a subregion of a zero-fill, it's zero. */
const svalue *outer_size,
const svalue *inner_svalue)
{
+ /* Repeated "unknown"/"poisoned" is unknown. */
+ if (!outer_size->can_have_associated_state_p ()
+ || !inner_svalue->can_have_associated_state_p ())
+ return get_or_create_unknown_svalue (type);
+
/* If INNER_SVALUE is the same size as OUTER_SIZE,
turn into simply a cast. */
if (tree cst_outer_num_bytes = outer_size->maybe_get_constant ())
region_model::purge_state_involving (const svalue *sval,
region_model_context *ctxt)
{
+ if (!sval->can_have_associated_state_p ())
+ return;
m_store.purge_state_involving (sval, m_mgr);
m_constraints->purge_state_involving (sval);
m_dynamic_extents.purge_state_involving (sval);
type),
m_parent_svalue (parent_svalue), m_subregion (subregion)
{
+ gcc_assert (parent_svalue->can_have_associated_state_p ());
}
/* Implementation of svalue::dump_to_pp vfunc for sub_svalue. */
m_outer_size (outer_size),
m_inner_svalue (inner_svalue)
{
+ gcc_assert (outer_size->can_have_associated_state_p ());
+ gcc_assert (inner_svalue->can_have_associated_state_p ());
}
/* Implementation of svalue::dump_to_pp vfunc for repeated_svalue. */
m_bits (bits),
m_inner_svalue (inner_svalue)
{
+ gcc_assert (inner_svalue->can_have_associated_state_p ());
}
/* Implementation of svalue::dump_to_pp vfunc for bits_within_svalue. */
virtual bool all_zeroes_p () const;
+ /* Can this svalue be involved in constraints and sm-state?
+ Most can, but UNKNOWN and POISONED svalues are singletons
+ per-type and thus it's meaningless for them to "have state". */
+ virtual bool can_have_associated_state_p () const { return true; }
+
protected:
svalue (complexity c, tree type)
: m_complexity (c), m_type (type)
maybe_fold_bits_within (tree type,
const bit_range &subrange,
region_model_manager *mgr) const FINAL OVERRIDE;
+
+ /* Unknown values are singletons per-type, so can't have state. */
+ bool can_have_associated_state_p () const FINAL OVERRIDE { return false; }
};
/* An enum describing a particular kind of "poisoned" value. */
enum poison_kind get_poison_kind () const { return m_kind; }
+ /* Poisoned svalues are singletons per-type, so can't have state. */
+ bool can_have_associated_state_p () const FINAL OVERRIDE { return false; }
+
private:
enum poison_kind m_kind;
};
unaryop_svalue (tree type, enum tree_code op, const svalue *arg)
: svalue (complexity (arg), type), m_op (op), m_arg (arg)
{
+ gcc_assert (arg->can_have_associated_state_p ());
}
enum svalue_kind get_kind () const FINAL OVERRIDE { return SK_UNARYOP; }
type),
m_op (op), m_arg0 (arg0), m_arg1 (arg1)
{
+ gcc_assert (arg0->can_have_associated_state_p ());
+ gcc_assert (arg1->can_have_associated_state_p ());
}
enum svalue_kind get_kind () const FINAL OVERRIDE { return SK_BINOP; }
m_point (point.get_function_point ()),
m_base_sval (base_sval), m_iter_sval (iter_sval)
{
+ gcc_assert (base_sval->can_have_associated_state_p ());
+ gcc_assert (iter_sval->can_have_associated_state_p ());
}
enum svalue_kind get_kind () const FINAL OVERRIDE { return SK_WIDENING; }
--- /dev/null
+/* { dg-additional-options "--param analyzer-max-svalue-depth=0" } */
+
+int val;
+
+int
+fn (void)
+{
+ val = fn ();
+
+ return 0;
+}