Revert "Allow unicode range 0x10000..0x10ffff in identifiers."
This reverts commit f5cabd3087d80b2da680e3ca7fda331b9df5e190.
Reason for revert: redness on the buildbots.
Change-Id: I4ace842f950b506871ee36e3235371b66235ed16
diff --git a/src/main/java/com/android/tools/r8/utils/IdentifierUtils.java b/src/main/java/com/android/tools/r8/utils/IdentifierUtils.java
index 07074ff..3097a07 100644
--- a/src/main/java/com/android/tools/r8/utils/IdentifierUtils.java
+++ b/src/main/java/com/android/tools/r8/utils/IdentifierUtils.java
@@ -15,25 +15,33 @@
}
private static boolean isSimpleNameChar(char ch) {
- // Test if we have a SimpleChar,
- // see https://source.android.com/devices/tech/dalvik/dex-format#string-syntax.
- //
- // NOTE: we assume the input strings are well-formed UTF-16 strings.
- // This matters when checking the range 0x10000..0x10ffff, which is represented by a pair of
- // UTF-16 surrogates. In that case, instead of checking the actual code point, we let pass all
- // characters which are high or low surrogates.
- return ('A' <= ch && ch <= 'Z')
- || ('a' <= ch && ch <= 'z')
- || ('0' <= ch && ch <= '9')
- || ch == '$'
- || ch == '-'
- || ch == '_'
- || (0x00a1 <= ch && ch <= 0x1fff)
- || (0x2010 <= ch && ch <= 0x2027)
- // The next range consists of these ranges:
- // 0x2030..0xd7ff, then
- // 0xd800..0xdfff (low or high surrogates), then
- // 0xe000..0xffef.
- || (0x2030 <= ch && ch <= 0xffef);
+ if (ch >= 'A' && ch <= 'Z') {
+ return true;
+ }
+ if (ch >= 'a' && ch <= 'z') {
+ return true;
+ }
+ if (ch >= '0' && ch <= '9') {
+ return true;
+ }
+ if (ch == '$' || ch == '-' || ch == '_') {
+ return true;
+ }
+ if (ch >= 0x00a1 && ch <= 0x1fff) {
+ return true;
+ }
+ if (ch >= 0x2010 && ch <= 0x2027) {
+ return true;
+ }
+ if (ch >= 0x2030 && ch <= 0xd7ff) {
+ return true;
+ }
+ if (ch >= 0xe000 && ch <= 0xffef) {
+ return true;
+ }
+ if (ch >= 0x10000 && ch <= 0x10ffff) {
+ return true;
+ }
+ return false;
}
}
diff --git a/src/test/java/com/android/tools/r8/dex/DexStringTest.java b/src/test/java/com/android/tools/r8/dex/DexStringTest.java
index 394ce53..b12d876 100644
--- a/src/test/java/com/android/tools/r8/dex/DexStringTest.java
+++ b/src/test/java/com/android/tools/r8/dex/DexStringTest.java
@@ -8,9 +8,6 @@
import com.android.tools.r8.graph.DexItemFactory;
import com.android.tools.r8.graph.DexString;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-import java.util.Set;
import org.junit.Test;
public class DexStringTest {
@@ -108,24 +105,4 @@
assertEquals("\\ud800\\udc00", factory.createString("\ud800\udc00").toASCIIString());
assertEquals("\\udbff\\udfff", factory.createString("\udbff\udfff").toASCIIString());
}
-
- @Test
- public void testIsValid() {
- DexItemFactory factory = new DexItemFactory();
- Set<String> goods =
- ImmutableSet.of(
- "\u00a1",
- "\u1fff\u2010\u2027\u2030\ud7ff\ue000\uffef",
- "a\ud800\udc00\udbff\udfffb\ud800\udc00c\udbff\udfff");
- Set<String> bads = ImmutableSet.of("\u00a0", "\u2000", "\u202f", "\uffff");
- Set<String> all = Sets.union(goods, bads);
-
- for (String s : all) {
- DexString ds = factory.createString(s);
- boolean isGood = goods.contains(s);
- assertEquals(isGood, ds.isValidFieldName());
- assertEquals(isGood, ds.isValidMethodName());
- assertEquals(isGood, factory.createString("L" + s + ";").isValidClassDescriptor());
- }
- }
}