Skip to content

Commit 2e8b539

Browse files
authored
[NFC][TableGen] Add {} for else when if body has {} (llvm#139420)
1 parent 386f2ca commit 2e8b539

22 files changed

+88
-48
lines changed

llvm/lib/TableGen/Record.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,9 @@ const Init *ListInit::convertInitializerTo(const RecTy *Ty) const {
751751
Elements.push_back(CI);
752752
if (CI != I)
753753
Changed = true;
754-
} else
754+
} else {
755755
return nullptr;
756+
}
756757

757758
if (!Changed)
758759
return this;

llvm/lib/TableGen/TGParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,9 +1928,10 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
19281928
const auto *Arg2 = cast<TypedInit>(Args[2]);
19291929
assert(isa<IntRecTy>(Arg2->getType()));
19301930
RHS = Arg2;
1931-
} else
1931+
} else {
19321932
// (start, end, 1)
19331933
RHS = IntInit::get(Records, 1);
1934+
}
19341935
}
19351936
return TernOpInit::get(TernOpInit::RANGE, LHS, MHS, RHS,
19361937
IntRecTy::get(Records)->getListTy())
@@ -1946,7 +1947,7 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
19461947
const RecTy *Type = nullptr;
19471948

19481949
tgtok::TokKind LexCode = Lex.getCode();
1949-
Lex.Lex(); // eat the operation
1950+
Lex.Lex(); // Eat the operation.
19501951
switch (LexCode) {
19511952
default: llvm_unreachable("Unhandled code!");
19521953
case tgtok::XDag:

llvm/utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,9 @@ void AsmMatcherInfo::buildRegisterClasses(
13471347
CI->ClassName = RC.getName();
13481348
CI->Name = "MCK_" + RC.getName();
13491349
CI->ValueName = RC.getName();
1350-
} else
1350+
} else {
13511351
CI->ValueName = CI->ValueName + "," + RC.getName();
1352+
}
13521353

13531354
const Init *DiagnosticType = Def->getValueInit("DiagnosticType");
13541355
if (const StringInit *SI = dyn_cast<StringInit>(DiagnosticType))
@@ -1379,8 +1380,9 @@ void AsmMatcherInfo::buildRegisterClasses(
13791380
CI->ClassName = std::string(Rec->getName());
13801381
CI->Name = "MCK_" + Rec->getName().str();
13811382
CI->ValueName = std::string(Rec->getName());
1382-
} else
1383+
} else {
13831384
CI->ValueName = CI->ValueName + "," + Rec->getName().str();
1385+
}
13841386
}
13851387
}
13861388

@@ -1663,13 +1665,14 @@ void AsmMatcherInfo::buildInfo() {
16631665
// Add the alias to the matchables list.
16641666
NewMatchables.push_back(std::move(AliasII));
16651667
}
1666-
} else
1668+
} else {
16671669
// FIXME: The tied operands checking is not yet integrated with the
16681670
// framework for reporting multiple near misses. To prevent invalid
16691671
// formats from being matched with an alias if a tied-operands check
16701672
// would otherwise have disallowed it, we just disallow such constructs
16711673
// in TableGen completely.
16721674
II->buildAliasResultOperands(!ReportMultipleNearMisses);
1675+
}
16731676
}
16741677
if (!NewMatchables.empty())
16751678
Matchables.insert(Matchables.end(),
@@ -2303,9 +2306,10 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
23032306
<< utostr(std::get<2>(KV.first)) << " },\n";
23042307
}
23052308
OS << "};\n\n";
2306-
} else
2309+
} else {
23072310
OS << "static const uint8_t TiedAsmOperandTable[][3] = "
23082311
"{ /* empty */ {0, 0, 0} };\n\n";
2312+
}
23092313

23102314
OS << "namespace {\n";
23112315

