[llvm] f43ad50 - [SandboxIR][NFC] Refactor Function::dumpNameAndArgs()
Vasileios Porpodas via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 20:46:43 PDT 2024
Author: Vasileios Porpodas
Date: 2024-07-10T20:43:12-07:00
New Revision: f43ad50b7e353a6a67647bf3bb44c2d5cafe62c4
URL: https://github.com/llvm/llvm-project/commit/f43ad50b7e353a6a67647bf3bb44c2d5cafe62c4
DIFF: https://github.com/llvm/llvm-project/commit/f43ad50b7e353a6a67647bf3bb44c2d5cafe62c4.diff
LOG: [SandboxIR][NFC] Refactor Function::dumpNameAndArgs()
Added:
Modified:
llvm/lib/SandboxIR/SandboxIR.cpp
Removed:
################################################################################
diff --git a/llvm/lib/SandboxIR/SandboxIR.cpp b/llvm/lib/SandboxIR/SandboxIR.cpp
index 160d807738a3c..7536afc9dd157 100644
--- a/llvm/lib/SandboxIR/SandboxIR.cpp
+++ b/llvm/lib/SandboxIR/SandboxIR.cpp
@@ -270,16 +270,16 @@ void Constant::dump() const {
void Function::dumpNameAndArgs(raw_ostream &OS) const {
auto *F = cast<llvm::Function>(Val);
OS << *F->getReturnType() << " @" << F->getName() << "(";
- auto NumArgs = F->arg_size();
- for (auto [Idx, Arg] : enumerate(F->args())) {
- auto *SBArg = cast_or_null<Argument>(Ctx.getValue(&Arg));
- if (SBArg == nullptr)
- OS << "NULL";
- else
- SBArg->printAsOperand(OS);
- if (Idx + 1 < NumArgs)
- OS << ", ";
- }
+ interleave(
+ F->args(),
+ [this, &OS](const llvm::Argument &LLVMArg) {
+ auto *SBArg = cast_or_null<Argument>(Ctx.getValue(&LLVMArg));
+ if (SBArg == nullptr)
+ OS << "NULL";
+ else
+ SBArg->printAsOperand(OS);
+ },
+ [this, &OS] { OS << ", "; });
OS << ")";
}
void Function::dump(raw_ostream &OS) const {
More information about the llvm-commits
mailing list