@@ -0,0 +1,190 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
30Wedge wrote:
Apologies for force push and squashing. I didn't know that the "update branch"
would merge `main` into this feature branch.
I lost the fixup commits while reconciling with the local branch.
https://github.com/llvm/llvm-project/pull/151590
@@ -0,0 +1,35 @@
+//===--- NumericLiteralCaseFixer.h -*- C++ -*-===//
+//
+// 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,0 +1,190 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
https://github.com/30Wedge updated
https://github.com/llvm/llvm-project/pull/151590
>From 152f3acfe9747e2c957e30a13130b7048ca989de Mon Sep 17 00:00:00 2001
From: Andy MacGregor
Date: Thu, 31 Jul 2025 16:24:06 -0400
Subject: [PATCH] [clang-format] Add an option to format integer literal case
--
https://github.com/30Wedge updated
https://github.com/llvm/llvm-project/pull/151590
>From e816bb79765a31ecaf8d5c4236a485cb7303dc62 Mon Sep 17 00:00:00 2001
From: Andy MacGregor
Date: Thu, 31 Jul 2025 16:24:06 -0400
Subject: [PATCH] [clang-format] Add an option to format integer literal case
--
@@ -0,0 +1,190 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
https://github.com/30Wedge edited
https://github.com/llvm/llvm-project/pull/151590
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
30Wedge wrote:
The CI failure seems unrelated to this change. I opened an issue for it here:
https://github.com/llvm/llvm-project/issues/154613
https://github.com/llvm/llvm-project/pull/151590
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
h
30Wedge wrote:
@owenca Rebased to address merge conflicts.
https://github.com/llvm/llvm-project/pull/151590
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -77,7 +77,7 @@ static std::optional formatIfNeeded(StringRef
IntegerLiteral,
transformComponent(IntegerLiteral.take_front(1 + N.BaseLetterPos),
Style.NumericLiteralCase.Prefix);
}
- // reformat this slice as HexDigit whether or not the
@@ -47,14 +47,21 @@ TEST_F(NumericLiteralInfoTest, IntegerLiteral) {
// Hexadecimal.
EXPECT_TRUE(verifyInfo(NumericLiteralInfo("0xF"), 1));
EXPECT_TRUE(verifyInfo(NumericLiteralInfo("0XfZ"), 1, npos, npos, 3));
+
+ // C++ suffixes.
+ EXPECT_TRUE(verifyInfo(NumericLitera
@@ -0,0 +1,368 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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,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
30Wedge wrote:
Cool, thanks for hearing me out! I am working on handling `NumericLiteralCase`
in the same pass as `IntegerLiteralSeparatorFixer`; that seemed natural since
they both only modify single `numeric_constant` tokens. I won't have time to
get to it until next week.
https://github.co
30Wedge wrote:
> IMO, the best place to handle this is in FormatTokenLexer::getNextToken().
I see you have much more experience in this part of the codebase, but I have
some hangups because I don't understand the implications of doing this move
myself. Here's what I'm thinking; are these vali
30Wedge wrote:
> I suggest NumericLiteralCase, Prefix, HexDigit, ExponentLetter, and Suffix
> for the option names and Leave, Lower, and Upper for the enum values.
I agree. So much more concise.
https://github.com/llvm/llvm-project/pull/151590
___
https://github.com/30Wedge updated
https://github.com/llvm/llvm-project/pull/151590
>From 2934f3ade1f585ba527507986d46577254e95e40 Mon Sep 17 00:00:00 2001
From: Andy MacGregor
Date: Thu, 31 Jul 2025 16:24:06 -0400
Subject: [PATCH 1/3] [clang-format] Add an option to format integer literal
cas
@@ -3558,6 +3558,76 @@ struct FormatStyle {
/// \version 9
std::vector NamespaceMacros;
+ /// Control over each component in a numeric literal.
+ enum NumericLiteralComponentStyle : int8_t {
+/// Leave this component of the literal as is.
+NLCS_Leave,
+/// Al
@@ -0,0 +1,347 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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,0 +1,347 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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,0 +1,347 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
@@ -3100,6 +3100,54 @@ struct FormatStyle {
/// \version 11
TrailingCommaStyle InsertTrailingCommas;
+ /// Character case format for different components of a numeric literal.
+ ///
+ /// For all options, ``0`` leave the case unchanged, ``-1``
+ /// uses lower case and
https://github.com/30Wedge edited
https://github.com/llvm/llvm-project/pull/151590
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,368 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
https://github.com/30Wedge edited
https://github.com/llvm/llvm-project/pull/151590
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -5076,6 +5075,78 @@ the configuration (without a prefix: ``Auto``).
For example: TESTSUITE
+.. _NumericLiteralCase:
+
+**NumericLiteralCase** (``NumericLiteralCaseStyle``)
:versionbadge:`clang-format 21` :ref:`ΒΆ `
+ Controls character case in numeric literals.
+
+ Pos
30Wedge wrote:
> Most likely the docs were not generated with the script, but manually
Yup! I manually edited ClangFormatStyleOptions.rst in the first commit. Much
easier to have a script do it for you :slightly_smiling_face:
In the fixup, this file is regenerated with: `python
clang/docs/t
@@ -0,0 +1,368 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
https://github.com/30Wedge edited
https://github.com/llvm/llvm-project/pull/151590
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -0,0 +1,368 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
@@ -3872,6 +3887,10 @@ reformat(const FormatStyle &Style, StringRef Code,
return IntegerLiteralSeparatorFixer().process(Env, Expanded);
});
+ Passes.emplace_back([&](const Environment &Env) {
30Wedge wrote:
I ended up putting it in `NumericLiteralCaseF
https://github.com/30Wedge updated
https://github.com/llvm/llvm-project/pull/151590
>From 2934f3ade1f585ba527507986d46577254e95e40 Mon Sep 17 00:00:00 2001
From: Andy MacGregor
Date: Thu, 31 Jul 2025 16:24:06 -0400
Subject: [PATCH 1/2] [clang-format] Add an option to format integer literal
cas
@@ -0,0 +1,368 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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,0 +1,368 @@
+//===--- NumericLiteralCaseFixer.cpp ---*- C++ -*-===//
+//
+// 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
35 matches
Mail list logo