Skip to content

Commit 9a9ad37

Browse files
Merge pull request #176 from FrNecas/fnecas-svcomp-24
SV-COMP 24 fixes
2 parents c572aa1 + 651828d commit 9a9ad37

10 files changed

+46
-28
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
AccessModifierOffset: '-2'
3-
AlignAfterOpenBracket: Align
3+
AlignAfterOpenBracket: AlwaysBreak
44
AlignConsecutiveAssignments: 'false'
55
AlignConsecutiveDeclarations: 'false'
66
AlignEscapedNewlinesLeft: 'false'

src/2ls/2ls_parse_options.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ bool twols_parse_optionst::process_goto_program(
10231023
remove_returns(goto_model);
10241024

10251025
if(options.get_bool_option("competition-mode"))
1026-
assert_no_atexit(goto_model);
1026+
assert_no_unsupported_function_calls(goto_model);
10271027

10281028
// now do full inlining, if requested
10291029
if(options.get_bool_option("inline"))
@@ -1045,7 +1045,7 @@ bool twols_parse_optionst::process_goto_program(
10451045
}
10461046

10471047
if(options.get_bool_option("competition-mode"))
1048-
assert_no_builtin_functions(goto_model);
1048+
assert_no_unsupported_functions(goto_model);
10491049

10501050
make_scanf_nondet(goto_model);
10511051

src/2ls/2ls_parse_options.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class twols_parse_optionst:
185185
void remove_dead_goto(goto_modelt &goto_model);
186186
void memory_assert_info(goto_modelt &goto_model);
187187
void handle_freed_ptr_compare(goto_modelt &goto_model);
188-
void assert_no_builtin_functions(goto_modelt &goto_model);
189-
void assert_no_atexit(goto_modelt &goto_model);
188+
void assert_no_unsupported_functions(goto_modelt &goto_model);
189+
void assert_no_unsupported_function_calls(goto_modelt &goto_model);
190190
void fix_goto_targets(goto_modelt &goto_model);
191191
void make_assertions_false(goto_modelt &goto_model);
192192
void make_symbolic_array_indices(goto_modelt &goto_model);

src/2ls/preprocessing_util.cpp

+33-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Author: Peter Schrammel
2222

2323
#include "2ls_parse_options.h"
2424

25+
#define NOT_MATH_FUN(call, fun) call != fun &&call != fun "f" && call != fun "l"
26+
2527
void twols_parse_optionst::inline_main(goto_modelt &goto_model)
2628
{
2729
irep_idt start=goto_functionst::entry_point();
@@ -653,9 +655,12 @@ void twols_parse_optionst::handle_freed_ptr_compare(goto_modelt &goto_model)
653655
}
654656
}
655657

