Skip to content

Commit 36e1e0f

Browse files
committed
SSA steps: don't guess the property id, set it during construction
There is no need for a method that tries to reverse engineer the property id of an assertion: we just store the id in an SSA step when building that step.
1 parent 6e13f53 commit 36e1e0f

13 files changed

+40
-49
lines changed

src/goto-checker/bmc_util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ssa_step_matches_failing_property(const irep_idt &property_id)
5757
return [property_id](
5858
symex_target_equationt::SSA_stepst::const_iterator step,
5959
const decision_proceduret &decision_procedure) {
60-
return step->is_assert() && step->get_property_id() == property_id &&
60+
return step->is_assert() && step->property_id == property_id &&
6161
decision_procedure.get(step->cond_handle).is_false();
6262
};
6363
}
@@ -246,7 +246,7 @@ void update_properties_status_from_symex_target_equation(
246246
if(!step.is_assert())
247247
continue;
248248

249-
irep_idt property_id = step.get_property_id();
249+
const irep_idt &property_id = step.property_id;
250250
CHECK_RETURN(!property_id.empty());
251251

252252
// Don't update status of properties that are constant 'false';

src/goto-checker/goto_symex_fault_localizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ const SSA_stept &goto_symex_fault_localizert::collect_guards(
6969
localization_points.emplace(l, emplace_result.first);
7070
}
7171
}
72-
73-
// reached failed assertion?
74-
if(step.is_assert() && step.get_property_id() == failed_property_id)
72+
else if(step.is_assert() && step.property_id == failed_property_id)
73+
{
7574
return step;
75+
}
7676
}
7777
UNREACHABLE;
7878
}

src/goto-checker/goto_symex_property_decider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void goto_symex_property_decidert::
5151
{
5252
if(it->is_assert())
5353
{
54-
irep_idt property_id = it->get_property_id();
54+
const irep_idt &property_id = it->property_id;
5555
CHECK_RETURN(!property_id.empty());
5656

5757
// consider goal instance if it is in the given properties

src/goto-symex/build_goto_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void build_goto_trace(
343343
if(SSA_step.is_assert())
344344
{
345345
goto_trace_step.comment = SSA_step.comment;
346-
goto_trace_step.property_id = SSA_step.get_property_id();
346+
goto_trace_step.property_id = SSA_step.property_id;
347347
}
348348
goto_trace_step.type = SSA_step.type;
349349
goto_trace_step.hidden = SSA_step.hidden;

src/goto-symex/goto_symex.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,16 @@ class goto_symext
377377
value_sett *jump_not_taken_value_set,
378378
const namespacet &ns);
379379

380+
/// Symbolically execute a verification condition (assertion).
381+
/// \param cond: The guard of the assumption
382+
/// \param property_id: Unique property identifier of this assertion
383+
/// \param msg: The message associated with this assertion
384+
/// \param state: Symbolic execution state for current instruction
380385
virtual void vcc(
381-
const exprt &,
386+
const exprt &cond,
387+
const irep_idt &property_id,
382388
const std::string &msg,
383-
statet &);
389+
statet &state);
384390

385391
/// Symbolically execute an ASSUME instruction or simulate such an execution
386392
/// for a synthetic assumption

src/goto-symex/ssa_step.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ void SSA_stept::validate(const namespacet &ns, const validation_modet vm) const
132132
switch(type)
133133
{
134134
case goto_trace_stept::typet::ASSERT:
135+
DATA_CHECK(vm, !property_id.empty(), "missing property id in assert step");
135136
case goto_trace_stept::typet::ASSUME:
136137
case goto_trace_stept::typet::GOTO:
137138
case goto_trace_stept::typet::CONSTRAINT:
@@ -184,36 +185,6 @@ void SSA_stept::validate(const namespacet &ns, const validation_modet vm) const
184185
}
185186
}
186187

187-
irep_idt SSA_stept::get_property_id() const
188-
{
189-
PRECONDITION(is_assert());
190-
191-
irep_idt property_id;
192-
193-
if(source.pc->is_assert())
194-
{
195-
property_id = source.pc->source_location().get_property_id();
196-
}
197-
else if(source.pc->is_goto())
198-
{
199-
// this is likely an unwinding assertion
200-
property_id = id2string(source.pc->source_location().get_function()) +
201-
".unwind." + std::to_string(source.pc->loop_number);
202-
}
203-
else if(source.pc->is_function_call())
204-
{
205-
// this is likely a recursion unwinding assertion
206-
property_id =
207-
id2string(source.pc->source_location().get_function()) + ".recursion";
208-
}
209-
else
210-
{
211-
UNREACHABLE;
212-
}
213-
214-
return property_id;
215-
}
216-
217188
SSA_assignment_stept::SSA_assignment_stept(
218189
symex_targett::sourcet source,
219190
exprt _guard,

src/goto-symex/ssa_step.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@ class SSA_stept
129129
return type == goto_trace_stept::typet::ATOMIC_END;
130130
}
131131

