Skip to content

Commit 3c3b526

Browse files
authored
Merge pull request #5899 from diffblue/move_c_types
Move C types into util/c_types.h
2 parents ac1e4dd + 6c7e490 commit 3c3b526

38 files changed

+388
-360
lines changed

scripts/expected_doxygen_warnings.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ warning: Include graph for 'goto_instrument_parse_options.cpp' not generated, to
2222
warning: Included by graph for 'goto_functions.h' not generated, too many nodes (66), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
2323
warning: Included by graph for 'goto_model.h' not generated, too many nodes (110), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
2424
warning: Included by graph for 'arith_tools.h' not generated, too many nodes (181), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
25-
warning: Included by graph for 'c_types.h' not generated, too many nodes (110), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
25+
warning: Included by graph for 'c_types.h' not generated, too many nodes (141), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
2626
warning: Included by graph for 'config.h' not generated, too many nodes (87), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
2727
warning: Included by graph for 'exception_utils.h' not generated, too many nodes (61), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
2828
warning: Included by graph for 'expr.h' not generated, too many nodes (87), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
@@ -31,10 +31,10 @@ warning: Included by graph for 'invariant.h' not generated, too many nodes (186)
3131
warning: Included by graph for 'irep.h' not generated, too many nodes (62), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
3232
warning: Included by graph for 'message.h' not generated, too many nodes (117), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
3333
warning: Included by graph for 'namespace.h' not generated, too many nodes (109), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
34-
warning: Included by graph for 'pointer_expr.h' not generated, too many nodes (117), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
34+
warning: Included by graph for 'pointer_expr.h' not generated, too many nodes (116), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
3535
warning: Included by graph for 'prefix.h' not generated, too many nodes (85), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
3636
warning: Included by graph for 'simplify_expr.h' not generated, too many nodes (79), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
3737
warning: Included by graph for 'std_code.h' not generated, too many nodes (78), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
3838
warning: Included by graph for 'std_expr.h' not generated, too many nodes (241), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
39-
warning: Included by graph for 'std_types.h' not generated, too many nodes (102), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
39+
warning: Included by graph for 'std_types.h' not generated, too many nodes (96), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
4040
warning: Included by graph for 'symbol_table.h' not generated, too many nodes (95), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.

src/ansi-c/c_typecheck_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Author: Daniel Kroening, [email protected]
1313
#define CPROVER_ANSI_C_C_TYPECHECK_BASE_H
1414

1515
#include <util/bitvector_expr.h>
16+
#include <util/c_types.h>
1617
#include <util/namespace.h>
1718
#include <util/std_code.h>
1819
#include <util/std_expr.h>
19-
#include <util/std_types.h>
2020
#include <util/symbol_table.h>
2121
#include <util/typecheck.h>
2222

src/ansi-c/padding.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <algorithm>
1515

1616
#include <util/arith_tools.h>
17-
#include <util/bitvector_types.h>
17+
#include <util/c_types.h>
1818
#include <util/config.h>
1919
#include <util/pointer_offset_size.h>
2020
#include <util/simplify_expr.h>

src/ansi-c/type2name.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected]
1212
#include "type2name.h"
1313

1414
#include <util/arith_tools.h>
15+
#include <util/c_types.h>
1516
#include <util/invariant.h>
1617
#include <util/namespace.h>
1718
#include <util/pointer_offset_size.h>

src/cpp/cpp_exception_id.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "cpp_exception_id.h"
1313

14+
#include <util/c_types.h>
1415
#include <util/invariant.h>
1516
#include <util/std_types.h>
1617

src/cpp/expr2cpp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Author: Daniel Kroening, [email protected]
88

99
#include "expr2cpp.h"
1010

11+
#include <util/c_types.h>
1112
#include <util/lispexpr.h>
1213
#include <util/lispirep.h>
1314
#include <util/namespace.h>

src/goto-instrument/dump_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "dump_c.h"
1313

14-
#include <util/bitvector_types.h>
1514
#include <util/byte_operators.h>
15+
#include <util/c_types.h>
1616
#include <util/config.h>
1717
#include <util/expr_initializer.h>
1818
#include <util/find_symbols.h>

src/goto-programs/goto_trace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Author: Daniel Kroening
1616
#include <ostream>
1717

1818
#include <util/arith_tools.h>
19-
#include <util/bitvector_types.h>
2019
#include <util/byte_operators.h>
20+
#include <util/c_types.h>
2121
#include <util/format_expr.h>
2222
#include <util/merge_irep.h>
2323
#include <util/range.h>

src/goto-programs/interpreter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
1818
#include <algorithm>
1919
#include <cstring>
2020

21+
#include <util/c_types.h>
2122
#include <util/fixedbv.h>
2223
#include <util/ieee_float.h>
2324
#include <util/invariant.h>

src/goto-programs/interpreter_evaluate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <util/bitvector_expr.h>
1515
#include <util/byte_operators.h>
16+
#include <util/c_types.h>
1617
#include <util/fixedbv.h>
1718
#include <util/ieee_float.h>
1819
#include <util/pointer_expr.h>

src/goto-programs/json_expr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Peter Schrammel
1212
#include "json_expr.h"
1313

1414
#include <util/arith_tools.h>
15+
#include <util/c_types.h>
1516
#include <util/config.h>
1617
#include <util/expr.h>
1718
#include <util/expr_util.h>

