@@ -704,6 +704,38 @@ void add_array_to_length_association(
704
704
symbol_table));
705
705
}
706
706
707
+ // / Add a call to a primitive of the string solver which ensures all characters
708
+ // / belong to the character set.
709
+ // / \param pointer: a character pointer expression
710
+ // / \param length: length of the character sequence pointed by `pointer`
711
+ // / \param char_set: character set given by a range expression consisting of
712
+ // / two characters separated by an hyphen.
713
+ // / For instance "a-z" denotes all lower case ascii letters.
714
+ // / \param symbol_table: the symbol table
715
+ // / \param loc: source location
716
+ // / \param code [out] : code block to which declaration and calls get added
717
+ void add_character_set_constraint (
718
+ const exprt &pointer,
719
+ const exprt &length,
720
+ const irep_idt &char_set,
721
+ symbol_tablet &symbol_table,
722
+ const source_locationt &loc,
723
+ code_blockt &code)
724
+ {
725
+ PRECONDITION (pointer.type ().id () == ID_pointer);
726
+ symbolt &return_sym = get_fresh_aux_symbol (
727
+ java_int_type (), " cnstr_added" , " cnstr_added" , loc, ID_java, symbol_table);
728
+ const exprt return_expr = return_sym.symbol_expr ();
729
+ code.add (code_declt (return_expr));
730
+ const constant_exprt char_set_expr (char_set, string_typet ());
731
+ code.add (
732
+ code_assign_function_application (
733
+ return_expr,
734
+ ID_cprover_string_constrain_characters_func,
735
+ {length, pointer, char_set_expr},
736
+ symbol_table));
737
+ }
738
+
707
739
// / Create a refined_string_exprt `str` whose content and length are fresh
708
740
// / symbols, calls the string primitive with name `function_name`.
709
741
// / In the arguments of the primitive `str` takes the place of the result and
0 commit comments