return;
}
- check_for_writable_region (dest_reg, cd.get_ctxt ());
+ check_region_for_write (dest_reg, cd.get_ctxt ());
/* Otherwise, mark region's contents as unknown. */
mark_region_as_unknown (dest_reg, cd.get_uncertainty ());
const region *sized_dest_reg = m_mgr->get_sized_region (dest_reg,
NULL_TREE,
num_bytes_sval);
- check_for_writable_region (sized_dest_reg, cd.get_ctxt ());
+ check_region_for_write (sized_dest_reg, cd.get_ctxt ());
fill_region (sized_dest_reg, fill_value_u8);
return true;
}
cd.maybe_set_lhs (dest_sval);
- check_for_writable_region (dest_reg, cd.get_ctxt ());
+ check_region_for_write (dest_reg, cd.get_ctxt ());
/* For now, just mark region's contents as unknown. */
mark_region_as_unknown (dest_reg, cd.get_uncertainty ());
gcc_assert (TREE_CODE (first_bit_offset) == INTEGER_CST);
bit_range bits (TREE_INT_CST_LOW (first_bit_offset),
TREE_INT_CST_LOW (num_bits));
- return get_rvalue_for_bits (TREE_TYPE (expr), reg, bits);
+ return get_rvalue_for_bits (TREE_TYPE (expr), reg, bits, ctxt);
}
case SSA_NAME:
case ARRAY_REF:
{
const region *reg = get_lvalue (pv, ctxt);
- return get_store_value (reg);
+ return get_store_value (reg, ctxt);
}
case REALPART_EXPR:
case MEM_REF:
{
const region *ref_reg = get_lvalue (pv, ctxt);
- return get_store_value (ref_reg);
+ return get_store_value (ref_reg, ctxt);
}
}
}
}
/* Get a value for REG, looking it up in the store, or otherwise falling
- back to "initial" or "unknown" values. */
+ back to "initial" or "unknown" values.
+ Use CTXT to report any warnings associated with reading from REG. */
const svalue *
-region_model::get_store_value (const region *reg) const
+region_model::get_store_value (const region *reg,
+ region_model_context *ctxt) const
{
+ check_region_for_read (reg, ctxt);
+
/* Special-case: handle var_decls in the constant pool. */
if (const decl_region *decl_reg = reg->dyn_cast_decl_region ())
if (const svalue *sval = decl_reg->maybe_get_constant_value (m_mgr))
/* Attempt to get BITS within any value of REG, as TYPE.
In particular, extract values from compound_svalues for the case
where there's a concrete binding at BITS.
- Return an unknown svalue if we can't handle the given case. */
+ Return an unknown svalue if we can't handle the given case.
+ Use CTXT to report any warnings associated with reading from REG. */
const svalue *
region_model::get_rvalue_for_bits (tree type,
const region *reg,
- const bit_range &bits) const
+ const bit_range &bits,
+ region_model_context *ctxt) const
{
- const svalue *sval = get_store_value (reg);
+ const svalue *sval = get_store_value (reg, ctxt);
return m_mgr->get_or_create_bits_within (type, bits, sval);
}
return m_mgr->get_or_create_unknown_svalue (sizetype);
}
+/* If CTXT is non-NULL, use it to warn about any problems accessing REG,
+ using DIR to determine if this access is a read or write. */
+
+void
+region_model::check_region_access (const region *reg,
+ enum access_direction dir,
+ region_model_context *ctxt) const
+{
+ /* Fail gracefully if CTXT is NULL. */
+ if (!ctxt)
+ return;
+
+ switch (dir)
+ {
+ default:
+ gcc_unreachable ();
+ case DIR_READ:
+ /* Currently a no-op. */
+ break;
+ case DIR_WRITE:
+ check_for_writable_region (reg, ctxt);
+ break;
+ }
+}
+
+/* If CTXT is non-NULL, use it to warn about any problems writing to REG. */
+
+void
+region_model::check_region_for_write (const region *dest_reg,
+ region_model_context *ctxt) const
+{
+ check_region_access (dest_reg, DIR_WRITE, ctxt);
+}
+
+/* If CTXT is non-NULL, use it to warn about any problems reading from REG. */
+
+void
+region_model::check_region_for_read (const region *src_reg,
+ region_model_context *ctxt) const
+{
+ check_region_access (src_reg, DIR_READ, ctxt);
+}
+
/* Set the value of the region given by LHS_REG to the value given
- by RHS_SVAL. */
+ by RHS_SVAL.
+ Use CTXT to report any warnings associated with writing to LHS_REG. */
void
region_model::set_value (const region *lhs_reg, const svalue *rhs_sval,
gcc_assert (lhs_reg);
gcc_assert (rhs_sval);
- check_for_writable_region (lhs_reg, ctxt);
+ check_region_for_write (lhs_reg, ctxt);
m_store.set_value (m_mgr->get_store_manager(), lhs_reg, rhs_sval,
ctxt ? ctxt->get_uncertainty () : NULL);
const svalue *get_rvalue_for_bits (tree type,
const region *reg,
- const bit_range &bits) const;
+ const bit_range &bits,
+ region_model_context *ctxt) const;
void set_value (const region *lhs_reg, const svalue *rhs_sval,
region_model_context *ctxt);
static void append_ssa_names_cb (const region *base_reg,
struct append_ssa_names_cb_data *data);
- const svalue *get_store_value (const region *reg) const;
+ const svalue *get_store_value (const region *reg,
+ region_model_context *ctxt) const;
bool region_exists_p (const region *reg) const;
void check_for_writable_region (const region* dest_reg,
region_model_context *ctxt) const;
+ void check_region_access (const region *reg,
+ enum access_direction dir,
+ region_model_context *ctxt) const;
+ void check_region_for_write (const region *dest_reg,
+ region_model_context *ctxt) const;
+ void check_region_for_read (const region *src_reg,
+ region_model_context *ctxt) const;
/* Storing this here to avoid passing it around everywhere. */
region_model_manager *const m_mgr;