summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/LinkerScript.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-02-04 00:00:21 +0000
committerRui Ueyama <ruiu@google.com>2015-02-04 00:00:21 +0000
commitcb6eb82e485f964cf79f8099bbb6138d6f82cb7a (patch)
tree819060b1ca8f9bcac07cf4a18522b75a4325e0fe /lld/lib/ReaderWriter/LinkerScript.cpp
parentfd34280b8e64fa68d4c2cfcfe1aa754289a1bfb7 (diff)
downloadbcm5719-llvm-cb6eb82e485f964cf79f8099bbb6138d6f82cb7a.tar.gz
bcm5719-llvm-cb6eb82e485f964cf79f8099bbb6138d6f82cb7a.zip
Simplify large switches.
This may be a little bit inefficient than the original code but that should be okay as this is not really in a performance critical pass. http://reviews.llvm.org/D7393 llvm-svn: 228077
Diffstat (limited to 'lld/lib/ReaderWriter/LinkerScript.cpp')
-rw-r--r--lld/lib/ReaderWriter/LinkerScript.cpp59
1 files changed, 5 insertions, 54 deletions
diff --git a/lld/lib/ReaderWriter/LinkerScript.cpp b/lld/lib/ReaderWriter/LinkerScript.cpp
index ef0bc955ef9..9d3619dc790 100644
--- a/lld/lib/ReaderWriter/LinkerScript.cpp
+++ b/lld/lib/ReaderWriter/LinkerScript.cpp
@@ -242,66 +242,17 @@ bool Lexer::canStartNumber(char c) const {
}
bool Lexer::canContinueNumber(char c) const {
- switch (c) {
- // Digits
- case '0': case '1': case '2': case '3': case '4': case '5': case '6':
- case '7': case '8': case '9':
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- // Hex marker
- case 'x': case 'X':
- // Type suffix
- case 'h': case 'H': case 'o': case 'O':
- // Scale suffix
- case 'M': case 'K':
- return true;
- default:
- return false;
- }
+ return strchr("0123456789ABCDEFabcdefxXhHoOMK", c);
}
bool Lexer::canStartName(char c) const {
- switch (c) {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
- case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
- case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
- case 'V': case 'W': case 'X': case 'Y': case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
- case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
- case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
- case 'v': case 'w': case 'x': case 'y': case 'z':
- case '_': case '.': case '$': case '/': case '\\':
- case '*':
- return true;
- default:
- return false;
- }
+ return strchr(
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_.$/\\*", c);
}
bool Lexer::canContinueName(char c) const {
- switch (c) {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
- case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
- case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
- case 'V': case 'W': case 'X': case 'Y': case 'Z':
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
- case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
- case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
- case 'v': case 'w': case 'x': case 'y': case 'z':
- case '0': case '1': case '2': case '3': case '4': case '5': case '6':
- case '7': case '8': case '9':
- case '_': case '.': case '$': case '/': case '\\': case '~': case '=':
- case '+':
- case '[':
- case ']':
- case '*':
- case '?':
- case '-':
- case ':':
- return true;
- default:
- return false;
- }
+ return strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ "0123456789_.$/\\~=+[]*?-:", c);
}
/// Helper function to split a StringRef in two at the nth character.
OpenPOWER on IntegriCloud