[TableGen] Use range-based for loops (NFC) (#144250)

This commit is contained in:
Kazu Hirata 2025-06-15 10:32:37 -07:00 committed by GitHub
parent 2669664605
commit fef5df9d84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 12 deletions

View File

@ -78,10 +78,10 @@ void clang::EmitClangCommentCommandInfo(const RecordKeeper &Records,
static std::string MangleName(StringRef Str) {
std::string Mangled;
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
switch (Str[i]) {
for (char C : Str) {
switch (C) {
default:
Mangled += Str[i];
Mangled += C;
break;
case '(':
Mangled += "lparen";
@ -122,9 +122,8 @@ void clang::EmitClangCommentCommandList(const RecordKeeper &Records,
<< "#endif\n";
ArrayRef<const Record *> Tags = Records.getAllDerivedDefinitions("Command");
for (size_t i = 0, e = Tags.size(); i != e; ++i) {
const Record &Tag = *Tags[i];
std::string MangledName = MangleName(Tag.getValueAsString("Name"));
for (const Record *Tag : Tags) {
std::string MangledName = MangleName(Tag->getValueAsString("Name"));
OS << "COMMENT_COMMAND(" << MangledName << ")\n";
}

View File

@ -37,9 +37,9 @@ static bool translateCodePointToUTF8(unsigned CodePoint,
raw_svector_ostream OS(CLiteral);
OS << "\"";
for (size_t i = 0, e = UTF8.size(); i != e; ++i) {
for (char C : UTF8) {
OS << "\\x";
OS.write_hex(static_cast<unsigned char>(UTF8[i]));
OS.write_hex(static_cast<unsigned char>(C));
}
OS << "\"";

View File

@ -1794,8 +1794,8 @@ static std::string getDiagCategoryEnum(StringRef name) {
if (name.empty())
return "DiagCat_None";
SmallString<256> enumName = StringRef("DiagCat_");
for (StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
enumName += isalnum(*I) ? *I : '_';
for (char C : name)
enumName += isalnum(C) ? C : '_';
return std::string(enumName);
}

View File

@ -224,8 +224,7 @@ void ClangOpcodesEmitter::EmitProto(raw_ostream &OS, StringRef N,
auto Args = R->getValueAsListOfDefs("Args");
Enumerate(R, N, [&OS, &Args](ArrayRef<const Record *> TS, const Twine &ID) {
OS << "bool emit" << ID << "(";
for (size_t I = 0, N = Args.size(); I < N; ++I) {
const auto *Arg = Args[I];
for (const Record *Arg : Args) {
bool AsRef = Arg->getValueAsBit("AsRef");
auto Name = Arg->getValueAsString("Name");