@@ -2503,8 +2507,9 @@ static void emitValidateOperandClass(const CodeGenTarget &Target,
25032507
OS << " return " << Info.Target.getName() << "AsmParser::Match_"
25042508
<< CI.DiagnosticType << ";\n";
25052509
OS << " break;\n";
2506-
} else
2510+
} else {
25072511
OS << " break;\n";
2512+
}
25082513
OS << " }\n";
25092514
}
25102515
OS << " } // end switch (Kind)\n\n";

llvm/utils/TableGen/AsmWriterEmitter.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,9 @@ void AsmWriterEmitter::EmitGetRegisterName(raw_ostream &O) {
660660
if (hasAltNames) {
661661
for (const Record *R : AltNameIndices)
662662
emitRegisterNameString(O, R->getName(), Registers);
663-
} else
663+
} else {
664664
emitRegisterNameString(O, "", Registers);
665+
}
665666

666667
if (hasAltNames) {
667668
O << " switch(AltIdx) {\n"
@@ -969,8 +970,9 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
969970
if (!Rec->isValueUnset("MCOperandPredicate")) {
970971
MCOpPredicates.push_back(Rec);
971972
Entry = MCOpPredicates.size();
972-
} else
973+
} else {
973974
break; // No conditions on this operand at all
975+
}
974976
}
975977
IAP.addCond(
976978
std::string(formatv("AliasPatternCond::K_Custom, {}", Entry)));

llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,16 @@ void CodeGenIntrinsic::setProperty(const Record *R) {
444444
int64_t Lower = R->getValueAsInt("Lower");
445445
int64_t Upper = R->getValueAsInt("Upper");
446446
addArgAttribute(ArgNo, Range, Lower, Upper);
447-
} else
447+
} else {
448448
llvm_unreachable("Unknown property!");
449+
}
449450
}
450451

451452
bool CodeGenIntrinsic::isParamAPointer(unsigned ParamIdx) const {
452453
if (ParamIdx >= IS.ParamTys.size())
453454
return false;
454-
return (IS.ParamTys[ParamIdx]->isSubClassOf("LLVMQualPointerType") ||
455-
IS.ParamTys[ParamIdx]->isSubClassOf("LLVMAnyPointerType"));
455+
return IS.ParamTys[ParamIdx]->isSubClassOf("LLVMQualPointerType") ||
456+
IS.ParamTys[ParamIdx]->isSubClassOf("LLVMAnyPointerType");
456457
}
457458

458459
bool CodeGenIntrinsic::isParamImmArg(unsigned ParamIdx) const {
@@ -461,8 +462,7 @@ bool CodeGenIntrinsic::isParamImmArg(unsigned ParamIdx) const {
461462
if (ParamIdx >= ArgumentAttributes.size())
462463
return false;
463464
ArgAttribute Val{ImmArg, 0, 0};
464-
return std::binary_search(ArgumentAttributes[ParamIdx].begin(),
465-
ArgumentAttributes[ParamIdx].end(), Val);
465+
return llvm::binary_search(ArgumentAttributes[ParamIdx], Val);
466466
}
467467

468468
void CodeGenIntrinsic::addArgAttribute(unsigned Idx, ArgAttrKind AK, uint64_t V,

llvm/utils/TableGen/Basic/VTEmitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ static void vTtoGetLlvmTyString(raw_ostream &OS, const Record *VT) {
7979
OS << "Type::getInt" << OutputVTSize << "Ty(Context)";
8080
else
8181
OS << "Type::getIntNTy(Context, " << OutputVTSize << ")";
82-
} else
82+
} else {
8383
llvm_unreachable("Unhandled case");
84+
}
8485

8586
if (IsVector)
8687
OS << ", " << VT->getValueAsInt("nElem") << ")";

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2405,8 +2405,9 @@ TreePatternNode::getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const {
24052405
if (!DI)
24062406
return nullptr;
24072407
Rec = DI->getDef();
2408-
} else
2408+
} else {
24092409
Rec = getOperator();
2410+
}
24102411