132-
/// Returns the property ID if this is a step resulting from an ASSERT, or
133-
/// builds a unique name for an unwinding assertion.
134-
irep_idt get_property_id() const;
135-
136132
// we may choose to hide
137133
bool hidden = false;
138134

@@ -149,6 +145,8 @@ class SSA_stept
149145
exprt cond_expr;
150146
exprt cond_handle;
151147
std::string comment;
148+
// for ASSERT
149+
irep_idt property_id;
152150

153151
exprt get_ssa_expr() const
154152
{

src/goto-symex/symex_function_call.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,13 @@ void goto_symext::symex_function_call_post_clean(
246246
if(stop_recursing)
247247
{
248248
if(symex_config.unwinding_assertions)
249-
vcc(false_exprt(), "recursion unwinding assertion", state);
249+
{
250+
vcc(
251+
false_exprt(),
252+
id2string(identifier) + ".recursion",
253+
"recursion unwinding assertion",
254+
state);
255+
}
250256
if(!symex_config.partial_loops)
251257
{
252258
// Rule out this path:

src/goto-symex/symex_goto.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ void goto_symext::loop_bound_exceeded(
923923
statet &state,
924924
const exprt &guard)
925925
{
926-
const unsigned loop_number=state.source.pc->loop_number;
926+
const std::string loop_number = std::to_string(state.source.pc->loop_number);
927927

928928
exprt negated_cond;
929929

@@ -937,7 +937,9 @@ void goto_symext::loop_bound_exceeded(
937937
// Generate VCC for unwinding assertion.
938938
vcc(
939939
negated_cond,
940-
"unwinding assertion loop " + std::to_string(loop_number),
940+
id2string(state.source.pc->source_location().get_function()) +
941+
".unwind." + loop_number,
942+
"unwinding assertion loop " + loop_number,
941943
state);
942944
}
943945

src/goto-symex/symex_main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,13 @@ void goto_symext::symex_assert(
179179
if(msg.empty())
180180
msg = "assertion";
181181

182-
vcc(l2_condition, msg, state);
182+
vcc(
183+
l2_condition, instruction.source_location().get_property_id(), msg, state);
183184
}
184185

185186
void goto_symext::vcc(
186187
const exprt &condition,
188+
const irep_idt &property_id,
187189
const std::string &msg,
188190
statet &state)
189191
{
@@ -196,7 +198,8 @@ void goto_symext::vcc(
196198
const exprt guarded_condition = state.guard.guard_expr(condition);
197199

198200
state.remaining_vccs++;
199-
target.assertion(state.guard.as_expr(), guarded_condition, msg, state.source);
201+
target.assertion(
202+
state.guard.as_expr(), guarded_condition, property_id, msg, state.source);
200203
}
201204

202205
void goto_symext::symex_assume(statet &state, const exprt &cond)

src/goto-symex/symex_target.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,16 @@ class symex_targett
233233
/// Record an assertion.
234234
/// \param guard: Precondition for reaching this assertion
235235
/// \param cond: Condition this assertion represents
236+
/// \param property_id: Unique property identifier of this assertion
236237
/// \param msg: The message associated with this assertion
237238
/// \param source: Pointer to location in the input GOTO program of this
238239
/// assertion
239240
virtual void assertion(
240241
const exprt &guard,
241242
const exprt &cond,
243+
const irep_idt &property_id,
242244
const std::string &msg,
243-
const sourcet &source)=0;
245+
const sourcet &source) = 0;
244246

245247
/// Record a goto instruction.
246248
/// \param guard: Precondition for reaching this goto instruction

src/goto-symex/symex_target_equation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ void symex_target_equationt::assumption(
282282
void symex_target_equationt::assertion(
283283
const exprt &guard,
284284
const exprt &cond,
285+
const irep_idt &property_id,
285286
const std::string &msg,
286287
const sourcet &source)
287288
{
@@ -291,6 +292,7 @@ void symex_target_equationt::assertion(
291292
SSA_step.guard=guard;
292293
SSA_step.cond_expr=cond;
293294
SSA_step.comment=msg;
295+
SSA_step.property_id = property_id;
294296

295297
merge_ireps(SSA_step);
296298
}

src/goto-symex/symex_target_equation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class symex_target_equationt:public symex_targett
130130
virtual void assertion(
131131
const exprt &guard,
132132
const exprt &cond,
133+
const irep_idt &property_id,
133134
const std::string &msg,
134135
const sourcet &source);
135136

0 commit comments

Comments
 (0)