[PATCH] D83888: [LLVM] Update formatv() documentation to clarify no escape for `}`

Rahul Joshi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 15:31:26 PDT 2020


This revision was automatically updated to reflect the committed changes.
jurahul marked an inline comment as done.
Closed by commit rGe6ea5b388b0d: [LLVM] Update formatv() documentation to clarify no escape for `}` (authored by jurahul).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83888/new/

https://reviews.llvm.org/D83888

Files:
  llvm/include/llvm/Support/FormatVariadic.h
  llvm/unittests/Support/FormatVariadicTest.cpp


Index: llvm/unittests/Support/FormatVariadicTest.cpp
===================================================================
--- llvm/unittests/Support/FormatVariadicTest.cpp
+++ llvm/unittests/Support/FormatVariadicTest.cpp
@@ -60,6 +60,18 @@
   ASSERT_EQ(1u, Replacements.size());
   EXPECT_EQ("{{{", Replacements[0].Spec);
   EXPECT_EQ(ReplacementType::Literal, Replacements[0].Type);
+
+  // } does not require doubling up.
+  Replacements = formatv_object_base::parseFormatString("}");
+  ASSERT_EQ(1u, Replacements.size());
+  EXPECT_EQ("}", Replacements[0].Spec);
+  EXPECT_EQ(ReplacementType::Literal, Replacements[0].Type);
+
+  // } does not require doubling up.
+  Replacements = formatv_object_base::parseFormatString("}}}");
+  ASSERT_EQ(1u, Replacements.size());
+  EXPECT_EQ("}}}", Replacements[0].Spec);
+  EXPECT_EQ(ReplacementType::Literal, Replacements[0].Type);
 }
 
 TEST(FormatVariadicTest, ValidReplacementSequence) {
Index: llvm/include/llvm/Support/FormatVariadic.h
===================================================================
--- llvm/include/llvm/Support/FormatVariadic.h
+++ llvm/include/llvm/Support/FormatVariadic.h
@@ -205,10 +205,10 @@
 //
 // The characters '{' and '}' are reserved and cannot appear anywhere within a
 // replacement sequence.  Outside of a replacement sequence, in order to print
-// a literal '{' or '}' it must be doubled -- "{{" to print a literal '{' and
-// "}}" to print a literal '}'.
+// a literal '{' it must be doubled as "{{".
 //
 // ===Parameter Indexing===
+//
 // `index` specifies the index of the parameter in the parameter pack to format
 // into the output.  Note that it is possible to refer to the same parameter
 // index multiple times in a given format string.  This makes it possible to


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83888.279958.patch
Type: text/x-patch
Size: 1767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200722/41282d80/attachment.bin>


More information about the llvm-commits mailing list