[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 13 23:24:46 PDT 2025
================
@@ -0,0 +1,354 @@
+//===- unittest/Format/NumericLiteralCaseTest.cpp --------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "FormatTestBase.h"
+
+#define DEBUG_TYPE "numeric-literal-case-test"
+
+namespace clang {
+namespace format {
+namespace test {
+namespace {
+
+class NumericLiteralCaseTest : public FormatTestBase {};
+
+TEST_F(NumericLiteralCaseTest, Prefix) {
+ FormatStyle Style = getLLVMStyle();
+ EXPECT_EQ(Style.Language, FormatStyle::LK_Cpp);
+ EXPECT_EQ(Style.NumericLiteralCase.Prefix, FormatStyle::NLCS_Leave);
+ EXPECT_EQ(Style.NumericLiteralCase.HexDigit, FormatStyle::NLCS_Leave);
+ EXPECT_EQ(Style.NumericLiteralCase.ExponentLetter, FormatStyle::NLCS_Leave);
+ EXPECT_EQ(Style.NumericLiteralCase.Suffix, FormatStyle::NLCS_Leave);
+
+ const StringRef Bin0{"b = 0b0'10'010uL;"};
----------------
owenca wrote:
```suggestion
constexpr StringRef Bin0("b = 0b0'10'010uL;");
```
Here and elsewhere.
https://github.com/llvm/llvm-project/pull/151590
More information about the cfe-commits
mailing list