[ELF] Simplify isValidCIdentifier. NFC

This commit is contained in:
Fangrui Song
2021-03-11 09:38:15 -08:00
parent 49173ca4db
commit 0890b39ee9

View File

@@ -76,9 +76,8 @@ std::vector<uint8_t> lld::parseHex(StringRef s) {
// Returns true if S is valid as a C language identifier.
bool lld::isValidCIdentifier(StringRef s) {
return !s.empty() && (isAlpha(s[0]) || s[0] == '_') &&
std::all_of(s.begin() + 1, s.end(),
[](char c) { return c == '_' || isAlnum(c); });
return !s.empty() && !isDigit(s[0]) &&
llvm::all_of(s, [](char c) { return isAlnum(c) || c == '_'; });
}
// Write the contents of the a buffer to a file