CBMC
Loading...
Searching...
No Matches
symex_goto.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Symbolic Execution
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
11
13#include <util/expr_util.h>
14#include <util/invariant.h>
16#include <util/simplify_expr.h>
17#include <util/std_expr.h>
18
20
21#include "goto_symex.h"
22#include "path_storage.h"
24
25#include <algorithm>
26#include <map>
27
32 const exprt &original_guard,
33 const exprt &new_guard,
34 const namespacet &ns)
35{
36 // It would be better to call try_filter_value_sets after apply_condition,
37 // and pass nullptr for value sets which apply_condition successfully updated
38 // already. However, try_filter_value_sets calls rename to do constant
39 // propagation, and apply_condition can update the constant propagator. Since
40 // apply condition will never succeed on both jump_taken_state and
41 // jump_not_taken_state, it should be possible to pass a reference to an
42 // unmodified goto_statet to use for renaming. But renaming needs a
43 // goto_symex_statet, not just a goto_statet, and we only have access to one
44 // of those. A future improvement would be to split rename into two parts:
45 // one part on goto_symex_statet which is non-const and deals with
46 // l2 thread reads, and one part on goto_statet which is const and could be
47 // used in try_filter_value_sets.
48
52 jump_taken_state.value_set,
53 &jump_taken_state.value_set,
54 &jump_not_taken_state.value_set,
55 ns);
56
57 if(!symex_config.constant_propagation)
58 return;
59
60 jump_taken_state.apply_condition(new_guard, current_state, ns);
61
62 // Could use not_exprt + simplify, but let's avoid paying that cost on quite
63 // a hot path:
66}
67
69{
71
72 const goto_programt::instructiont &instruction=*state.source.pc;
73
74 exprt new_guard = clean_expr(instruction.condition(), state, false);
75
77 if(symex_config.simplify_opt)
78 {
80 renamed_guard.simplify(simp);
81 }
83
84 if(new_guard == false)
85 {
86 target.location(state.guard.as_expr(), state.source);
87
88 // next instruction
89 symex_transition(state);
90 return; // nothing to do
91 }
92
94
96 !instruction.targets.empty(), "goto should have at least one target");
97
98 // we only do deterministic gotos for now
100 instruction.targets.size() == 1, "no support for non-deterministic gotos");
101
103 instruction.get_target();
104
105 const bool backward = instruction.is_backwards_goto();
106
107 if(backward)
108 {
109 // is it label: goto label; or while(cond); - popular in SV-COMP
110 if(
111 symex_config.self_loops_to_assumptions &&
112 // label: goto label; or do {} while(cond);
113 (goto_target == state.source.pc ||
114 // while(cond);
115 (instruction.incoming_edges.size() == 1 &&
116 *instruction.incoming_edges.begin() == goto_target &&
117 goto_target->is_goto() && new_guard == true)))
118 {
119 // generate assume(false) or a suitable negation if this
120 // instruction is a conditional goto
123 log.statistics() << "replacing self-loop at "
124 << state.source.pc->source_location() << " by assume("
126 << ")" << messaget::eom;
127 if(symex_config.unwinding_assertions)
128 {
129 log.warning()
130 << "no unwinding assertion will be generated for self-loop at "
131 << state.source.pc->source_location() << messaget::eom;
132 }
134
135 // next instruction
136 symex_transition(state);
137 return;
138 }
139
140 const auto loop_id =
142
143 unsigned &unwind = state.call_stack().top().loop_iterations[loop_id].count;
144 unwind++;
145
146 if(should_stop_unwind(state.source, state.call_stack(), unwind))
147 {
148 // we break the loop
150
151 // next instruction
152 symex_transition(state);
153 return;
154 }
155
156 if(new_guard == true)
157 {
158 // we continue executing the loop
159 if(check_break(loop_id, unwind))
160 {
161 should_pause_symex = true;
162 }
163 symex_transition(state, goto_target, true);
164 return; // nothing else to do
165 }
166 }
167
168 // No point executing both branches of an unconditional goto.
169 if(
170 new_guard == true && // We have an unconditional goto, AND
171 // either there are no reachable blocks between us and the target in the
172 // surrounding scope (because state.guard == true implies there is no path
173 // around this GOTO instruction)
174 (state.guard.is_true() ||
175 // or there is another block, but we're doing path exploration so
176 // we're going to skip over it for now and return to it later.
177 symex_config.doing_path_exploration))
178 {
180 instruction.targets.size() > 0,
181 "Instruction is an unconditional goto with no target: " +
182 instruction.code().pretty());
183 symex_transition(state, instruction.get_target(), true);
184 return;
185 }
186
189
190 if(!backward)
191 {
193 state_pc=state.source.pc;
194 state_pc++;
195
196 // skip dead instructions
197 if(new_guard == true)
198 while(state_pc!=goto_target && !state_pc->is_target())
199 ++state_pc;
200
202 {
203 symex_transition(state, goto_target, false);
204 return; // nothing else to do
205 }
206 }
207 else
208 {
209 new_state_pc=state.source.pc;
210 new_state_pc++;
212 }
213
214 // Normally the next instruction to execute would be state_pc and we save
215 // new_state_pc for later. But if we're executing from a saved state, then
216 // new_state_pc should be the state that we saved from earlier, so let's
217 // execute that instead.
218 if(state.has_saved_jump_target)
219 {
220 INVARIANT(
221 new_state_pc == state.saved_target,
222 "Tried to explore the other path of a branch, but the next "
223 "instruction along that path is not the same as the instruction "
224 "that we saved at the branch point. Saved instruction is " +
225 state.saved_target->code().pretty() +
226 "\nwe were intending "
227 "to explore " +
228 new_state_pc->code().pretty() +
229 "\nthe "
230 "instruction we think we saw on a previous path exploration is " +
231 state_pc->code().pretty());
234 state_pc = tmp;
235
236 log.debug() << "Resuming from jump target '" << state_pc->source_location()
237 << "'" << log.eom;
238 }
239 else if(state.has_saved_next_instruction)
240 {
241 log.debug() << "Resuming from next instruction '"
242 << state_pc->source_location() << "'" << log.eom;
243 }
244 else if(symex_config.doing_path_exploration)
245 {
246 // We should save both the instruction after this goto, and the target of
247 // the goto.
248
250 next_instruction.state.saved_target = state_pc;
251 next_instruction.state.has_saved_next_instruction = true;
252
254 jump_target.state.saved_target = new_state_pc;
255 jump_target.state.has_saved_jump_target = true;
256 // `forward` tells us where the branch we're _currently_ executing is
257 // pointing to; this needs to be inverted for the branch that we're saving,
258 // so let its truth value for `backwards` be the same as ours for `forward`.
259
260 log.debug() << "Saving next instruction '"
261 << next_instruction.state.saved_target->source_location() << "'"
262 << log.eom;
263 log.debug() << "Saving jump target '"
264 << jump_target.state.saved_target->source_location() << "'"
265 << log.eom;
268
269 // It is now up to the caller of symex to decide which path to continue
270 // executing. Signal to the caller that states have been pushed (therefore
271 // symex has not yet completed and must be resumed), and bail out.
272 should_pause_symex = true;
273 return;
274 }
275
276 // put a copy of the current state into the state-queue, to be used by
277 // merge_gotos when we visit new_state_pc
280
281 // On an unconditional GOTO we don't need our state, as it will be overwritten
282 // by merge_goto. Therefore we move it onto goto_state_list instead of copying
283 // as usual.
284 if(new_guard == true)
285 {
286 // The move here only moves goto_statet, the base class of goto_symex_statet
287 // and not the entire thing.
288 goto_state_list.emplace_back(state.source, std::move(state));
289
291
293 state.reachable = false;
294 }
295 else
296 {
297 goto_state_list.emplace_back(state.source, state);
298
300
301 if(!symex_config.doing_path_exploration)
302 {
303 // This doesn't work for --paths (single-path mode) yet, as in multi-path
304 // mode we remove the implied constants at a control-flow merge, but in
305 // single-path mode we don't run merge_gotos.
306 auto &taken_state = backward ? state : goto_state_list.back().second;
307 auto &not_taken_state = backward ? goto_state_list.back().second : state;
308
310 state,
313 instruction.condition(),
314 new_guard,
315 ns);
316 }
317
318 // produce new guard symbol
319 exprt guard_expr;
320
321 if(
322 new_guard.id() == ID_symbol ||
323 (new_guard.id() == ID_not &&
324 to_not_expr(new_guard).op().id() == ID_symbol))
325 {
326 guard_expr=new_guard;
327 }
328 else
329 {
333
336 new_lhs =
337 state.assignment(std::move(new_lhs), new_rhs, ns, true, false).get();
338
340
342 log.debug(),
343 [this, &new_lhs](messaget::mstreamt &mstream) {
344 mstream << "Assignment to " << new_lhs.get_identifier()
345 << " [" << pointer_offset_bits(new_lhs.type(), ns).value_or(0) << " bits]"
346 << messaget::eom;
347 });
348
350 guard.as_expr(),
352 new_rhs,
355
356 guard_expr = state.rename(boolean_negate(guard_symbol_expr), ns).get();
357 }
358
359 if(state.has_saved_jump_target)
360 {
361 if(!backward)
362 state.guard.add(guard_expr);
363 else
364 state.guard.add(boolean_negate(guard_expr));
365 }
366 else
367 {
368 goto_statet &new_state = goto_state_list.back().second;
369 if(!backward)
370 {
371 new_state.guard.add(guard_expr);
372 state.guard.add(boolean_negate(guard_expr));
373 }
374 else
375 {
376 state.guard.add(guard_expr);
377 new_state.guard.add(boolean_negate(guard_expr));
378 }
379 }
380 }
381}
382
384{
385 PRECONDITION(!state.reachable);
386 // This is like symex_goto, except the state is unreachable. We try to take
387 // some arbitrary choice that maintains the state guard in a reasonable state
388 // in order that it simplifies properly when states are merged (in
389 // merge_gotos). Note we can't try to evaluate the actual GOTO guard because
390 // our constant propagator might be out of date, since we haven't been
391 // executing assign instructions.
392
393 // If the guard is already false then there's no value in this state; just
394 // carry on and check the next instruction.
395 if(state.guard.is_false())
396 {
397 symex_transition(state);
398 return;
399 }
400
401 const goto_programt::instructiont &instruction = *state.source.pc;
402 PRECONDITION(instruction.is_goto());
404
409 new_state.guard = state.guard;
410 new_state.reachable = false;
411 goto_state_list.emplace_back(state.source, std::move(new_state));
412 };
413
414 if(instruction.condition() == true)
415 {
416 if(instruction.is_backwards_goto())
417 {
418 // Give up trying to salvage the guard
419 // (this state's guard is squashed, without queueing it at the target)
420 }
421 else
422 {
423 // Take the branch:
425 }
426
427 state.guard.add(false_exprt());
428 }
429 else
430 {
431 // Arbitrarily assume a conditional branch is not-taken, except for when
432 // there's an incoming backedge, when we guess that the taken case is less
433 // likely to lead to that backedge than the not-taken case.
434 bool maybe_loop_head = std::any_of(
435 instruction.incoming_edges.begin(),
436 instruction.incoming_edges.end(),
437 [&instruction](const goto_programt::const_targett predecessor) {
438 return predecessor->location_number > instruction.location_number;
439 });
440
441 if(instruction.is_backwards_goto() || !maybe_loop_head)
442 {
443 // Assume branch not taken (fall through)
444 }
445 else
446 {
447 // Assume branch taken:
449 state.guard.add(false_exprt());
450 }
451 }
452
453 symex_transition(state);
454}
455
456bool goto_symext::check_break(const irep_idt &loop_id, unsigned unwind)
457{
458 // dummy implementation
459 return false;
460}
461
463{
464 framet &frame = state.call_stack().top();
465
466 // first, see if this is a target at all
467 auto state_map_it = frame.goto_state_map.find(state.source.pc);
468
469 if(state_map_it==frame.goto_state_map.end())
470 return; // nothing to do
471
472 // we need to merge
474
475 for(auto list_it = state_list.rbegin(); list_it != state_list.rend();
476 ++list_it)
477 {
478 merge_goto(list_it->first, std::move(list_it->second), state);
479 }
480
481 // clean up to save some memory
482 frame.goto_state_map.erase(state_map_it);
483}
484
485static guardt
487{
488 // adjust guard, even using guards from unreachable states. This helps to
489 // shrink the state guard if the incoming edge is from a path that was
490 // truncated by config.unwind, config.depth or an assume-false instruction.
491
492 // Note when an unreachable state contributes its guard, merging it in is
493 // optional, since the formula already implies the unreachable guard is
494 // impossible. Therefore we only integrate it when to do so simplifies the
495 // state guard.
496
497 // This function can trash either state's guards, since goto_state is dying
498 // and state's guard will shortly be overwritten.
499
500 if(
501 (goto_state.reachable && state.reachable) ||
503 {
504 state.guard |= goto_state.guard;
505 return std::move(state.guard);
506 }
507 else if(!state.reachable && goto_state.reachable)
508 {
509 return std::move(goto_state.guard);
510 }
511 else
512 {
513 return std::move(state.guard);
514 }
515}
516
520 statet &state)
521{
522 // check atomic section
523 if(state.atomic_section_id != goto_state.atomic_section_id)
525 "atomic sections differ across branches",
526 state.source.pc->source_location());
527
528 // Merge guards. Don't write this to `state` yet because we might move
529 // goto_state over it below.
531
532 // Merge constant propagator, value-set etc. only if the incoming state is
533 // reachable:
534 if(goto_state.reachable)
535 {
536 if(!state.reachable)
537 {
538 // Important to note that we're moving into our base class here.
539 // Note this overwrites state.guard, but we restore it below.
540 static_cast<goto_statet &>(state) = std::move(goto_state);
541 }
542 else
543 {
544 // do SSA phi functions
545 phi_function(goto_state, state);
546
547 // merge value sets
548 state.value_set.make_union(goto_state.value_set);
549
550 // adjust depth
551 state.depth = std::min(state.depth, goto_state.depth);
552 }
553 }
554
555 // Save the new state guard
556 state.guard = std::move(new_guard);
557}
558
574static void merge_names(
575 const goto_statet &goto_state,
577 const namespacet &ns,
578 const guardt &diff_guard,
579 messaget &log,
580 const bool do_simplify,
582 const incremental_dirtyt &dirty,
583 const ssa_exprt &ssa,
584 const std::size_t goto_count,
585 const std::size_t dest_count)
586{
587 const irep_idt l1_identifier = ssa.get_identifier();
588 const irep_idt &obj_identifier = ssa.get_object_name();
589
591 return; // just a guard, don't bother
592
594 return; // not at all changed
595
596 // changed - but only on a branch that is now dead, and the other branch is
597 // uninitialized/invalid
598 if(
599 (!dest_state.reachable && goto_count == 0) ||
600 (!goto_state.reachable && dest_count == 0))
601 {
602 return;
603 }
604
605 // field sensitivity: only merge on individual fields
606 if(dest_state.field_sensitivity.is_divisible(ssa, true))
607 return;
608
609 // shared variables are renamed on every access anyway, we don't need to
610 // merge anything
611 const symbolt &symbol = ns.lookup(obj_identifier);
612
613 // shared?
614 if(
615 dest_state.atomic_section_id == 0 && dest_state.threads.size() >= 2 &&
616 (symbol.is_shared() || dirty(symbol.name)))
617 {
618 return; // no phi nodes for shared stuff
619 }
620
621 // don't merge (thread-)locals across different threads, which
622 // may have been introduced by symex_start_thread (and will
623 // only later be removed from level2.current_names by pop_frame
624 // once the thread is executed)
625 const irep_idt level_0 = ssa.get_level_0();
626 if(
627 !level_0.empty() &&
628 level_0 != std::to_string(dest_state.source.thread_nr) && dest_count != 0)
629 {
630 return;
631 }
632
634
635 {
636 const auto p_it = goto_state.propagation.find(l1_identifier);
637
638 if(p_it.has_value())
640 else
642 }
643
644 {
645 const auto p_it = dest_state.propagation.find(l1_identifier);
646
647 if(p_it.has_value())
649 else
651 }
652
653 exprt rhs;
654
655 // Don't add a conditional to the assignment when:
656 // 1. Either guard is false, so we can't follow that branch.
657 // 2. Either identifier is of generation zero, and so hasn't been
658 // initialized and therefore an invalid target.
659
660 // These rules only apply to dynamic objects and locals.
661 if(!dest_state.reachable)
662 rhs = goto_state_rhs;
663 else if(!goto_state.reachable)
664 rhs = dest_state_rhs;
665 else if(goto_count == 0)
666 rhs = dest_state_rhs;
667 else if(dest_count == 0)
668 rhs = goto_state_rhs;
669 else
670 {
672 if(do_simplify)
673 {
674 // Do not value-set supported filtering here as neither dest_state nor
675 // goto_state necessarily have a comprehensive value set.
676 simplify(rhs, ns);
677 }
678 }
679
680 dest_state.record_events.push(false);
681 const ssa_exprt new_lhs =
682 dest_state.assignment(ssa, rhs, ns, true, true).get();
683 dest_state.record_events.pop();
684
685 log.conditional_output(
686 log.debug(), [ns, &new_lhs](messaget::mstreamt &mstream) {
687 mstream << "Assignment to " << new_lhs.get_identifier() << " ["
688 << pointer_offset_bits(new_lhs.type(), ns).value_or(0) << " bits]"
689 << messaget::eom;
690 });
691
692 target.assignment(
693 true_exprt(),
694 new_lhs,
695 new_lhs,
696 new_lhs.get_original_expr(),
697 rhs,
698 dest_state.source,
700}
701
703 const goto_statet &goto_state,
705{
706 if(
707 goto_state.get_level2().current_names.empty() &&
708 dest_state.get_level2().current_names.empty())
709 return;
710
712 // this gets the diff between the guards
713 diff_guard -= dest_state.guard;
714
716 goto_state.get_level2().current_names.get_delta_view(
717 dest_state.get_level2().current_names, delta_view, false);
718
719 std::map<std::string, symex_renaming_levelt::delta_viewt::const_iterator>
721 for(auto it = delta_view.begin(); it != delta_view.end(); ++it)
722 {
723 const ssa_exprt &ssa = it->m.first;
724 bool inserted =
725 ordered_names_to_merge.insert({id2string(ssa.get_identifier()), it})
726 .second;
727 CHECK_RETURN(inserted);
728 }
729
730 for(const auto &ordered_entry : ordered_names_to_merge)
731 {
732 const auto &delta_item = *ordered_entry.second;
733 const ssa_exprt &ssa = delta_item.m.first;
734 std::size_t goto_count = delta_item.m.second;
735 std::size_t dest_count = !delta_item.is_in_both_maps()
736 ? 0
737 : delta_item.get_other_map_value().second;
738
742 ns,
744 log,
745 symex_config.simplify_opt,
746 target,
748 ssa,
750 dest_count);
751 }
752
754 dest_state.get_level2().current_names.get_delta_view(
755 goto_state.get_level2().current_names, delta_view, false);
756
758 for(auto it = delta_view.begin(); it != delta_view.end(); ++it)
759 {
760 if(it->is_in_both_maps())
761 continue;
762
763 const ssa_exprt &ssa = it->m.first;
764 bool inserted =
765 ordered_names_to_merge.insert({id2string(ssa.get_identifier()), it})
766 .second;
767 CHECK_RETURN(inserted);
768 }
769
770 for(const auto &ordered_entry : ordered_names_to_merge)
771 {
772 const auto &delta_item = *ordered_entry.second;
773 const ssa_exprt &ssa = delta_item.m.first;
774 std::size_t goto_count = 0;
775 std::size_t dest_count = delta_item.m.second;
776
780 ns,
782 log,
783 symex_config.simplify_opt,
784 target,
786 ssa,
788 dest_count);
789 }
790}
791
793 statet &state,
794 const exprt &guard)
795{
796 const std::string loop_number = std::to_string(state.source.pc->loop_number);
797
799
800 if(symex_config.unwinding_assertions)
801 {
802 // Generate VCC for unwinding assertion.
803 const std::string property_id =
804 id2string(state.source.pc->source_location().get_function()) +
805 ".unwind." + loop_number;
806 vcc(
808 property_id,
809 "unwinding assertion loop " + loop_number,
810 state);
811 }
812
813 if(!symex_config.partial_loops)
814 {
815 // generate unwinding assumption, unless we permit partial loops
817 }
818}
819
822 const call_stackt &,
823 unsigned)
824{
825 // by default, we keep going
826 return false;
827}
static exprt guard(const exprt::operandst &guards, exprt cond)
virtual void clear()
Reset the abstract state.
Definition ai.h:269
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:566
The Boolean type.
Definition std_types.h:36
framet & top()
Definition call_stack.h:17
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
Base class for all expressions.
Definition expr.h:57
The Boolean constant false.
Definition std_expr.h:3125
Stack frames – these are used for function calls and for exceptions.
std::list< std::pair< symex_targett::sourcet, goto_statet > > goto_state_listt
Definition frame.h:25
std::unordered_map< irep_idt, loop_infot > loop_iterations
Definition frame.h:77
std::map< goto_programt::const_targett, goto_state_listt, goto_programt::target_less_than > goto_state_map
Definition frame.h:33
This class represents an instruction in the GOTO intermediate representation.
const goto_instruction_codet & code() const
Get the code represented by this instruction.
targetst targets
The list of successor instructions.
bool is_backwards_goto() const
Returns true if the instruction is a backwards branch.
std::set< targett, target_less_than > incoming_edges
const exprt & condition() const
Get the condition of gotos, assume, assert.
const_targett get_target() const
Returns the first (and only) successor for the usual case of a single target.
static irep_idt loop_id(const irep_idt &function_id, const instructiont &instruction)
Human-readable loop name.
instructionst::const_iterator const_targett
Container for data that varies per program point, e.g.
Definition goto_state.h:32
guardt guard
Definition goto_state.h:58
unsigned depth
Distance from entry.
Definition goto_state.h:35
bool reachable
Is this code reachable? If not we can take shortcuts such as not entering function calls,...
Definition goto_state.h:62
unsigned atomic_section_id
Threads.
Definition goto_state.h:76
value_sett value_set
Uses level 1 names, and is used to do dereferencing.
Definition goto_state.h:51
Central data structure: state.
goto_programt::const_targett saved_target
call_stackt & call_stack()
static irep_idt guard_identifier()
renamedt< ssa_exprt, L2 > assignment(ssa_exprt lhs, const exprt &rhs, const namespacet &ns, bool rhs_is_simplified, bool record_value, bool allow_pointer_unsoundness=false)
guard_managert & guard_manager
renamedt< exprt, level > rename(exprt expr, const namespacet &ns)
Rewrites symbol expressions in exprt, applying a suffix to each symbol reflecting its most recent ver...
symex_targett::sourcet source
bool has_saved_jump_target
This state is saved, with the PC pointing to the target of a GOTO.
renamedt< ssa_exprt, level > rename_ssa(ssa_exprt ssa, const namespacet &ns)
Version of rename which is specialized for SSA exprt.
bool has_saved_next_instruction
This state is saved, with the PC pointing to the next instruction of a GOTO.
virtual bool should_stop_unwind(const symex_targett::sourcet &source, const call_stackt &context, unsigned unwind)
Determine whether to unwind a loop.
void try_filter_value_sets(goto_symex_statet &state, exprt condition, const value_sett &original_value_set, value_sett *jump_taken_value_set, value_sett *jump_not_taken_value_set, const namespacet &ns)
Try to filter value sets based on whether possible values of a pointer-typed symbol make the conditio...
void apply_goto_condition(goto_symex_statet &current_state, goto_statet &jump_taken_state, goto_statet &jump_not_taken_state, const exprt &original_guard, const exprt &new_guard, const namespacet &ns)
Propagate constants and points-to information implied by a GOTO condition.
virtual bool check_break(const irep_idt &loop_id, unsigned unwind)
Defines condition for interrupting symbolic execution for a specific loop.
void symex_unreachable_goto(statet &state)
Symbolically execute a GOTO instruction in the context of unreachable code.
irep_idt language_mode
language_mode: ID_java, ID_C or another language identifier if we know the source language in use,...
Definition goto_symex.h:240
virtual void symex_goto(statet &state)
Symbolically execute a GOTO instruction.
void phi_function(const goto_statet &goto_state, statet &dest_state)
Merge the SSA assignments from goto_state into dest_state.
path_storaget & path_storage
Symbolic execution paths to be resumed later.
Definition goto_symex.h:808
symex_target_equationt & target
The equation that this execution is building up.
Definition goto_symex.h:264
guard_managert & guard_manager
Used to create guards.
Definition goto_symex.h:261
exprt clean_expr(exprt expr, statet &state, bool write)
Clean up an expression.
virtual void loop_bound_exceeded(statet &state, const exprt &guard)
namespacet ns
Initialized just before symbolic execution begins, to point to both outer_symbol_table and the symbol...
Definition goto_symex.h:256
virtual void vcc(const exprt &cond, const irep_idt &property_id, const std::string &msg, statet &state)
Symbolically execute a verification condition (assertion).
virtual void merge_goto(const symex_targett::sourcet &source, goto_statet &&goto_state, statet &state)
Merge a single branch, the symbolic state of which is held in goto_state, into the current overall sy...
virtual void do_simplify(exprt &expr, const value_sett &value_set)
messaget log
The messaget to write log messages to.
Definition goto_symex.h:276
const symex_configt symex_config
The configuration to use for this symbolic execution.
Definition goto_symex.h:186
bool should_pause_symex
Set when states are pushed onto the workqueue If this flag is set at the end of a symbolic execution ...
Definition goto_symex.h:168
void symex_assume_l2(statet &, const exprt &cond)
void merge_gotos(statet &state)
Merge all branches joining at the current program point.
void add(const exprt &expr)
bool is_true() const
Definition guard_expr.h:60
bool disjunction_may_simplify(const guard_exprt &other_guard)
Returns true if operator|= with other_guard may result in a simpler expression.
exprt as_expr() const
Definition guard_expr.h:46
bool is_false() const
Definition guard_expr.h:65
The trinary if-then-else operator.
Definition std_expr.h:2416
Thrown when a goto program that's being processed is in an invalid format, for example passing the wr...
Wrapper for dirtyt that permits incremental population, ensuring each function is analysed exactly on...
Definition dirty.h:118
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
mstreamt & debug() const
Definition message.h:421
mstreamt & statistics() const
Definition message.h:411
mstreamt & warning() const
Definition message.h:396
void conditional_output(mstreamt &mstream, const std::function< void(mstreamt &)> &output_generator) const
Generate output to message_stream using output_generator if the configured verbosity is at least as h...
Definition message.cpp:139
static eomt eom
Definition message.h:289
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
incremental_dirtyt dirty
Local variables are considered 'dirty' if they've had an address taken and therefore may be referred ...
virtual void push(const patht &)=0
Add a path to resume to the storage.
std::vector< delta_view_itemt > delta_viewt
Delta view of the key-value pairs in two maps.
Expression providing an SSA-renamed symbol of expressions.
Definition ssa_expr.h:17
Expression to hold a symbol (variable)
Definition std_expr.h:132
Symbol table entry.
Definition symbol.h:28
irep_idt name
The unique identifier.
Definition symbol.h:40
bool is_shared() const
Definition symbol.h:101
Inheriting the interface of symex_targett this class represents the SSA form of the input program as ...
virtual void goto_instruction(const exprt &guard, const renamedt< exprt, L2 > &cond, const sourcet &source)
Record a goto instruction.
virtual void location(const exprt &guard, const sourcet &source)
Record a location.
virtual void assignment(const exprt &guard, const ssa_exprt &ssa_lhs, const exprt &ssa_full_lhs, const exprt &original_full_lhs, const exprt &ssa_rhs, const sourcet &source, assignment_typet assignment_type)
Write to a local variable.
The Boolean constant true.
Definition std_expr.h:3116
bool make_union(object_mapt &dest, const object_mapt &src) const
Merges two RHS expression sets.
exprt boolean_negate(const exprt &src)
negate a Boolean expression, possibly removing a not_exprt, and swapping false and true
Definition expr_util.cpp:98
Deprecated expression utility functions.
Symbolic Execution.
void symex_transition(goto_symext::statet &state)
Transition to the next instruction, which increments the internal program counter and initializes the...
guard_exprt guardt
Definition guard.h:29
const std::string & id2string(const irep_idt &d)
Definition irep.h:44
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
double log(double x)
Definition math.c:2416
Storage of symbolic execution paths to resume.
Pointer Logic.
@ L1
Definition renamed.h:24
bool simplify(exprt &expr, const namespacet &ns)
#define CHECK_RETURN(CONDITION)
Definition invariant.h:495
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition invariant.h:534
#define PRECONDITION(CONDITION)
Definition invariant.h:463
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition invariant.h:423
const ssa_exprt & to_ssa_expr(const exprt &expr)
Cast a generic exprt to an ssa_exprt.
Definition ssa_expr.h:145
API to expression classes.
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
Definition std_expr.h:2398
Information saved at a conditional goto to resume execution.
Identifies source in the context of symbolic execution.
goto_programt::const_targett pc
static void merge_names(const goto_statet &goto_state, goto_symext::statet &dest_state, const namespacet &ns, const guardt &diff_guard, messaget &log, const bool do_simplify, symex_target_equationt &target, const incremental_dirtyt &dirty, const ssa_exprt &ssa, const std::size_t goto_count, const std::size_t dest_count)
Helper function for phi_function which merges the names of an identifier for two different states.
static guardt merge_state_guards(goto_statet &goto_state, goto_symex_statet &state)