[PATCH] D141392: Avoid u8"" literals in tests, their type changes in C++20

Ilya Biryukov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 09:28:45 PST 2023


ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM, but please address the NITs before submitting.



================
Comment at: llvm/include/llvm/Support/raw_ostream.h:231
+  // behavior, especially as `u8""` literals are of type `char8_t*` instead of
+  // type `char_t*` from C++20 one. Thus we disallow using them with
+  // raw_ostreams.
----------------
NIT: is there a typo? should this be 'from C++20 on' or 'from C++20 onward'?


================
Comment at: llvm/include/llvm/Support/raw_ostream.h:236
+  // e.g.  replace `u8"\u00a0"` by `"\xc2\xa0"`
+  // or use reinterprete_cast:
+  // e.g. replace `u8"\u00a0"` by `reinterpret_cast<const char *>(u8"\u00a0")`
----------------
NIT: there's a typo, should be `reinterpret_cast`



================
Comment at: llvm/unittests/Support/formatted_raw_ostream_test.cpp:102
   // wide.
-  C << u8"\u2468";
+  C << "\xe2\x91\xa8";
   EXPECT_EQ(0U, C.getLine());
----------------
NIT: `reinterpret_cast` seems better there as the character code is directly written above


================
Comment at: llvm/unittests/Support/formatted_raw_ostream_test.cpp:109
   // column wide.
-  C << u8"\U00010000";
+  C << "\xf0\x90\x80\x80";
   EXPECT_EQ(0U, C.getLine());
----------------
NIT: `reinterpret_cast` also seems better here


================
Comment at: llvm/unittests/Support/formatted_raw_ostream_test.cpp:115
   // U+55B5, CJK character, encodes as three bytes, takes up two columns.
-  C << u8"\u55b5";
+  C << "\xe5\x96\xb5";
   EXPECT_EQ(0U, C.getLine());
----------------
NIT: `reinterpret_cast` also seems better here


================
Comment at: llvm/unittests/Support/formatted_raw_ostream_test.cpp:122
   // column or line number.
-  C << u8"\u200b";
+  C << "\xe2\x80\x8b";
   EXPECT_EQ(0U, C.getLine());
----------------
NIT: `reinterpret_cast` also seems better here


================
Comment at: llvm/unittests/Support/formatted_raw_ostream_test.cpp:140
   // with 6 bytes written into total, 2 of which are in the buffer.
-  C << u8"123\u2468";
+  C << "123\xe2\x91\xa8";
   EXPECT_EQ(0U, C.getLine());
----------------
NIT: `reinterpret_cast` also seems better here


================
Comment at: llvm/unittests/Support/formatted_raw_ostream_test.cpp:148
   // Same as above, but with a CJK character which displays as two columns.
-  C << u8"123\u55b5";
+  C << "123\xe5\x96\xb5";
   EXPECT_EQ(0U, C.getLine());
----------------
NIT: `reinterpret_cast` also seems better here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141392



More information about the llvm-commits mailing list