Skip to content

Commit e098f3e

Browse files
committed
Use llvm::interleaveComma in printCopyPrivateVarList
1 parent 00a1487 commit e098f3e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,14 @@ static void printCopyPrivateVarList(OpAsmPrinter &p, Operation *op,
537537
OperandRange copyPrivateVars,
538538
TypeRange copyPrivateTypes,
539539
std::optional<ArrayAttr> copyPrivateFuncs) {
540-
assert(copyPrivateFuncs.has_value() || copyPrivateVars.empty());
541-
for (unsigned i = 0, e = copyPrivateVars.size(); i < e; ++i) {
542-
if (i != 0)
543-
p << ", ";
544-
p << copyPrivateVars[i] << " -> " << (*copyPrivateFuncs)[i] << " : "
545-
<< copyPrivateTypes[i];
546-
}
540+
if (!copyPrivateFuncs.has_value())
541+
return;
542+
llvm::interleaveComma(
543+
llvm::zip(copyPrivateVars, *copyPrivateFuncs, copyPrivateTypes), p,
544+
[&](const auto &args) {
545+
p << std::get<0>(args) << " -> " << std::get<1>(args) << " : "
546+
<< std::get<2>(args);
547+
});
547548
}
548549

549550
/// Verifies CopyPrivate Clause

0 commit comments

Comments
 (0)