[llvm] [NFC][CodeGen] Add braces for else per LLVM coding standard (PR #181750)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 16 13:39:24 PST 2026
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/181750
Add braces for else bodies if the if body has braces.
>From 41e8420f0b6ed4cbd726bc649d31997de8e46016 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Mon, 16 Feb 2026 13:37:46 -0800
Subject: [PATCH] [NFC][CodeGen] Add braces for else per LLVM coding standard
Add braces for else bodies if the if body has braces.
---
llvm/lib/CodeGen/MIRParser/MIParser.cpp | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 9329adcb995b8..c90ee21c6750b 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -959,8 +959,9 @@ bool MIParser::parseBasicBlock(MachineBasicBlock &MBB,
return true;
} else if (consumeIfPresent(MIToken::Newline)) {
continue;
- } else
+ } else {
break;
+ }
if (!Token.isNewlineOrEOF())
return error("expected line break at the end of a list");
lex();
@@ -1162,8 +1163,9 @@ bool MIParser::parse(MachineInstr *&MI) {
} else if (Token.is(MIToken::md_dilocation)) {
if (parseDILocation(Node))
return true;
- } else
+ } else {
return error("expected a metadata node after 'debug-location'");
+ }
if (!isa<DILocation>(Node))
return error("referenced metadata is not a DILocation");
DebugLocation = DebugLoc(Node);
@@ -1301,8 +1303,9 @@ bool MIParser::parseStandaloneMDNode(MDNode *&Node) {
} else if (Token.is(MIToken::md_dilocation)) {
if (parseDILocation(Node))
return true;
- } else
+ } else {
return error("expected a metadata node");
+ }
if (Token.isNot(MIToken::Eof))
return error("expected end of string after the metadata node");
return false;
@@ -2039,8 +2042,9 @@ bool MIParser::parseLowLevelType(StringRef::iterator Loc, LLT &Ty) {
return error("invalid address space number");
Ty = LLT::pointer(AS, DL.getPointerSizeInBits(AS));
- } else
+ } else {
return GetError();
+ }
lex();
if (Token.isNot(MIToken::greater))
@@ -2416,8 +2420,9 @@ bool MIParser::parseDILocation(MDNode *&Loc) {
} else if (Token.is(MIToken::md_dilocation)) {
if (parseDILocation(InlinedAt))
return true;
- } else
+ } else {
return error("expected metadata node");
+ }
if (!isa<DILocation>(InlinedAt))
return error("expected DILocation node");
continue;
@@ -2808,8 +2813,9 @@ bool MIParser::parseShuffleMaskOperand(MachineOperand &Dest) {
} else if (Token.is(MIToken::IntegerLiteral)) {
const APSInt &Int = Token.integerValue();
ShufMask.push_back(Int.getExtValue());
- } else
+ } else {
return error("expected integer constant");
+ }
lex();
} while (consumeIfPresent(MIToken::comma));
@@ -3047,8 +3053,9 @@ bool MIParser::parseMachineOperand(const unsigned OpCode, const unsigned OpIdx,
break;
} else if (Token.stringValue() == "CustomRegMask") {
return parseCustomRegisterMaskOperand(Dest);
- } else
+ } else {
return parseTypedImmediateOperand(Dest);
+ }
case MIToken::dot: {
const auto *TII = MF.getSubtarget().getInstrInfo();
if (const auto *Formatter = TII->getMIRFormatter()) {
@@ -3335,8 +3342,9 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
return error(Loc, Msg);
}))
return true;
- } else
+ } else {
return error("unable to parse target custom pseudo source value");
+ }
break;
}
default:
More information about the llvm-commits
mailing list