Skip to content

Commit 49d7eb0

Browse files
committed
Fixes formatting.
1 parent 9183e6d commit 49d7eb0

File tree

6 files changed

+64
-58
lines changed

6 files changed

+64
-58
lines changed

regression/contracts/quantifiers-exists-ensures-01/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
int f1(int *arr)
2-
__CPROVER_ensures(
3-
__CPROVER_exists {int i; (0 <= i && i < 10) && arr[i] == i}
4-
)
1+
int f1(int *arr) __CPROVER_ensures(__CPROVER_exists {
2+
int i;
3+
(0 <= i && i < 10) && arr[i] == i
4+
})
55
{
66
for(int i = 0; i < 10; i++)
77
{

regression/contracts/quantifiers-exists-ensures-02/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
int f1(int *arr)
2-
__CPROVER_ensures(
3-
__CPROVER_exists {int i; (0 <= i && i < 10) && arr[i] != 0}
4-
)
1+
int f1(int *arr) __CPROVER_ensures(__CPROVER_exists {
2+
int i;
3+
(0 <= i && i < 10) && arr[i] != 0
4+
})
55
{
66
for(int i = 0; i < 10; i++)
77
{

regression/contracts/quantifiers-forall-ensures-01/main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
int f1(int *arr)
2-
__CPROVER_ensures(
3-
__CPROVER_forall {int i; (0 <= i && i < 10) ==> arr[i] == 0}
4-
)
1+
// clang-format oFF
2+
int f1(int *arr) __CPROVER_ensures(__CPROVER_forall {
3+
int i;
4+
(0 <= i && i < 10) ==> arr[i] == 0
5+
})
6+
// clang-format on
57
{
68
for(int i = 0; i < 10; i++)
79
{

regression/contracts/quantifiers-forall-ensures-02/main.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
int f1(int *arr)
2-
__CPROVER_ensures(
3-
__CPROVER_forall {int i; (0 <= i && i < 10) ==> arr[i] == i}
4-
)
1+
// clang-format oFF
2+
int f1(int *arr) __CPROVER_ensures(__CPROVER_forall {
3+
int i;
4+
(0 <= i && i < 10) ==> arr[i] == i
5+
})
6+
// clang-format on
57
{
68
for(int i = 0; i < 10; i++)
79
{
8-
if (i == 0) arr[i] = -1;
9-
else arr[i] = i;
10+
if(i == 0)
11+
arr[i] = -1;
12+
else
13+
arr[i] = i;
1014
}
1115

1216
return 0;

src/goto-instrument/code_contracts.cpp

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static void check_apply_invariants(
149149

150150
// change the back edge into assume(false) or assume(guard)
151151
loop_end->targets.clear();
152-
loop_end->type=ASSUME;
152+
loop_end->type = ASSUME;
153153
if(loop_head->is_goto())
154154
loop_end->set_condition(false_exprt());
155155
else
@@ -168,20 +168,21 @@ void code_contractst::add_quantified_variable(
168168
replace_symbolt &replace,
169169
irep_idt mode)
170170
{
171-
//If the expression is a quantified expression, this function adds
172-
//the quantified variable to the symbol table and to the expression map
171+
// If the expression is a quantified expression, this function adds
172+
// the quantified variable to the symbol table and to the expression map
173173

174-
//TODO Currently only works if the contract contains only a single quantified formula
174+
// TODO Currently only works if the contract contains only a single
175+
// quantified formula
175176
// i.e. (1) the top-level element is a quantifier formula
176-
//and (2) there are no inner quantifier formulae
177+
// and (2) there are no inner quantifier formulae
177178
if(expression.id() == ID_exists || expression.id() == ID_forall)
178179
{
179-
//get quantified symbol
180+
// get quantified symbol
180181
exprt tuple = expression.operands().front();
181182
exprt quantified_variable = tuple.operands().front();
182183
symbol_exprt quantified_symbol = to_symbol_expr(quantified_variable);
183184

184-
//create fresh symbol
185+
// create fresh symbol
185186
symbolt new_symbol = get_fresh_aux_symbol(
186187
quantified_symbol.type(),
187188
id2string(quantified_symbol.get_identifier()),
@@ -264,7 +265,7 @@ bool code_contractst::apply_function_contract(
264265
}
265266

266267
// Replace formal parameters
267-
code_function_callt::argumentst::const_iterator a_it=
268+
code_function_callt::argumentst::const_iterator a_it =
268269
call.arguments().begin();
269270
for(code_typet::parameterst::const_iterator p_it = type.parameters().begin();
270271
p_it != type.parameters().end() && a_it != call.arguments().end();
@@ -479,38 +480,38 @@ void code_contractst::instrument_call_statement(
479480

480481
return;
481482
}
482-
else // Called function has assigns clause
483+
else // Called function has assigns clause
484+
{
485+
replace_symbolt replace;
486+
// Replace formal parameters
487+
code_function_callt::argumentst::const_iterator a_it =
488+
call.arguments().begin();
489+
for(code_typet::parameterst::const_iterator p_it =
490+
called_type.parameters().begin();
491+
p_it != called_type.parameters().end() &&
492+
a_it != call.arguments().end();
493+
++p_it, ++a_it)
483494
{
484-
replace_symbolt replace;
485-
// Replace formal parameters
486-
code_function_callt::argumentst::const_iterator a_it =
487-
call.arguments().begin();
488-
for(code_typet::parameterst::const_iterator p_it =
489-
called_type.parameters().begin();
490-
p_it != called_type.parameters().end() &&
491-
a_it != call.arguments().end();
492-
++p_it, ++a_it)
495+
if(!p_it->get_identifier().empty())
493496
{
494-
if(!p_it->get_identifier().empty())
495-
{
496-
symbol_exprt p(p_it->get_identifier(), p_it->type());
497-
replace.insert(p, *a_it);
498-
}
497+
symbol_exprt p(p_it->get_identifier(), p_it->type());
498+
replace.insert(p, *a_it);
499499
}
500-
501-
replace(called_assigns);
502-
503-
// check compatibility of assigns clause with the called function
504-
assigns_clauset called_assigns_clause(
505-
called_assigns, *this, function_id, log);
506-
exprt compatible =
507-
assigns_clause.compatible_expression(called_assigns_clause);
508-
goto_programt alias_assertion;
509-
alias_assertion.add(goto_programt::make_assertion(
510-
compatible, instruction_iterator->source_location));
511-
program.insert_before_swap(instruction_iterator, alias_assertion);
512-
++instruction_iterator;
513500
}
501+
502+
replace(called_assigns);
503+
504+
// check compatibility of assigns clause with the called function
505+
assigns_clauset called_assigns_clause(
506+
called_assigns, *this, function_id, log);
507+
exprt compatible =
508+
assigns_clause.compatible_expression(called_assigns_clause);
509+
goto_programt alias_assertion;
510+
alias_assertion.add(goto_programt::make_assertion(
511+
compatible, instruction_iterator->source_location));
512+
program.insert_before_swap(instruction_iterator, alias_assertion);
513+
++instruction_iterator;
514+
}
514515
}
515516

516517
bool code_contractst::check_for_looped_mallocs(const goto_programt &program)
@@ -784,7 +785,7 @@ void code_contractst::add_contract_check(
784785
.symbol_expr();
785786
check.add(goto_programt::make_decl(r, skip->source_location));
786787

787-
call.lhs()=r;
788+
call.lhs() = r;
788789
return_stmt = code_returnt(r);
789790

790791
symbol_exprt ret_val(CPROVER_PREFIX "return_value", call.lhs().type());

src/goto-instrument/code_contracts.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Date: February 2016
2525
#include <util/message.h>
2626
#include <util/namespace.h>
2727
#include <util/pointer_expr.h>
28-
#include <util/pointer_expr.h>
2928
#include <util/replace_symbol.h>
3029

3130
class messaget;
@@ -168,8 +167,8 @@ class code_contractst
168167
void
169168
add_contract_check(const irep_idt &, const irep_idt &, goto_programt &dest);
170169

171-
//If the expression is a quantified expression, this function adds
172-
//the quantified variable to the symbol table and to the expression map
170+
// If the expression is a quantified expression, this function adds
171+
// the quantified variable to the symbol table and to the expression map
173172
void add_quantified_variable(
174173
exprt expression,
175174
replace_symbolt &replace,

0 commit comments

Comments
 (0)