Skip to content

Commit 2de979e

Browse files
Merge pull request gcc-mirror#62 from NinaRanns/contracts_clean_up2
addressing review comments
2 parents b913973 + b920d82 commit 2de979e

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

gcc/cp/contracts.cc

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
This file is part of GCC.
66
77
GCC is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
89
the Free Software Foundation; either version 3, or (at your option)
910
any later version.
1011
@@ -190,7 +191,7 @@ lookup_concrete_semantic (const char *name)
190191
return CCS_INVALID;
191192
}
192193

193-
/* Compare role and name up to either the NULL terminator or the first
194+
/* Compare role and name up to either the NUL terminator or the first
194195
occurrence of colon. */
195196

196197
static bool
@@ -516,15 +517,15 @@ contract_config_to_mode (tree config)
516517
if (!role)
517518
role = get_default_contract_role ();
518519

519-
contract_level level =
520-
map_contract_level (IDENTIFIER_POINTER (TREE_VALUE (config)));
520+
contract_level level
521+
= map_contract_level (IDENTIFIER_POINTER (TREE_VALUE (config)));
521522
return contract_mode (level, role);
522523
}
523524

524525
/* Literal semantic. */
525526
gcc_assert (TREE_CODE (config) == IDENTIFIER_NODE);
526-
contract_semantic semantic =
527-
map_contract_semantic (IDENTIFIER_POINTER (config));
527+
contract_semantic semantic
528+
= map_contract_semantic (IDENTIFIER_POINTER (config));
528529
return contract_mode (semantic);
529530
}
530531

