Skip to content

[NFC][TableGen] Add {} for else when if body has {} #139420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/TableGen/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,9 @@ const Init *ListInit::convertInitializerTo(const RecTy *Ty) const {
Elements.push_back(CI);
if (CI != I)
Changed = true;
} else
} else {
return nullptr;
}

if (!Changed)
return this;
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/TableGen/TGParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1928,9 +1928,10 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
const auto *Arg2 = cast<TypedInit>(Args[2]);
assert(isa<IntRecTy>(Arg2->getType()));
RHS = Arg2;
} else
} else {
// (start, end, 1)
RHS = IntInit::get(Records, 1);
}
}
return TernOpInit::get(TernOpInit::RANGE, LHS, MHS, RHS,
IntRecTy::get(Records)->getListTy())
Expand All @@ -1946,7 +1947,7 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
const RecTy *Type = nullptr;

tgtok::TokKind LexCode = Lex.getCode();
Lex.Lex(); // eat the operation
Lex.Lex(); // Eat the operation.
switch (LexCode) {
default: llvm_unreachable("Unhandled code!");
case tgtok::XDag:
Expand Down
15 changes: 10 additions & 5 deletions llvm/utils/TableGen/AsmMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1347,8 +1347,9 @@ void AsmMatcherInfo::buildRegisterClasses(
CI->ClassName = RC.getName();
CI->Name = "MCK_" + RC.getName();
CI->ValueName = RC.getName();
} else
} else {
CI->ValueName = CI->ValueName + "," + RC.getName();
}

const Init *DiagnosticType = Def->getValueInit("DiagnosticType");
if (const StringInit *SI = dyn_cast<StringInit>(DiagnosticType))
Expand Down Expand Up @@ -1379,8 +1380,9 @@ void AsmMatcherInfo::buildRegisterClasses(
CI->ClassName = std::string(Rec->getName());
CI->Name = "MCK_" + Rec->getName().str();
CI->ValueName = std::string(Rec->getName());
} else
} else {
CI->ValueName = CI->ValueName + "," + Rec->getName().str();
}
}
}

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

OS << "namespace {\n";

Expand Down Expand Up @@ -2503,8 +2507,9 @@ static void emitValidateOperandClass(const CodeGenTarget &Target,
OS << " return " << Info.Target.getName() << "AsmParser::Match_"
<< CI.DiagnosticType << ";\n";
OS << " break;\n";
} else
} else {
OS << " break;\n";
}
OS << " }\n";
}
OS << " } // end switch (Kind)\n\n";
Expand Down
6 changes: 4 additions & 2 deletions llvm/utils/TableGen/AsmWriterEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,8 +660,9 @@ void AsmWriterEmitter::EmitGetRegisterName(raw_ostream &O) {
if (hasAltNames) {
for (const Record *R : AltNameIndices)
emitRegisterNameString(O, R->getName(), Registers);
} else
} else {
emitRegisterNameString(O, "", Registers);
}

if (hasAltNames) {
O << " switch(AltIdx) {\n"
Expand Down Expand Up @@ -969,8 +970,9 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
if (!Rec->isValueUnset("MCOperandPredicate")) {
MCOpPredicates.push_back(Rec);
Entry = MCOpPredicates.size();
} else
} else {
break; // No conditions on this operand at all
}
}
IAP.addCond(
std::string(formatv("AliasPatternCond::K_Custom, {}", Entry)));
Expand Down
10 changes: 5 additions & 5 deletions llvm/utils/TableGen/Basic/CodeGenIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,16 @@ void CodeGenIntrinsic::setProperty(const Record *R) {
int64_t Lower = R->getValueAsInt("Lower");
int64_t Upper = R->getValueAsInt("Upper");
addArgAttribute(ArgNo, Range, Lower, Upper);
} else
} else {
llvm_unreachable("Unknown property!");
}
}

bool CodeGenIntrinsic::isParamAPointer(unsigned ParamIdx) const {
if (ParamIdx >= IS.ParamTys.size())
return false;
return (IS.ParamTys[ParamIdx]->isSubClassOf("LLVMQualPointerType") ||
IS.ParamTys[ParamIdx]->isSubClassOf("LLVMAnyPointerType"));
return IS.ParamTys[ParamIdx]->isSubClassOf("LLVMQualPointerType") ||
IS.ParamTys[ParamIdx]->isSubClassOf("LLVMAnyPointerType");
}

