[llvm] [Support] Add automatic index assignment in formatv (PR #107459)
Rahul Joshi via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 11 15:40:25 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
+// in the parameter pack to print. Any other value is invalid. If its
+// not specified, it will be automatically assigned a value based on
+// the order of rep_field seen in the format string. Note that mixing
+// automatic and explicit index in the same call is undefined.
----------------
jurahul wrote:
Done. I added: "Note that mixing automatic and explicit index in the same call is an error and will fail validation in assert-enabled builds".
https://github.com/llvm/llvm-project/pull/107459
More information about the llvm-commits
mailing list