24112412
if (!Rec->isSubClassOf("ComplexPattern"))
24122413
return nullptr;

llvm/utils/TableGen/Common/CodeGenInstruction.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
3434
PrintFatalError(R->getLoc(),
3535
R->getName() +
3636
": invalid def name for output list: use 'outs'");
37-
} else
37+
} else {
3838
PrintFatalError(R->getLoc(),
3939
R->getName() + ": invalid output list: use 'outs'");
40+
}
4041

4142
NumDefs = OutDI->getNumArgs();
4243

@@ -46,9 +47,10 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
4647
PrintFatalError(R->getLoc(),
4748
R->getName() +
4849
": invalid def name for input list: use 'ins'");
49-
} else
50+
} else {
5051
PrintFatalError(R->getLoc(),
5152
R->getName() + ": invalid input list: use 'ins'");
53+
}
5254

5355
unsigned MIOperandNo = 0;
5456
std::set<std::string> OperandNames;

llvm/utils/TableGen/Common/CodeGenSchedule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,8 +2016,9 @@ void CodeGenSchedModels::collectRWResources(unsigned RWIdx, bool IsRead,
20162016
if (Alias->getValueInit("SchedModel")->isComplete()) {
20172017
AliasProcIndices.push_back(
20182018
getProcModel(Alias->getValueAsDef("SchedModel")).Index);
2019-
} else
2019+
} else {
20202020
AliasProcIndices = ProcIndices;
2021+
}
20212022
const CodeGenSchedRW &AliasRW = getSchedRW(Alias->getValueAsDef("AliasRW"));
20222023
assert(AliasRW.IsRead == IsRead && "cannot alias reads to writes");
20232024

llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,9 +2015,10 @@ void TempRegRenderer::emitRenderOpcodes(MatchTable &Table,
20152015
if (SubRegIdx) {
20162016
assert(!IsDef);
20172017
Table << MatchTable::Opcode("GIR_AddTempSubRegister");
2018-
} else
2018+
} else {
20192019
Table << MatchTable::Opcode(NeedsFlags ? "GIR_AddTempRegister"
20202020
: "GIR_AddSimpleTempRegister");
2021+
}
20212022

20222023
Table << MatchTable::Comment("InsnID") << MatchTable::ULEB128Value(InsnID)
20232024
<< MatchTable::Comment("TempRegID")
@@ -2035,8 +2036,9 @@ void TempRegRenderer::emitRenderOpcodes(MatchTable &Table,
20352036
if (IsDead)
20362037
RegFlags += "|RegState::Dead";
20372038
Table << MatchTable::NamedValue(2, RegFlags);
2038-
} else
2039+
} else {
20392040
Table << MatchTable::IntValue(2, 0);
2041+
}
20402042

20412043
if (SubRegIdx)
20422044
Table << MatchTable::NamedValue(2, SubRegIdx->getQualifiedName());
@@ -2064,8 +2066,9 @@ void ImmRenderer::emitRenderOpcodes(MatchTable &Table,
20642066
<< MatchTable::ULEB128Value(InsnID) << MatchTable::Comment("Type")
20652067
<< *CImmLLT << MatchTable::Comment("Imm")
20662068
<< MatchTable::IntValue(8, Imm) << MatchTable::LineBreak;
2067-
} else
2069+
} else {
20682070
emitAddImm(Table, Rule, InsnID, Imm);
2071+
}
20692072
}
20702073

20712074
//===- SubRegIndexRenderer ------------------------------------------------===//
@@ -2156,8 +2159,9 @@ bool BuildMIAction::canMutate(RuleMatcher &Rule,
21562159
if (Insn != &OM.getInstructionMatcher() ||
21572160
OM.getOpIdx() != Renderer.index())
21582161
return false;
2159-
} else
2162+
} else {
21602163
return false;
2164+
}
21612165
}
21622166

21632167
return true;

0 commit comments

Comments
 (0)