src/goto-programs/xml_expr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening
1414
#include "xml_expr.h"
1515

1616
#include <util/arith_tools.h>
17+
#include <util/c_types.h>
1718
#include <util/config.h>
1819
#include <util/expr.h>
1920
#include <util/fixedbv.h>

src/goto-symex/goto_symex_state.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
1818
#include <util/as_const.h>
1919
#include <util/base_exceptions.h>
2020
#include <util/byte_operators.h>
21+
#include <util/c_types.h>
2122
#include <util/exception_utils.h>
2223
#include <util/expr_util.h>
2324
#include <util/format.h>

src/jsil/jsil_types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Author: Daiva Naudziuniene, [email protected]
1212
#ifndef CPROVER_JSIL_JSIL_TYPES_H
1313
#define CPROVER_JSIL_JSIL_TYPES_H
1414

15-
#include <util/type.h>
16-
#include <util/std_types.h>
15+
#include <util/c_types.h>
1716

1817
typet jsil_kind();
1918
typet jsil_any_type();

src/linking/linking.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Author: Daniel Kroening, [email protected]
1515
#include <unordered_set>
1616

1717
#include <util/base_type.h>
18+
#include <util/c_types.h>
1819
#include <util/find_symbols.h>
1920
#include <util/mathematical_types.h>
2021
#include <util/pointer_expr.h>

src/solvers/flattening/boolbv_update.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, [email protected]
99
#include "boolbv.h"
1010

1111
#include <util/arith_tools.h>
12+
#include <util/c_types.h>
1213

1314
bvt boolbvt::convert_update(const update_exprt &expr)
1415
{

src/solvers/flattening/boolbv_width.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111
#include <algorithm>
1212

1313
#include <util/arith_tools.h>
14+
#include <util/c_types.h>
1415
#include <util/exception_utils.h>
1516
#include <util/invariant.h>
1617
#include <util/namespace.h>

src/solvers/flattening/boolbv_with.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ Author: Daniel Kroening, [email protected]
88

99
#include "boolbv.h"
1010

11-
#include <util/std_types.h>
12-
#include <util/std_expr.h>
1311
#include <util/arith_tools.h>
12+
#include <util/c_types.h>
1413
#include <util/config.h>
14+
#include <util/std_expr.h>
15+
#include <util/std_types.h>
1516

1617
bvt boolbvt::convert_with(const with_exprt &expr)
1718
{

src/solvers/flattening/c_bit_field_replacement_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Author: Daniel Kroening, [email protected]
88

99
#include "c_bit_field_replacement_type.h"
1010

11-
#include <util/bitvector_types.h>
11+
#include <util/c_types.h>
1212
#include <util/invariant.h>
1313

1414
typet c_bit_field_replacement_type(

src/solvers/flattening/c_bit_field_replacement_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Author: Daniel Kroening, [email protected]
1010
#ifndef CPROVER_SOLVERS_FLATTENING_C_BIT_FIELD_REPLACEMENT_TYPE_H
1111
#define CPROVER_SOLVERS_FLATTENING_C_BIT_FIELD_REPLACEMENT_TYPE_H
1212

13-
#include <util/std_types.h>
13+
#include <util/c_types.h>
1414
#include <util/namespace.h>
1515

1616
typet c_bit_field_replacement_type(

src/solvers/smt2/smt2_conv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <set>
1515

1616
#include <util/byte_operators.h>
17+
#include <util/c_types.h>
1718
#include <util/floatbv_expr.h>
1819
#include <util/std_expr.h>
1920

src/util/arith_tools.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Author: Daniel Kroening, [email protected]
88

99
#include "arith_tools.h"
1010

11+
#include "c_types.h"
1112
#include "fixedbv.h"
1213
#include "ieee_float.h"
1314
#include "invariant.h"
14-
#include "pointer_expr.h"
1515
#include "std_expr.h"
1616
#include "std_types.h"
1717

src/util/c_types.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9+
#include "c_types.h"
910

10-
#include "std_types.h"
1111
#include "config.h"
1212
#include "invariant.h"
13-
14-
#include "c_types.h"
13+
#include "pointer_offset_size.h"
14+
#include "std_types.h"
1515

1616
bitvector_typet index_type()
1717
{
@@ -303,3 +303,34 @@ std::string c_type_as_string(const irep_idt &c_type)
303303
else
304304
return "";
305305
}
306+
307+
optionalt<std::pair<struct_union_typet::componentt, mp_integer>>
308+
union_typet::find_widest_union_component(const namespacet &ns) const
309+
{
310+
const union_typet::componentst &comps = components();
311+
312+
optionalt<mp_integer> max_width;
313+
typet max_comp_type;
314+
irep_idt max_comp_name;
315+
316+
for(const auto &comp : comps)
317+
{
318+
auto element_width = pointer_offset_bits(comp.type(), ns);
319+
320+
if(!element_width.has_value())
321+
return {};
322+
323+
if(max_width.has_value() && *element_width <= *max_width)
324+
continue;
325+
326+
max_width = *element_width;
327+
max_comp_type = comp.type();
328+
max_comp_name = comp.get_name();
329+
}
330+
331+
if(!max_width.has_value())
332+
return {};
333+
else
334+
return std::make_pair(
335+
struct_union_typet::componentt{max_comp_name, max_comp_type}, *max_width);
336+
}

0 commit comments

Comments
 (0)