bool CodeGenIntrinsic::isParamImmArg(unsigned ParamIdx) const {
Expand All @@ -461,8 +462,7 @@ bool CodeGenIntrinsic::isParamImmArg(unsigned ParamIdx) const {
if (ParamIdx >= ArgumentAttributes.size())
return false;
ArgAttribute Val{ImmArg, 0, 0};
return std::binary_search(ArgumentAttributes[ParamIdx].begin(),
ArgumentAttributes[ParamIdx].end(), Val);
return llvm::binary_search(ArgumentAttributes[ParamIdx], Val);
}

void CodeGenIntrinsic::addArgAttribute(unsigned Idx, ArgAttrKind AK, uint64_t V,
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/Basic/VTEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ static void vTtoGetLlvmTyString(raw_ostream &OS, const Record *VT) {
OS << "Type::getInt" << OutputVTSize << "Ty(Context)";
else
OS << "Type::getIntNTy(Context, " << OutputVTSize << ")";
} else
} else {
llvm_unreachable("Unhandled case");
}

if (IsVector)
OS << ", " << VT->getValueAsInt("nElem") << ")";
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2405,8 +2405,9 @@ TreePatternNode::getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const {
if (!DI)
return nullptr;
Rec = DI->getDef();
} else
} else {
Rec = getOperator();
}

if (!Rec->isSubClassOf("ComplexPattern"))
return nullptr;
Expand Down
6 changes: 4 additions & 2 deletions llvm/utils/TableGen/Common/CodeGenInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
PrintFatalError(R->getLoc(),
R->getName() +
": invalid def name for output list: use 'outs'");
} else
} else {
PrintFatalError(R->getLoc(),
R->getName() + ": invalid output list: use 'outs'");
}

NumDefs = OutDI->getNumArgs();

Expand All @@ -46,9 +47,10 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
PrintFatalError(R->getLoc(),
R->getName() +
": invalid def name for input list: use 'ins'");
} else
} else {
PrintFatalError(R->getLoc(),
R->getName() + ": invalid input list: use 'ins'");
}

unsigned MIOperandNo = 0;
std::set<std::string> OperandNames;
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/Common/CodeGenSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2016,8 +2016,9 @@ void CodeGenSchedModels::collectRWResources(unsigned RWIdx, bool IsRead,
if (Alias->getValueInit("SchedModel")->isComplete()) {
AliasProcIndices.push_back(
getProcModel(Alias->getValueAsDef("SchedModel")).Index);
} else
} else {
AliasProcIndices = ProcIndices;
}
const CodeGenSchedRW &AliasRW = getSchedRW(Alias->getValueAsDef("AliasRW"));
assert(AliasRW.IsRead == IsRead && "cannot alias reads to writes");

Expand Down
12 changes: 8 additions & 4 deletions llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2015,9 +2015,10 @@ void TempRegRenderer::emitRenderOpcodes(MatchTable &Table,
if (SubRegIdx) {
assert(!IsDef);
Table << MatchTable::Opcode("GIR_AddTempSubRegister");
} else
} else {
Table << MatchTable::Opcode(NeedsFlags ? "GIR_AddTempRegister"
: "GIR_AddSimpleTempRegister");
}

Table << MatchTable::Comment("InsnID") << MatchTable::ULEB128Value(InsnID)
<< MatchTable::Comment("TempRegID")
Expand All @@ -2035,8 +2036,9 @@ void TempRegRenderer::emitRenderOpcodes(MatchTable &Table,
if (IsDead)
RegFlags += "|RegState::Dead";
Table << MatchTable::NamedValue(2, RegFlags);
} else
} else {
Table << MatchTable::IntValue(2, 0);
}

if (SubRegIdx)
Table << MatchTable::NamedValue(2, SubRegIdx->getQualifiedName());
Expand Down Expand Up @@ -2064,8 +2066,9 @@ void ImmRenderer::emitRenderOpcodes(MatchTable &Table,
<< MatchTable::ULEB128Value(InsnID) << MatchTable::Comment("Type")
<< *CImmLLT << MatchTable::Comment("Imm")
<< MatchTable::IntValue(8, Imm) << MatchTable::LineBreak;
} else
} else {
emitAddImm(Table, Rule, InsnID, Imm);
}
}

//===- SubRegIndexRenderer ------------------------------------------------===//
Expand Down Expand Up @@ -2156,8 +2159,9 @@ bool BuildMIAction::canMutate(RuleMatcher &Rule,
if (Insn != &OM.getInstructionMatcher() ||
OM.getOpIdx() != Renderer.index())
return false;
} else
} else {
return false;
}
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/Common/GlobalISel/PatternParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ PatternParser::parseInstructionPattern(const Init &Arg, StringRef Name) {
getDagWithOperatorOfSubClass(Arg, BuiltinPattern::ClassName)) {
Pat = std::make_unique<BuiltinPattern>(*BP->getOperatorAsDef(DiagLoc),
insertStrRef(Name));
} else
} else {
return nullptr;
}

