Generalise addTupleOf

Allow it to iterate over an arbitrary container
type.
This commit is contained in:
Hamish Knight
2021-06-05 18:41:13 +01:00
parent 1b2a4ac365
commit 34402346be

View File

@@ -5807,8 +5807,8 @@ private:
/// Prints a tuple of elements, or a lone single element if only one is
/// present, using the provided printing function.
template <typename T, typename PrintFn>
void addTupleOf(ArrayRef<T> Elements, llvm::raw_ostream &OS,
template <typename Container, typename PrintFn>
void addTupleOf(const Container &Elements, llvm::raw_ostream &OS,
PrintFn PrintElt) {
if (Elements.size() == 1) {
PrintElt(Elements[0]);
@@ -5909,8 +5909,7 @@ private:
// cont.resume(returning: (res1, res2, ...))
OS << ContName << tok::period << "resume" << tok::l_paren;
OS << "returning" << tok::colon << " ";
addTupleOf(llvm::makeArrayRef(SuccessParamNames), OS,
[&](auto Ref) { OS << Ref; });
addTupleOf(SuccessParamNames, OS, [&](auto Ref) { OS << Ref; });
OS << tok::r_paren << "\n";
break;
}