@@ -586,8 +587,8 @@ all_attributes_are_contracts_p (tree attributes)
586587
tree
587588
invalidate_contract (tree contract)
588589
{
589-
if (TREE_CODE (contract) == POSTCONDITION_STMT &&
590-
POSTCONDITION_IDENTIFIER (contract))
590+
if (TREE_CODE (contract) == POSTCONDITION_STMT
591+
&& POSTCONDITION_IDENTIFIER (contract))
591592
POSTCONDITION_IDENTIFIER (contract) = error_mark_node;
592593
CONTRACT_CONDITION (contract) = error_mark_node;
593594
CONTRACT_COMMENT (contract) = error_mark_node;
@@ -783,8 +784,8 @@ grok_contract (tree attribute, tree mode, tree result, cp_expr condition,
783784
contract_semantic semantic = compute_concrete_semantic (contract);
784785
if (flag_contracts_nonattr
785786
&& OPTION_SET_P (flag_contract_evaluation_semantic))
786-
semantic =
787-
static_cast<contract_semantic>(flag_contract_evaluation_semantic);
787+
semantic
788+
= static_cast<contract_semantic>(flag_contract_evaluation_semantic);
788789
set_contract_semantic (contract, semantic);
789790

790791
/* If the contract is deferred, don't do anything with the condition. */
@@ -2624,8 +2625,8 @@ emit_assertion (tree attr)
26242625

26252626
emit_contract_attr (attr);
26262627

2627-
contract_semantic semantic =
2628-
get_contract_semantic (CONTRACT_STATEMENT (attr));
2628+
contract_semantic semantic
2629+
= get_contract_semantic (CONTRACT_STATEMENT (attr));
26292630

26302631
if (semantic == CCS_OBSERVE)
26312632
{
@@ -2728,8 +2729,7 @@ constify_contract_access(tree decl)
27282729
|| (TREE_CODE (decl) == PARM_DECL)
27292730
|| (REFERENCE_REF_P (decl)
27302731
&& ((VAR_P (TREE_OPERAND (decl, 0))
2731-
&& decl_storage_duration
2732-
(TREE_OPERAND (decl, 0)) == dk_auto)
2732+
&& decl_storage_duration(TREE_OPERAND (decl, 0)) == dk_auto)
27332733
|| (TREE_CODE (TREE_OPERAND (decl, 0)) == PARM_DECL)))))
27342734
{
27352735
decl = view_as_const (decl);
@@ -2820,8 +2820,8 @@ start_function_contracts (tree fndecl)
28202820

28212821
/* If this is not a client side check and definition side checks are
28222822
disabled, do nothing. */
2823-
if (!flag_contracts_nonattr_definition_check &&
2824-
!DECL_CONTRACT_WRAPPER(fndecl))
2823+
if (!flag_contracts_nonattr_definition_check
2824+
&& !DECL_CONTRACT_WRAPPER(fndecl))
28252825
return;
28262826

28272827
/* Check that the user did not try to shadow a function parameter with the
@@ -2942,8 +2942,8 @@ maybe_apply_function_contracts (tree fndecl)
29422942

29432943
/* If this is not a client side check and definition side checks are
29442944
disabled, do nothing. */
2945-
if (!flag_contracts_nonattr_definition_check &&
2946-
!DECL_CONTRACT_WRAPPER(fndecl))
2945+
if (!flag_contracts_nonattr_definition_check
2946+
&& !DECL_CONTRACT_WRAPPER(fndecl))
29472947
return;
29482948

29492949
bool do_pre = has_active_preconditions (fndecl);
@@ -3036,8 +3036,8 @@ copy_and_remap_contracts (tree dest, tree source, bool remap_result = true,
30363036
a != NULL_TREE;
30373037
a = CONTRACT_CHAIN (a))
30383038
{
3039-
if (!remap_post &&
3040-
(TREE_CODE (CONTRACT_STATEMENT (a)) == POSTCONDITION_STMT))
3039+
if (!remap_post
3040+
&& (TREE_CODE (CONTRACT_STATEMENT (a)) == POSTCONDITION_STMT))
30413041
continue;
30423042

30433043
tree c = copy_node (a);
@@ -3047,16 +3047,16 @@ copy_and_remap_contracts (tree dest, tree source, bool remap_result = true,
30473047
remap_contract (source, dest, CONTRACT_STATEMENT (c),
30483048
/*duplicate_p=*/true);
30493049

3050-
if ( remap_result &&
3051-
(TREE_CODE (CONTRACT_STATEMENT (c)) == POSTCONDITION_STMT))
3050+
if (remap_result
3051+
&& (TREE_CODE (CONTRACT_STATEMENT (c)) == POSTCONDITION_STMT))
30523052
{
30533053
tree oldvar = POSTCONDITION_IDENTIFIER (CONTRACT_STATEMENT (c));
30543054
if (oldvar)
30553055
DECL_CONTEXT (oldvar) = dest;
30563056
}
30573057

3058-
CONTRACT_COMMENT (CONTRACT_STATEMENT (c)) =
3059-
copy_node (CONTRACT_COMMENT (CONTRACT_STATEMENT (c)));
3058+
CONTRACT_COMMENT (CONTRACT_STATEMENT (c))
3059+
= copy_node (CONTRACT_COMMENT (CONTRACT_STATEMENT (c)));
30603060

30613061
chainon (last, c);
30623062
last = c;
@@ -3085,8 +3085,8 @@ finish_function_contracts (tree fndecl)
30853085

30863086
/* If this is not a client side check and definition side checks are
30873087
disabled, do nothing. */
3088-
if (!flag_contracts_nonattr_definition_check &&
3089-
!DECL_CONTRACT_WRAPPER(fndecl))
3088+
if (!flag_contracts_nonattr_definition_check
3089+
&& !DECL_CONTRACT_WRAPPER(fndecl))
30903090
return;
30913091

30923092
for (tree ca = DECL_CONTRACTS (fndecl); ca; ca = CONTRACT_CHAIN (ca))
@@ -3137,8 +3137,10 @@ finish_function_contracts (tree fndecl)
31373137
if (wrapdecl){
31383138
/* we copy postconditions on virtual function wrapper calls or if
31393139
postcondition checks are enabled on the caller side. */
3140-
bool copy_post = (flag_contract_nonattr_client_check > 1) ||
3141-
((DECL_IOBJ_MEMBER_FUNCTION_P (fndecl) && DECL_VIRTUAL_P (fndecl)));
3140+
bool copy_post
3141+
= (flag_contract_nonattr_client_check > 1)
3142+
|| ((DECL_IOBJ_MEMBER_FUNCTION_P (fndecl)
3143+
&& DECL_VIRTUAL_P (fndecl)));
31423144

31433145
copy_and_remap_contracts (wrapdecl, fndecl, true, copy_post);
31443146
}
@@ -3395,8 +3397,9 @@ maybe_contract_wrap_call (tree fndecl, tree call)
33953397

33963398
/* we check postconditions on vitual function wrapper calls or if
33973399
postcondition checks are enabled on the caller side. */
3398-
bool check_post = (flag_contract_nonattr_client_check > 1) ||
3399-
(DECL_IOBJ_MEMBER_FUNCTION_P (fndecl) && DECL_VIRTUAL_P (fndecl));
3400+
bool check_post
3401+
= (flag_contract_nonattr_client_check > 1)
3402+
|| (DECL_IOBJ_MEMBER_FUNCTION_P (fndecl) && DECL_VIRTUAL_P (fndecl));
34003403

34013404
bool do_pre = has_active_preconditions (fndecl);
34023405
bool do_post = has_active_postconditions (fndecl);

0 commit comments

Comments
 (0)