[llvm] [Support] Add automatic index assignment in formatv (PR #107459)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 13:41:05 PDT 2024
================
@@ -167,16 +167,19 @@ template <typename Tuple> class formatv_object : public formatv_object_base {
// Formats textual output. `Fmt` is a string consisting of one or more
// replacement sequences with the following grammar:
//
-// rep_field ::= "{" index ["," layout] [":" format] "}"
+// rep_field ::= "{" [index] ["," layout] [":" format] "}"
// index ::= <non-negative integer>
// layout ::= [[[char]loc]width]
// format ::= <any string not containing "{" or "}">
// char ::= <any character except "{" or "}">
// loc ::= "-" | "=" | "+"
// width ::= <positive integer>
//
-// index - A non-negative integer specifying the index of the item in the
-// parameter pack to print. Any other value is invalid.
+// index - An optional non-negative integer specifying the index of the item
----------------
jurahul wrote:
Note that with the index being optional, it's possible in some cases to avoid the "," before the layout (if char/loc are used) and simplify the grammar here. But I did not do that to keep it simple.
https://github.com/llvm/llvm-project/pull/107459
More information about the llvm-commits
mailing list