Skip to content

Commit d9fd299

Browse files
committed
Make smt_function_application_termt constructor private
To prevent construction of function application without checking that the given arguments are valid for the given function.
1 parent ec7d8a2 commit d9fd299

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/solvers/smt2_incremental/smt_terms.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,15 @@ class smt_bit_vector_constant_termt : public smt_termt
113113

114114
class smt_function_application_termt : public smt_termt
115115
{
116-
public:
117-
// Public access is deprecated and will be replaced with the `of` factory
118-
// function which will perform checks relevant to the particular function
119-
// being applied. To be fixed before the end of this PR.
116+
private:
117+
/// Unchecked construction of function application terms. The public factoryt
118+
/// sub class should be used to construct instances of this term with the
119+
/// appropriate checks for the function being applied.
120120
smt_function_application_termt(
121121
smt_identifier_termt function_identifier,
122122
std::vector<smt_termt> arguments);
123+
124+
public:
123125
const smt_identifier_termt &function_identifier() const;
124126
std::vector<std::reference_wrapper<const smt_termt>> arguments() const;
125127

unit/solvers/smt2_incremental/smt_terms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <testing-utils/use_catch.h>
44

5+
#include <solvers/smt2_incremental/smt_core_theory.h>
56
#include <solvers/smt2_incremental/smt_terms.h>
67

78
#include <util/mp_arith.h>
@@ -147,8 +148,7 @@ smt_bit_vector_constant_termt make_test_term<smt_bit_vector_constant_termt>()
147148
template <>
148149
smt_function_application_termt make_test_term<smt_function_application_termt>()
149150
{
150-
return smt_function_application_termt{
151-
smt_identifier_termt{"bar", smt_bool_sortt{}}, {}};
151+
return smt_core_theoryt::make_not(smt_bool_literal_termt{true});
152152
}
153153

154154
TEMPLATE_TEST_CASE(

unit/solvers/smt2_incremental/smt_to_smt2_string.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <testing-utils/use_catch.h>
44

55
#include <solvers/smt2_incremental/smt_commands.h>
6+
#include <solvers/smt2_incremental/smt_core_theory.h>
67
#include <solvers/smt2_incremental/smt_logics.h>
78
#include <solvers/smt2_incremental/smt_sorts.h>
89
#include <solvers/smt2_incremental/smt_terms.h>
@@ -36,10 +37,9 @@ TEST_CASE(
3637
"[core][smt2_incremental]")
3738
{
3839
CHECK(
39-
smt_to_smt2_string(smt_function_application_termt{
40-
smt_identifier_termt{"=", smt_bool_sortt{}},
41-
{smt_identifier_termt{"foo", smt_bit_vector_sortt{32}},
42-
{smt_identifier_termt{"bar", smt_bit_vector_sortt{32}}}}}) ==
40+
smt_to_smt2_string(smt_core_theoryt::equal(
41+
smt_identifier_termt{"foo", smt_bit_vector_sortt{32}},
42+
smt_identifier_termt{"bar", smt_bit_vector_sortt{32}})) ==
4343
"(|=| |foo| |bar|)");
4444
}
4545

@@ -102,10 +102,7 @@ TEST_CASE(
102102

103103
CHECK(
104104
smt_to_smt2_string(smt_define_function_commandt{
105-
"f",
106-
{g, h},
107-
smt_function_application_termt{
108-
smt_identifier_termt{"=", smt_bool_sortt{}}, {g, h}}}) ==
105+
"f", {g, h}, smt_core_theoryt::equal(g, h)}) ==
109106
"(define-fun |f| ((|g| (_ BitVec 32)) (|h| (_ BitVec 32))) Bool (|=| |g| "
110107
"|h|))");
111108
}

0 commit comments

Comments
 (0)