[clang] [llvm] [clang] Use separator for large numeric values in overflow diagnostic (PR #80939)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 04:46:11 PST 2024


================
@@ -1379,6 +1379,23 @@ TEST(APIntTest, toString) {
   EXPECT_EQ(std::string(S), "0");
   S.clear();
 
+  // with separators
+  APInt(64, 140).toString(S, 2, false, true, false, true);
+  EXPECT_EQ(std::string(S), "0b1000'1100");
+  S.clear();
+  APInt(64, 1024).toString(S, 8, false, true, false, true);
+  EXPECT_EQ(std::string(S), "02'000");
+  S.clear();
+  APInt(64, 1000000).toString(S, 10, false, true, false, true);
+  EXPECT_EQ(std::string(S), "1'000'000");
+  S.clear();
+  APInt(64, 1000000).toString(S, 16, false, true, true, true);
+  EXPECT_EQ(std::string(S), "0xF'4240");
+  S.clear();
+  APInt(64, 1'000'000'000).toString(S, 36, false, false, false, true);
+  EXPECT_EQ(std::string(S), "gj'dgxs");
----------------
AaronBallman wrote:

lol, I love it (it took me a minute when I saw the expected string).

https://github.com/llvm/llvm-project/pull/80939


More information about the cfe-commits mailing list