Skip to content

Commit 7b8e7fb

Browse files
Petr BauchPetr Bauch
Petr Bauch
authored and
Petr Bauch
committed
Fix based on comments
1 parent 43f402f commit 7b8e7fb

File tree

7 files changed

+25
-28
lines changed

7 files changed

+25
-28
lines changed

src/cbmc/bmc.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,6 @@ int bmct::do_language_agnostic_bmc(
637637
void bmct::perform_symbolic_execution(
638638
goto_symext::get_goto_functiont get_goto_function)
639639
{
640-
if(options.get_bool_option("validate-ssa-equation"))
641-
{
642-
symex.global_validation_mode = validation_modet::INVARIANT;
643-
}
644-
645640
symex.symex_from_entry_point_of(get_goto_function, symex_symbol_table);
646641

647642
if(options.get_bool_option("validate-ssa-equation"))

src/goto-symex/goto_symex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class goto_symext
7777
path_segment_vccs(0),
7878
_total_vccs(std::numeric_limits<unsigned>::max()),
7979
_remaining_vccs(std::numeric_limits<unsigned>::max()),
80-
global_validation_mode(validation_modet::IGNORE)
80+
run_validation_checks(options.get_bool_option("validate-ssa-equation"))
8181
{
8282
}
8383

@@ -524,7 +524,7 @@ class goto_symext
524524
{
525525
target.validate(ns, vm);
526526
}
527-
validation_modet global_validation_mode;
527+
bool run_validation_checks;
528528
};
529529

530530
#endif // CPROVER_GOTO_SYMEX_GOTO_SYMEX_H

src/goto-symex/goto_symex_state.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ goto_symex_statet::goto_symex_statet()
3030
total_vccs(0),
3131
remaining_vccs(0),
3232
record_events(true),
33-
dirty(),
34-
global_validation_mode(validation_modet::IGNORE)
35-
33+
dirty()
3634
{
3735
threads.resize(1);
3836
new_frame();
@@ -217,16 +215,19 @@ void goto_symex_statet::assignment(
217215
// the type might need renaming
218216
rename(lhs.type(), l1_identifier, ns);
219217
lhs.update_type();
220-
const validation_modet vm = global_validation_mode;
221-
DATA_CHECK(!check_renaming_l1(lhs), "lhs renaming failed on l1");
222-
218+
const validation_modet local_validation_mode = validation_modet::INVARIANT;
219+
if(run_validation_checks)
220+
{
221+
const validation_modet vm = local_validation_mode;
222+
DATA_CHECK(!check_renaming_l1(lhs), "lhs renaming failed on l1");
223+
}
223224
#if 0
224225
PRECONDITION(l1_identifier != get_original_name(l1_identifier)
225226
|| l1_identifier=="goto_symex::\\guard"
226227
|| ns.lookup(l1_identifier).is_shared()
227228
|| has_prefix(id2string(l1_identifier), "symex::invalid_object")
228229
|| has_prefix(id2string(l1_identifier), "symex_dynamic::dynamic_object"));
229-
#endif
230+
#endif
230231

231232
// do the l2 renaming
232233
if(level2.current_names.find(l1_identifier)==level2.current_names.end())
@@ -237,9 +238,12 @@ void goto_symex_statet::assignment(
237238
// in case we happen to be multi-threaded, record the memory access
238239
bool is_shared=l2_thread_write_encoding(lhs, ns);
239240

240-
DATA_CHECK(!check_renaming(lhs), "lhs renaming failed on l2");
241-
DATA_CHECK(!check_renaming(rhs), "rhs renaming failed on l2");
242-
241+
if(run_validation_checks)
242+
{
243+
const validation_modet vm = local_validation_mode;
244+
DATA_CHECK(!check_renaming(lhs), "lhs renaming failed on l2");
245+
DATA_CHECK(!check_renaming(rhs), "rhs renaming failed on l2");
246+
}
243247
// see #305 on GitHub for a simple example and possible discussion
244248
if(is_shared && lhs.type().id() == ID_pointer && !allow_pointer_unsoundness)
245249
throw unsupported_operation_exceptiont(
@@ -261,8 +265,12 @@ void goto_symex_statet::assignment(
261265
ssa_exprt l1_lhs(lhs);
262266
get_l1_name(l1_lhs);
263267

264-
DATA_CHECK(!check_renaming_l1(l1_lhs), "lhs renaming failed on l1");
265-
DATA_CHECK(!check_renaming_l1(l1_rhs), "rhs renaming failed on l1");
268+
if(run_validation_checks)
269+
{
270+
const validation_modet vm = local_validation_mode;
271+
DATA_CHECK(!check_renaming_l1(l1_lhs), "lhs renaming failed on l1");
272+
DATA_CHECK(!check_renaming_l1(l1_rhs), "rhs renaming failed on l1");
273+
}
266274

267275
value_set.assign(l1_lhs, l1_rhs, ns, rhs_is_simplified, is_shared);
268276
}

src/goto-symex/goto_symex_state.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class goto_symex_statet final
4343
: goto_symex_statet(other) // NOLINT
4444
{
4545
symex_target = target;
46-
global_validation_mode = other.global_validation_mode;
4746
}
4847

4948
/// contains symbols that are minted during symbolic execution, such as
@@ -391,7 +390,7 @@ class goto_symex_statet final
391390
/// of a GOTO
392391
bool has_saved_next_instruction;
393392
bool saved_target_is_backwards;
394-
validation_modet global_validation_mode;
393+
bool run_validation_checks;
395394

396395
private:
397396
/// \brief Dangerous, do not use

src/goto-symex/symex_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void goto_symext::symex_from_entry_point_of(
301301

302302
statet state;
303303

304-
state.global_validation_mode = global_validation_mode;
304+
state.run_validation_checks = run_validation_checks;
305305

306306
initialize_entry_point(
307307
state,

src/util/validate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ Author: Daniel Poetzl
3636
if(!(condition)) \
3737
throw incorrect_goto_program_exceptiont(message); \
3838
break; \
39-
case validation_modet::IGNORE: \
40-
break; \
4139
} \
4240
} while(0)
4341

@@ -58,8 +56,6 @@ Author: Daniel Poetzl
5856
if(!(condition)) \
5957
throw incorrect_goto_program_exceptiont(message, __VA_ARGS__); \
6058
break; \
61-
case validation_modet::IGNORE: \
62-
break; \
6359
} \
6460
} while(0)
6561

src/util/validation_mode.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Author: Daniel Poetzl
1212
enum class validation_modet
1313
{
1414
INVARIANT,
15-
EXCEPTION,
16-
IGNORE
15+
EXCEPTION
1716
};
1817

1918
#endif /* CPROVER_UTIL_VALIDATION_MODE_H */

0 commit comments

Comments
 (0)