Skip to content

Commit a3aee7d

Browse files
authored
Merge pull request #5086 from smowton/smowton/fix/remove-buggy-to-code-point-function
Remove buggy model of Character.toCodePoint
2 parents eaf8cb3 + 0d9223e commit a3aee7d

File tree

5 files changed

+23
-31
lines changed

5 files changed

+23
-31
lines changed
833 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class Test {
2+
3+
public void test(char a, char b) {
4+
assert Character.toCodePoint((char)0xD800, (char)0xDC00) == 0x10000;
5+
assert Character.toCodePoint((char)0xDBFF, (char)0xDFFF) == 0x10ffff;
6+
assert Character.toCodePoint((char)0xD800, (char)0xDFFF) == 0x103ff;
7+
assert Character.toCodePoint((char)0xDBFF, (char)0xDC00) == 0x10fc00;
8+
assert Character.toCodePoint(a, b) == 0x10000;
9+
}
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
Test.class
3+
--function Test.test --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^\[java::Test.test:\(CC\)V.assertion\.1\] line 4 .* SUCCESS$
5+
^\[java::Test.test:\(CC\)V.assertion\.2\] line 5 .* SUCCESS$
6+
^\[java::Test.test:\(CC\)V.assertion\.3\] line 6 .* SUCCESS$
7+
^\[java::Test.test:\(CC\)V.assertion\.4\] line 7 .* SUCCESS$
8+
^\[java::Test.test:\(CC\)V.assertion\.5\] line 8 .* FAILURE$
9+
^VERIFICATION FAILED$
10+
^EXIT=10$
11+
^SIGNAL=0$
12+
--
13+
^warning: ignoring

jbmc/src/java_bytecode/character_refine_preprocess.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,34 +1155,6 @@ codet character_refine_preprocesst::convert_reverse_bytes(
11551155
&character_refine_preprocesst::expr_of_reverse_bytes, target);
11561156
}
11571157

1158-
/// Converts function call to an assignment of an expression corresponding to
1159-
/// the java method Character.toCodePoint:(CC)I
1160-
/// \param target: a position in a goto program
1161-
codet character_refine_preprocesst::convert_to_code_point(
1162-
conversion_inputt &target)
1163-
{
1164-
const code_function_callt &function_call=target;
1165-
assert(function_call.arguments().size()==2);
1166-
const exprt &arg0=function_call.arguments()[0];
1167-
const exprt &arg1=function_call.arguments()[1];
1168-
const exprt &result=function_call.lhs();
1169-
const typet &type=result.type();
1170-
1171-
// These operations implement the decoding of a unicode symbol encoded
1172-
// in UTF16 for the supplementary planes (above U+10000).
1173-
// The low ten bits of the first character give the bits 10 to 19 of
1174-
// code point and the low ten bits of the second give the bits 0 to 9,
1175-
// then 0x10000 is added to the result. For more explenations see:
1176-
// https://en.wikipedia.org/wiki/UTF-16
1177-
1178-
exprt u010000=from_integer(0x010000, type);
1179-
exprt mask10bit=from_integer(0x03FF, type);
1180-
shl_exprt m1(bitand_exprt(arg0, mask10bit), from_integer(10, type));
1181-
bitand_exprt m2(arg1, mask10bit);
1182-
bitor_exprt pair_value(u010000, bitor_exprt(m1, m2));
1183-
return code_assignt(result, pair_value);
1184-
}
1185-
11861158
/// Converts the character argument to lowercase.
11871159
///
11881160
/// TODO: For now we only consider ASCII characters but ultimately
@@ -1481,8 +1453,6 @@ void character_refine_preprocesst::initialize_conversion_table()
14811453

14821454
// Not supported "java::java.lang.Character.toChars:(I[CI)I"
14831455

1484-
conversion_table["java::java.lang.Character.toCodePoint:(CC)I"]=
1485-
&character_refine_preprocesst::convert_to_code_point;
14861456
conversion_table["java::java.lang.Character.toLowerCase:(C)C"]=
14871457
&character_refine_preprocesst::convert_to_lower_case_char;
14881458
conversion_table["java::java.lang.Character.toLowerCase:(I)I"]=

jbmc/src/java_bytecode/character_refine_preprocess.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ class character_refine_preprocesst
133133
static codet convert_reverse_bytes(conversion_inputt &target);
134134
static exprt expr_of_to_chars(const exprt &chr, const typet &type);
135135
static codet convert_to_chars(conversion_inputt &target);
136-
static codet convert_to_code_point(conversion_inputt &target);
137136
static exprt expr_of_to_lower_case(const exprt &chr, const typet &type);
138137
static codet convert_to_lower_case_char(conversion_inputt &target);
139138
static codet convert_to_lower_case_int(conversion_inputt &target);

0 commit comments

Comments
 (0)