1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[llvm] Use isAlpha/isAlnum (NFC)

This commit is contained in:
Kazu Hirata 2021-01-22 23:25:03 -08:00
parent 94106f21e8
commit 0069e576c3
7 changed files with 10 additions and 33 deletions

View File

@ -18,6 +18,7 @@
#define LLVM_BITSTREAM_BITCODES_H #define LLVM_BITSTREAM_BITCODES_H
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/DataTypes.h" #include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include <cassert> #include <cassert>
@ -137,13 +138,7 @@ public:
} }
/// isChar6 - Return true if this character is legal in the Char6 encoding. /// isChar6 - Return true if this character is legal in the Char6 encoding.
static bool isChar6(char C) { static bool isChar6(char C) { return isAlnum(C) || C == '.' || C == '_'; }
if (C >= 'a' && C <= 'z') return true;
if (C >= 'A' && C <= 'Z') return true;
if (C >= '0' && C <= '9') return true;
if (C == '.' || C == '_') return true;
return false;
}
static unsigned EncodeChar6(char C) { static unsigned EncodeChar6(char C) {
if (C >= 'a' && C <= 'z') return C-'a'; if (C >= 'a' && C <= 'z') return C-'a';
if (C >= 'A' && C <= 'Z') return C-'A'+26; if (C >= 'A' && C <= 'Z') return C-'A'+26;

View File

@ -12,6 +12,7 @@
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h" #include "llvm/ADT/Triple.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/IR/DataLayout.h" #include "llvm/IR/DataLayout.h"
@ -186,8 +187,7 @@ void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
// Check if the name needs quotes to be safe for the linker to interpret. // Check if the name needs quotes to be safe for the linker to interpret.
static bool canBeUnquotedInDirective(char C) { static bool canBeUnquotedInDirective(char C) {
return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') || return isAlnum(C) || C == '_' || C == '$' || C == '.' || C == '@';
(C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@';
} }
static bool canBeUnquotedInDirective(StringRef Name) { static bool canBeUnquotedInDirective(StringRef Name) {

View File

@ -109,8 +109,7 @@ MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
} }
bool MCAsmInfo::isAcceptableChar(char C) const { bool MCAsmInfo::isAcceptableChar(char C) const {
return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') || return isAlnum(C) || C == '_' || C == '$' || C == '.' || C == '@';
(C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@';
} }
bool MCAsmInfo::isValidUnquotedName(StringRef Name) const { bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {

View File

@ -981,17 +981,9 @@ void Scanner::advanceWhile(SkipWhileFunc Func) {
Current = Final; Current = Final;
} }
static bool is_ns_hex_digit(const char C) { static bool is_ns_hex_digit(const char C) { return isAlnum(C); }
return (C >= '0' && C <= '9')
|| (C >= 'a' && C <= 'z')
|| (C >= 'A' && C <= 'Z');
}
static bool is_ns_word_char(const char C) { static bool is_ns_word_char(const char C) { return C == '-' || isAlpha(C); }
return C == '-'
|| (C >= 'a' && C <= 'z')
|| (C >= 'A' && C <= 'Z');
}
void Scanner::scan_ns_uri_char() { void Scanner::scan_ns_uri_char() {
while (true) { while (true) {

View File

@ -1112,9 +1112,7 @@ static std::string getEnumNameForToken(StringRef Str) {
case '-': Res += "_MINUS_"; break; case '-': Res += "_MINUS_"; break;
case '#': Res += "_HASH_"; break; case '#': Res += "_HASH_"; break;
default: default:
if ((*it >= 'A' && *it <= 'Z') || if (isAlnum(*it))
(*it >= 'a' && *it <= 'z') ||
(*it >= '0' && *it <= '9'))
Res += *it; Res += *it;
else else
Res += "_" + utostr((unsigned) *it) + "_"; Res += "_" + utostr((unsigned) *it) + "_";

View File

@ -713,9 +713,7 @@ public:
++Next; ++Next;
} else { } else {
// $name, just eat the usual suspects. // $name, just eat the usual suspects.
while (I != End && while (I != End && (isAlnum(*I) || *I == '_'))
((*I >= 'a' && *I <= 'z') || (*I >= 'A' && *I <= 'Z') ||
(*I >= '0' && *I <= '9') || *I == '_'))
++I; ++I;
Next = I; Next = I;
} }

View File

@ -18,12 +18,7 @@
using namespace llvm; using namespace llvm;
static bool isIdentChar(char C) { static bool isIdentChar(char C) { return isAlnum(C) || C == '_'; }
return (C >= 'a' && C <= 'z') ||
(C >= 'A' && C <= 'Z') ||
(C >= '0' && C <= '9') ||
C == '_';
}
std::string AsmWriterOperand::getCode(bool PassSubtarget) const { std::string AsmWriterOperand::getCode(bool PassSubtarget) const {
if (OperandType == isLiteralTextOperand) { if (OperandType == isLiteralTextOperand) {