Skip to content

Commit bb22700

Browse files
Cleanup unused fields of constraint generator
This removes unused functions, declaration of unimplemented function, unused constants and unused fields.
1 parent 2355e8e commit bb22700

File tree

3 files changed

+0
-99
lines changed

3 files changed

+0
-99
lines changed

src/solvers/refinement/string_constraint_generator.h

-25
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ class string_constraint_generatort final
6161
/// Set of strings that have been created by the generator
6262
const std::set<array_string_exprt> &get_created_strings() const;
6363

64-
array_string_exprt get_char_array_for_pointer(const exprt &pointer) const;
65-
6664
exprt get_witness_of(
6765
const string_not_contains_constraintt &c,
6866
const exprt &univ_val) const
@@ -100,10 +98,6 @@ class string_constraint_generatort final
10098
array_string_exprt get_string_expr(const exprt &expr);
10199
plus_exprt plus_exprt_with_overflow_check(const exprt &op1, const exprt &op2);
102100

103-
array_string_exprt find_or_add_string_of_symbol(
104-
const symbol_exprt &sym,
105-
const refined_string_typet &ref_type);
106-
107101
array_string_exprt associate_char_array_to_char_pointer(
108102
const exprt &char_pointer,
109103
const typet &char_array_type);
@@ -113,8 +107,6 @@ class string_constraint_generatort final
113107
array_string_exprt
114108
char_array_of_pointer(const exprt &pointer, const exprt &length);
115109

116-
static irep_idt extract_java_string(const symbol_exprt &s);
117-
118110
void add_default_axioms(const array_string_exprt &s);
119111
exprt axiom_for_is_positive_index(const exprt &x);
120112

@@ -179,10 +171,6 @@ class string_constraint_generatort final
179171
const array_string_exprt &res,
180172
const std::string &s,
181173
const exprt::operandst &args);
182-
exprt add_axioms_for_format_specifier_is_correct(
183-
const function_application_exprt &expr);
184-
bool add_axioms_for_format_specifier_is_correct(
185-
const std::string &s);
186174

