[llvm] [NFC][TableGen] Adopt `ArrayRef::consume_front()` in `PrintMessage` (PR #146775)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 13:41:31 PDT 2025
https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/146775
Adopt `ArrayRef::consume_front()` in `PrintMessage`, and convert the loop in that function to a range for loop.
>From 027da39a85278851e3c2a77325d70b4df347123a Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 2 Jul 2025 13:39:11 -0700
Subject: [PATCH] [NFC][TableGen] Adopt `ArrayRef::consume_front()` in
`PrintMessage`
Adopt `ArrayRef::consume_front()` in `PrintMessage`, and convert the
loop in that function to a range for loop.
---
llvm/lib/TableGen/Error.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/TableGen/Error.cpp b/llvm/lib/TableGen/Error.cpp
index 91423664a84cc..de0c4c971efeb 100644
--- a/llvm/lib/TableGen/Error.cpp
+++ b/llvm/lib/TableGen/Error.cpp
@@ -24,7 +24,7 @@ namespace llvm {
SourceMgr SrcMgr;
unsigned ErrorsPrinted = 0;
-static void PrintMessage(ArrayRef<SMLoc> Loc, SourceMgr::DiagKind Kind,
+static void PrintMessage(ArrayRef<SMLoc> Locs, SourceMgr::DiagKind Kind,
const Twine &Msg) {
// Count the total number of errors printed.
// This is used to exit with an error code if there were any errors.
@@ -32,11 +32,11 @@ static void PrintMessage(ArrayRef<SMLoc> Loc, SourceMgr::DiagKind Kind,
++ErrorsPrinted;
SMLoc NullLoc;
- if (Loc.empty())
- Loc = NullLoc;
- SrcMgr.PrintMessage(Loc.front(), Kind, Msg);
- for (unsigned i = 1; i < Loc.size(); ++i)
- SrcMgr.PrintMessage(Loc[i], SourceMgr::DK_Note,
+ if (Locs.empty())
+ Locs = NullLoc;
+ SrcMgr.PrintMessage(Locs.consume_front(), Kind, Msg);
+ for (SMLoc Loc : Locs)
+ SrcMgr.PrintMessage(Loc, SourceMgr::DK_Note,
"instantiated from multiclass");
}
More information about the llvm-commits
mailing list