656-
/// Add assertions preventing analysis of programs using GCC builtin functions
657-
/// that are not supported and can cause false results.
658-
void twols_parse_optionst::assert_no_builtin_functions(goto_modelt &goto_model)
658+
/// Fail if the program contains any functions that 2LS does not currently
659+
/// support. These include:
660+
/// - builtin gcc functions
661+
/// - longjmp (not supported by CBMC)
662+
void twols_parse_optionst::assert_no_unsupported_functions(
663+
goto_modelt &goto_model)
659664
{
660665
forall_goto_program_instructions(
661666
i_it,
@@ -666,6 +671,7 @@ void twols_parse_optionst::assert_no_builtin_functions(goto_modelt &goto_model)
666671
assert(
667672
name.find("__builtin_")==std::string::npos &&
668673
name.find("__CPROVER_overflow")==std::string::npos);
674+
assert(name != "longjmp" && name != "_longjmp" && name != "siglongjmp");
669675

670676
if(i_it->is_assign())
671677
{
@@ -674,9 +680,13 @@ void twols_parse_optionst::assert_no_builtin_functions(goto_modelt &goto_model)
674680
}
675681
}
676682

677-
/// Prevents usage of atexit function which is not supported, yet
678-
/// Must be called before inlining since it will lose the calls
679-
void twols_parse_optionst::assert_no_atexit(goto_modelt &goto_model)
683+
/// Fail if the program contains a call to an unsupported function. These
684+
/// include the atexit function and advanced math functions from math.h (
685+
/// these are either not defined in CBMC at all, or defined very imprecisely,
686+
/// e.g. the result of cos is in <-1, 1> without any further information).
687+
/// Must be called before inlining since it will lose the calls.
688+
void twols_parse_optionst::assert_no_unsupported_function_calls(
689+
goto_modelt &goto_model)
680690
{
681691
for(const auto &f_it : goto_model.goto_functions.function_map)
682692
{
@@ -689,6 +699,23 @@ void twols_parse_optionst::assert_no_atexit(goto_modelt &goto_model)
689699
continue;
690700
auto &name=id2string(to_symbol_expr(function).get_identifier());
691701
assert(name!="atexit");
702+
assert(
703+
// Trigonometry
704+
NOT_MATH_FUN(name, "cos") && NOT_MATH_FUN(name, "acos") &&
705+
NOT_MATH_FUN(name, "sin") && NOT_MATH_FUN(name, "asin") &&
706+
NOT_MATH_FUN(name, "tan") && NOT_MATH_FUN(name, "atan") &&
707+
NOT_MATH_FUN(name, "atan2") &&
708+
// Hyperbolic
709+
NOT_MATH_FUN(name, "cosh") && NOT_MATH_FUN(name, "acosh") &&
710+
NOT_MATH_FUN(name, "sinh") && NOT_MATH_FUN(name, "asinh") &&
711+
NOT_MATH_FUN(name, "tanh") && NOT_MATH_FUN(name, "atanh") &&
712+
// Exponential
713+
NOT_MATH_FUN(name, "exp") && NOT_MATH_FUN(name, "exp2") &&
714+
NOT_MATH_FUN(name, "expm1") && NOT_MATH_FUN(name, "log") &&
715+
NOT_MATH_FUN(name, "log10") && NOT_MATH_FUN(name, "log2") &&
716+
NOT_MATH_FUN(name, "log1p") &&
717+
// Other
718+
NOT_MATH_FUN(name, "erf"));
692719
}
693720
}
694721
}

src/config.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CPROVER_DIR = ../../lib/cbmc
33
# Variables you may want to override
44

55
# Enable warnings
6-
CXXFLAGS += -Wall -Werror -Wno-long-long -Wno-sign-compare -Wno-parentheses -Wno-strict-aliasing -pedantic
6+
CXXFLAGS += -Wall -Werror -Wno-long-long -Wno-sign-compare -Wno-parentheses -Wno-c++20-compat -Wno-strict-aliasing -pedantic
77

88
# Select optimisation or debug
99
#CXXFLAGS += -O2

src/domains/template_generator_base.h

-9
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ class template_generator_baset:public messaget
4646
{
4747
}
4848

49-
virtual void operator()(
50-
unsigned _domain_number,
51-
const local_SSAt &SSA,
52-
bool forward=true)
53-
{
54-
domain_number=_domain_number;
55-
assert(false);
56-
}
57-
5849
virtual var_sett all_vars();
5950

6051
inline domaint *domain()

src/domains/template_generator_callingcontext.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class template_generator_callingcontextt:public template_generator_baset
2727
{
2828
}
2929

30-
virtual void operator()(
30+
void operator()(
3131
unsigned _domain_number,
3232
const local_SSAt &SSA,
3333
local_SSAt::nodest::const_iterator n_it,
3434
local_SSAt::nodet::function_callst::const_iterator f_it,
35-
bool forward=true);
35+
bool forward = true);
3636

3737
virtual var_sett callingcontext_vars();
3838

src/domains/template_generator_ranking.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class template_generator_rankingt:public template_generator_baset
2828
{
2929
}
3030

31-
virtual void operator()(
31+
void operator()(
3232
unsigned _domain_number,
3333
const local_SSAt &SSA,
34-
bool forward=true);
34+
bool forward = true);
3535

3636
protected:
3737
void collect_variables_ranking(

src/domains/template_generator_summary.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class template_generator_summaryt:public template_generator_baset
2828
{
2929
}
3030

31-
virtual void operator()(
31+
void operator()(
3232
unsigned _domain_number,
3333
const local_SSAt &SSA,
34-
bool forward=true);
34+
bool forward = true);
3535

3636
virtual var_sett inout_vars();
3737
virtual var_sett loop_vars();

0 commit comments

Comments
 (0)