187175
array_string_exprt add_axioms_for_format_specifier(
188176
const format_specifiert &fs,
@@ -216,7 +204,6 @@ class string_constraint_generatort final
216204
exprt add_axioms_from_int_hex(const array_string_exprt &res, const exprt &i);
217205
exprt add_axioms_from_int_hex(const function_application_exprt &f);
218206
exprt add_axioms_from_long(const function_application_exprt &f);
219-
array_string_exprt add_axioms_from_long(const exprt &i, size_t max_size);
220207
exprt add_axioms_from_bool(const function_application_exprt &f);
221208
exprt add_axioms_from_bool(const array_string_exprt &res, const exprt &i);
222209
exprt add_axioms_from_char(const function_application_exprt &f);
@@ -294,7 +281,6 @@ class string_constraint_generatort final
294281
exprt add_axioms_for_code_point(
295282
const array_string_exprt &res,
296283
const exprt &code_point);
297-
array_string_exprt add_axioms_for_if(const if_exprt &expr);
298284
exprt add_axioms_for_char_literal(const function_application_exprt &f);
299285

300286
// Add axioms corresponding the String.codePointCount java function
@@ -343,7 +329,6 @@ class string_constraint_generatort final
343329
static exprt is_low_surrogate(const exprt &chr);
344330
static exprt character_equals_ignore_case(
345331
exprt char1, exprt char2, exprt char_a, exprt char_A, exprt char_Z);
346-
static bool is_constant_string(const array_string_exprt &expr);
347332
unsigned long to_integer_or_default(const exprt &expr, unsigned long def);
348333

349334
// MEMBERS
@@ -352,24 +337,14 @@ class string_constraint_generatort final
352337
// Used to store information about witnesses for not_contains constraints
353338
std::map<string_not_contains_constraintt, symbol_exprt> witness;
354339
private:
355-
// The integer with the longest string is Integer.MIN_VALUE which is -2^31,
356-
// that is -2147483648 so takes 11 characters to write.
357-
// The long with the longest string is Long.MIN_VALUE which is -2^63,
358-
// approximately -9.223372037*10^18 so takes 20 characters to write.
359-
CBMC_CONSTEXPR static const std::size_t MAX_INTEGER_LENGTH=11;
360-
CBMC_CONSTEXPR static const std::size_t MAX_LONG_LENGTH=20;
361-
CBMC_CONSTEXPR static const std::size_t MAX_FLOAT_LENGTH=15;
362-
CBMC_CONSTEXPR static const std::size_t MAX_DOUBLE_LENGTH=30;
363340
std::set<array_string_exprt> m_created_strings;
364341
unsigned m_symbol_count=0;
365342
const messaget m_message;
366343
const bool m_force_printable_characters;
367344

368345
std::vector<exprt> m_axioms;
369-
std::map<irep_idt, array_string_exprt> m_unresolved_symbols;
370346
std::vector<symbol_exprt> m_boolean_symbols;
371347
std::vector<symbol_exprt> m_index_symbols;
372-
std::map<function_application_exprt, exprt> m_function_application_cache;
373348
const namespacet m_ns;
374349
// To each string on which hash_code was called we associate a symbol
375350
// representing the return value of the hash_code function.

src/solvers/refinement/string_constraint_generator_main.cpp

-55
Original file line numberDiff line numberDiff line change
@@ -342,61 +342,6 @@ array_string_exprt string_constraint_generatort::char_array_of_pointer(
342342
return array;
343343
}
344344

345-
/// This can throw an exception if the pointer has not been associated to
346-
/// an array yet.
347-
array_string_exprt string_constraint_generatort::get_char_array_for_pointer(
348-
const exprt &pointer) const
349-
{
350-
return arrays_of_pointers_.at(pointer);
351-
}
352-
353-
/// add axioms for an if expression which should return a string
354-
/// \par parameters: an if expression
355-
/// \return a string expression
356-
array_string_exprt
357-
string_constraint_generatort::add_axioms_for_if(const if_exprt &expr)
358-
{
359-
PRECONDITION(is_refined_string_type(expr.true_case().type()));
360-
array_string_exprt t = get_string_expr(expr.true_case());
361-
PRECONDITION(is_refined_string_type(expr.false_case().type()));
362-
array_string_exprt f = get_string_expr(expr.false_case());
363-
const typet &char_type = t.content().type().subtype();
364-
const typet &index_type = t.length().type();
365-
array_string_exprt res = fresh_string(index_type, char_type);
366-
367-
m_axioms.push_back(
368-
implies_exprt(expr.cond(), equal_exprt(res.length(), t.length())));
369-
symbol_exprt qvar=fresh_univ_index("QA_string_if_true", index_type);
370-
equal_exprt qequal(res[qvar], t[qvar]);
371-
string_constraintt sc1(qvar, t.length(), implies_exprt(expr.cond(), qequal));
372-
m_axioms.push_back(sc1);
373-
m_axioms.push_back(
374-
implies_exprt(
375-
not_exprt(expr.cond()), equal_exprt(res.length(), f.length())));
376-
symbol_exprt qvar2=fresh_univ_index("QA_string_if_false", index_type);
377-
equal_exprt qequal2(res[qvar2], f[qvar2]);
378-
string_constraintt sc2(qvar2, f.length(), or_exprt(expr.cond(), qequal2));
379-
m_axioms.push_back(sc2);
380-
return res;
381-
}
382-
383-
/// if a symbol representing a string is present in the symbol_to_string table,
384-
/// returns the corresponding string, if the symbol is not yet present, creates
385-
/// a new string with the correct type depending on whether the mode is java or
386-
/// c, adds it to the table and returns it.
387-
/// \par parameters: a symbol expression
388-
/// \return a string expression
389-
array_string_exprt string_constraint_generatort::find_or_add_string_of_symbol(
390-
const symbol_exprt &sym,
391-
const refined_string_typet &ref_type)
392-
{
393-
irep_idt id=sym.get_identifier();
394-
array_string_exprt str =
395-
fresh_string(ref_type.get_index_type(), ref_type.get_char_type());
396-
auto entry=m_unresolved_symbols.insert(std::make_pair(id, str));
397-
return entry.first->second;
398-
}
399-
400345
/// strings contained in this call are converted to objects of type
401346
/// `string_exprt`, through adding axioms. Axioms are then added to enforce that
402347
/// the result corresponds to the function application.

src/solvers/refinement/string_constraint_generator_testing.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -156,25 +156,6 @@ exprt string_constraint_generatort::add_axioms_for_is_suffix(
156156
return tc_issuffix;
157157
}
158158

159-
/// tells whether the given string is a constant
160-
/// \param expr: a string expression
161-
/// \return a Boolean
162-
bool string_constraint_generatort::is_constant_string(
163-
const array_string_exprt &expr)
164-
{
165-
if(expr.id()!=ID_struct ||
166-
expr.operands().size()!=2 ||
167-
expr.length().id()!=ID_constant ||
168-
expr.content().id()!=ID_array)
169-
return false;
170-
for(const auto &element : expr.content().operands())
171-
{
172-
if(element.id()!=ID_constant)
173-
return false;
174-
}
175-
return true;
176-
}
177-
178159
/// add axioms corresponding to the String.contains java function
179160
/// \par parameters: function application with two string arguments
180161
/// \return a Boolean expression

0 commit comments

Comments
 (0)