diff options
Diffstat (limited to 'ELF/Strings.cpp')
-rw-r--r-- | ELF/Strings.cpp | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/ELF/Strings.cpp b/ELF/Strings.cpp index 2e88bfba0..766258f00 100644 --- a/ELF/Strings.cpp +++ b/ELF/Strings.cpp @@ -38,29 +38,6 @@ bool StringMatcher::match(StringRef S) const { return false; } -// If an input string is in the form of "foo.N" where N is a number, -// return N. Otherwise, returns 65536, which is one greater than the -// lowest priority. -int elf::getPriority(StringRef S) { - size_t Pos = S.rfind('.'); - if (Pos == StringRef::npos) - return 65536; - int V; - if (!to_integer(S.substr(Pos + 1), V, 10)) - return 65536; - return V; -} - -bool elf::hasWildcard(StringRef S) { - return S.find_first_of("?*[") != StringRef::npos; -} - -StringRef elf::unquote(StringRef S) { - if (!S.startswith("\"")) - return S; - return S.substr(1, S.size() - 2); -} - // Converts a hex string (e.g. "deadbeef") to a vector. std::vector<uint8_t> elf::parseHex(StringRef S) { std::vector<uint8_t> Hex; @@ -77,16 +54,11 @@ std::vector<uint8_t> elf::parseHex(StringRef S) { return Hex; } -static bool isAlpha(char C) { - return ('a' <= C && C <= 'z') || ('A' <= C && C <= 'Z') || C == '_'; -} - -static bool isAlnum(char C) { return isAlpha(C) || ('0' <= C && C <= '9'); } - // Returns true if S is valid as a C language identifier. bool elf::isValidCIdentifier(StringRef S) { - return !S.empty() && isAlpha(S[0]) && - std::all_of(S.begin() + 1, S.end(), isAlnum); + return !S.empty() && (isAlpha(S[0]) || S[0] == '_') && + std::all_of(S.begin() + 1, S.end(), + [](char C) { return C == '_' || isAlnum(C); }); } // Returns the demangled C++ symbol name for Name. |