for (unsigned K = 0; K < DagPat->getNumArgs(); ++K) {
const Init *Arg = DagPat->getArg(K);
Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/Common/GlobalISel/Patterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,9 @@ bool PatFragPattern::mapInputCodeExpansions(const CodeExpansions &ParentCEs,
if (It == ParentCEs.end()) {
if (!PF.handleUnboundInParam(ParamName, ArgName, DiagLoc))
return false;
} else
} else {
PatFragCEs.declare(ParamName, It->second);
}
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/TableGen/CompressInstEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ void CompressInstEmitter::addDagOperandMapping(const Record *Rec,
<< (IsSourceInst ? "input " : "output ")
<< "Dag. No validation time check possible for values of "
"fixed immediate.\n");
} else
} else {
llvm_unreachable("Unhandled CompressPat argument type!");
}
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
if (!OmitComments) {
OS << "/*" << format_decimal(CurrentIdx, IndexWidth) << "*/";
OS.indent(Indent) << "/*Scope*/ ";
} else
} else {
OS.indent(Indent);
}
}

unsigned ChildSize = SM->getChild(i)->getSize();
Expand Down Expand Up @@ -558,8 +559,9 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
if (PredNo < 8) {
OperandBytes = -1;
OS << "OPC_CheckPredicate" << PredNo << ", ";
} else
} else {
OS << "OPC_CheckPredicate, ";
}
}

if (PredNo >= 8 || Pred.usesOperands())
Expand Down Expand Up @@ -916,9 +918,10 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
OS << "OPC_EmitCopyToReg" << Slot << ", "
<< getQualifiedName(Reg->TheDef) << ",\n";
--Bytes;
} else
} else {
OS << "OPC_EmitCopyToReg, " << Slot << ", "
<< getQualifiedName(Reg->TheDef) << ",\n";
}
}

return Bytes;
Expand Down Expand Up @@ -1042,8 +1045,9 @@ unsigned MatcherTableEmitter::EmitMatcher(const Matcher *N,
OS.indent(FullIndexWidth + Indent)
<< "// Dst: " << SNT->getPattern().getDstPattern() << '\n';
}
} else
} else {
OS << '\n';
}

return 4 + !CompressVTs + !CompressNodeInfo + NumTypeBytes +
NumOperandBytes + NumCoveredBytes;
Expand Down
7 changes: 4 additions & 3 deletions llvm/utils/TableGen/FastISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ struct OperandsSignature {
RC = &Target.getRegisterClass(OpLeafRec);
else if (OpLeafRec->isSubClassOf("Register"))
RC = Target.getRegBank().getRegClassForRegister(OpLeafRec);
else if (OpLeafRec->isSubClassOf("ValueType")) {
else if (OpLeafRec->isSubClassOf("ValueType"))
RC = OrigDstRC;
} else
else
return false;

// For now, this needs to be a register class of some sort.
Expand All @@ -294,8 +294,9 @@ struct OperandsSignature {
if (DstRC) {
if (DstRC != RC && !DstRC->hasSubClass(RC))
return false;
} else
} else {
DstRC = RC;
}
Operands.push_back(OpKind::getReg());
}
return true;
Expand Down
6 changes: 4 additions & 2 deletions llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,8 +1277,9 @@ bool CombineRuleBuilder::checkSemantics() {
"patterns");
return false;
}
} else
} else {
IsUsingCXXPatterns = isa<CXXPattern>(Pat);
}

assert(Pat);
const auto *IP = dyn_cast<InstructionPattern>(Pat);
Expand Down Expand Up @@ -1610,8 +1611,9 @@ bool CombineRuleBuilder::emitMatchPattern(CodeExpansions &CE,
return false;
} else if (isa<BuiltinPattern>(&IP)) {
llvm_unreachable("No match builtins known!");
} else
} else {
llvm_unreachable("Unknown kind of InstructionPattern!");
}

// Emit remaining patterns
const bool IsUsingCustomCXXAction = hasOnlyCXXApplyPatterns();
Expand Down
6 changes: 4 additions & 2 deletions llvm/utils/TableGen/GlobalISelEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,10 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
if (isa<IntInit>(SrcInit)) {
InsnMatcher.addPredicate<InstructionOpcodeMatcher>(
&Target.getInstruction(RK.getDef("G_CONSTANT")));
} else
} else {
return failedImport(
"Unable to deduce gMIR opcode to handle Src (which is a leaf)");
}
} else {
SrcGIEquivOrNull = findNodeEquiv(Src.getOperator());
if (!SrcGIEquivOrNull)
Expand Down Expand Up @@ -850,9 +851,10 @@ Expected<InstructionMatcher &> GlobalISelEmitter::createAndImportSelDAGMatcher(
OperandMatcher &OM =
InsnMatcher.addOperand(OpIdx++, Src.getName(), TempOpIdx);
OM.addPredicate<LiteralIntOperandMatcher>(SrcIntInit->getValue());
} else
} else {
return failedImport(
"Unable to deduce gMIR opcode to handle Src (which is a leaf)");
}
} else {
assert(SrcGIOrNull &&
"Expected to have already found an equivalent Instruction");
Expand Down
Loading