Skip to content

Commit 16daaa9

Browse files
authored
Merge pull request #6699 from tautschnig/cleanup/partial-loops
SSA steps: don't guess the property id, set it during construction
2 parents 87e992b + 5c4503f commit 16daaa9

13 files changed

+42
-49
lines changed

Diff for: src/goto-checker/bmc_util.cpp

+2-2
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';

Diff for: src/goto-checker/goto_symex_fault_localizer.cpp

+3-3
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
}

Diff for: src/goto-checker/goto_symex_property_decider.cpp

+1-1
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

Diff for: src/goto-symex/build_goto_trace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void build_goto_trace(
346346
if(SSA_step.is_assert())
347347
{
348348
goto_trace_step.comment = SSA_step.comment;
349-
goto_trace_step.property_id = SSA_step.get_property_id();
349+
goto_trace_step.property_id = SSA_step.property_id;
350350
}
351351
goto_trace_step.type = SSA_step.type;
352352
goto_trace_step.hidden = SSA_step.hidden;

Diff for: src/goto-symex/goto_symex.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,16 @@ class goto_symext
376376
value_sett *jump_not_taken_value_set,
377377
const namespacet &ns);
378378

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

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

Diff for: src/goto-symex/ssa_step.cpp

+1-30
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void SSA_stept::validate(const namespacet &ns, const validation_modet vm) const
133133
switch(type)
134134
{
135135
case goto_trace_stept::typet::ASSERT:
136+
DATA_CHECK(vm, !property_id.empty(), "missing property id in assert step");
136137
case goto_trace_stept::typet::ASSUME:
137138
case goto_trace_stept::typet::GOTO:
138139
case goto_trace_stept::typet::CONSTRAINT:
@@ -185,36 +186,6 @@ void SSA_stept::validate(const namespacet &ns, const validation_modet vm) const
185186
}
186187
}
187188

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

Diff for: src/goto-symex/ssa_step.h

+2-4
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 (which includes loop unwinding assertions)
149+
irep_idt property_id;
152150

153151
exprt get_ssa_expr() const
154152
{

Diff for: src/goto-symex/symex_function_call.cpp

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

Diff for: src/goto-symex/symex_goto.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void goto_symext::loop_bound_exceeded(
927927
statet &state,
928928
const exprt &guard)
929929
{
930-
const unsigned loop_number=state.source.pc->loop_number;
930+
const std::string loop_number = std::to_string(state.source.pc->loop_number);
931931

932932
exprt negated_cond;
933933

@@ -939,9 +939,13 @@ void goto_symext::loop_bound_exceeded(
939939
if(symex_config.unwinding_assertions)
940940
{
941941
// Generate VCC for unwinding assertion.
942+
const std::string property_id =
943+
id2string(state.source.pc->source_location().get_function()) +
944+
".unwind." + loop_number;
942945
vcc(
943946
negated_cond,
944-
"unwinding assertion loop " + std::to_string(loop_number),
947+
property_id,
948+
"unwinding assertion loop " + loop_number,
945949
state);
946950
}
947951

Diff for: src/goto-symex/symex_main.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ void goto_symext::symex_assert(
176176
if(msg.empty())
177177
msg = "assertion";
178178

179-
vcc(l2_condition, msg, state);
179+
vcc(
180+
l2_condition, instruction.source_location().get_property_id(), msg, state);
180181
}
181182

182183
void goto_symext::vcc(
183184
const exprt &condition,
185+
const irep_idt &property_id,
184186
const std::string &msg,
185187
statet &state)
186188
{
@@ -193,7 +195,8 @@ void goto_symext::vcc(
193195
const exprt guarded_condition = state.guard.guard_expr(condition);
194196

195197
state.remaining_vccs++;
196-
target.assertion(state.guard.as_expr(), guarded_condition, msg, state.source);
198+
target.assertion(
199+
state.guard.as_expr(), guarded_condition, property_id, msg, state.source);
197200
}
198201

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

Diff for: src/goto-symex/symex_target.h

+3-1
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

Diff for: src/goto-symex/symex_target_equation.cpp

+2
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
}

Diff for: src/goto-symex/symex_target_equation.h

+1
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)