[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-04 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > I suggest `NumericLiteralCase`, `Prefix`, `HexDigit`, `ExponentLetter`, and > `Suffix` for the option names and `Leave`, `Lower`, and `Upper` for the enum > values. For example: > > ``` > NumericLiteralCase: > Prefix: Lower # 0x, 0b, etc. > HexDigit:

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-04 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-04 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-04 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-04 Thread Björn Schäpers via cfe-commits
@@ -5438,6 +5508,7 @@ struct FormatStyle { MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep && NamespaceIndentation == R.NamespaceIndentation && NamespaceMacros == R.NamespaceMacros && + NumericLiteralCase == R.NumericLiteralCase && --

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -5438,6 +5508,7 @@ struct FormatStyle { MaxEmptyLinesToKeep == R.MaxEmptyLinesToKeep && NamespaceIndentation == R.NamespaceIndentation && NamespaceMacros == R.NamespaceMacros && + NumericLiteralCase == R.NumericLiteralCase && --

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks 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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks commented: I'm not finished reviewing the changes, but must leave now. ;) https://github.com/llvm/llvm-project/pull/151590 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-03 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-08-02 Thread Björn Schäpers via 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

[clang] [clang-format][NFC] Maximize usage of isOneOf() in TokenAnnotator (PR #151658)

2025-08-02 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/151658 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > Looking at the > [CI](https://github.com/llvm/llvm-project/actions/runs/16659524063/job/47155439985?pr=151590#step:3:28856) > it seems the `clang/test/Format/docs_updated.test` test failed. This may be > due to incorrect formatting of your style option in > `ClangF

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via 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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via 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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via 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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via 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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -1618,6 +1630,9 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.InsertBraces = false; LLVMStyle.InsertNewlineAtEOF = false; LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None; + LLVMStyle.NumericLiteralCase = {/*PrefixCase=*/0, /*HexDi

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -1093,6 +1104,7 @@ template <> struct MappingTraits { IO.mapOptional("InsertBraces", Style.InsertBraces); IO.mapOptional("InsertNewlineAtEOF", Style.InsertNewlineAtEOF); IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas); +IO.mapOptional("Nume

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via 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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks commented: A bit to do, but I like the proposed feature. 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-

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -5424,6 +5472,7 @@ struct FormatStyle { IndentWrappedFunctionNames == R.IndentWrappedFunctionNames && InsertBraces == R.InsertBraces && InsertNewlineAtEOF == R.InsertNewlineAtEOF && + NumericLiteralCase == R.NumericLiteralCase && --

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -382,6 +383,16 @@ struct ScalarEnumerationTraits { } }; +template <> struct MappingTraits { HazardyKnusperkeks wrote: Sort https://github.com/llvm/llvm-project/pull/151590 ___ cfe-commits mailing list cfe-com

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via 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

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -3872,6 +3887,10 @@ reformat(const FormatStyle &Style, StringRef Code, return IntegerLiteralSeparatorFixer().process(Env, Expanded); }); + Passes.emplace_back([&](const Environment &Env) { HazardyKnusperkeks wrote: Add a check, if any option is not

[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

2025-07-31 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks 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

[clang] [clang-format] allow short function body on a single line (PR #151428)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -532,6 +538,20 @@ class LineJoiner { } return MergedLines; } + +// Previously, UnwrappedLineParser would move the left brace to a new line +// when AllowShortFunctionBodiesOnASingleLine is enabled. However, if the +// function body cannot fit on a

[clang] [clang-format] allow short function body on a single line (PR #151428)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -878,6 +878,12 @@ struct FormatStyle { /// \version 3.5 ShortFunctionStyle AllowShortFunctionsOnASingleLine; + /// Dependent on the value, function body like ``{ return 0; }`` can be + /// put on a single line. Only when AllowShortFunctionsOnASingleLine = None + ///

[clang] [clang-format] allow short function body on a single line (PR #151428)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -1921,6 +1921,10 @@ void UnwrappedLineParser::parseStructuralElement( } } else if (Style.BraceWrapping.AfterFunction) { addUnwrappedLine(); +} else if (Style.AllowShortFunctionBodiesOnASingleLine) { + // Wrap the left brace here;

[clang] [clang-format] allow short function body on a single line (PR #151428)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -532,6 +538,20 @@ class LineJoiner { } return MergedLines; } + +// Previously, UnwrappedLineParser would move the left brace to a new line HazardyKnusperkeks wrote: Something like `Previously` is suitable for a commit message, not for th

[clang] [clang-format] allow short function body on a single line (PR #151428)

2025-07-31 Thread Björn Schäpers via cfe-commits
@@ -878,6 +878,12 @@ struct FormatStyle { /// \version 3.5 ShortFunctionStyle AllowShortFunctionsOnASingleLine; + /// Dependent on the value, function body like ``{ return 0; }`` can be + /// put on a single line. Only when AllowShortFunctionsOnASingleLine = None + ///

[clang] [clang-format] allow short function body on a single line (PR #151428)

2025-07-31 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/151428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] allow short function body on a single line (PR #151428)

2025-07-31 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks commented: You are missing unit tests. `clang/unittests/Format/FromatTest.cpp`. https://github.com/llvm/llvm-project/pull/151428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] [clang-format] Fix a bug in `DerivePointerAlignment: true` (PR #150744)

2025-07-27 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/150744 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix a bug in `DerivePointerAlignment: true` (PR #150744)

2025-07-27 Thread Björn Schäpers via cfe-commits
@@ -2639,32 +2639,42 @@ class Formatter : public TokenAnalyzer { int countVariableAlignments(const SmallVectorImpl &Lines) { int AlignmentDiff = 0; + for (const AnnotatedLine *Line : Lines) { AlignmentDiff += countVariableAlignments(Line->Children); - fo

[clang] [clang-format] Fix a bug in `DerivePointerAlignment: true` (PR #150744)

2025-07-27 Thread Björn Schäpers via cfe-commits
@@ -2639,32 +2639,42 @@ class Formatter : public TokenAnalyzer { int countVariableAlignments(const SmallVectorImpl &Lines) { int AlignmentDiff = 0; + for (const AnnotatedLine *Line : Lines) { AlignmentDiff += countVariableAlignments(Line->Children); - fo

[clang] [clang-format] Fix a bug in `DerivePointerAlignment: true` (PR #150744)

2025-07-27 Thread Björn Schäpers via cfe-commits
@@ -2639,32 +2639,42 @@ class Formatter : public TokenAnalyzer { int countVariableAlignments(const SmallVectorImpl &Lines) { int AlignmentDiff = 0; + for (const AnnotatedLine *Line : Lines) { AlignmentDiff += countVariableAlignments(Line->Children); - fo

[clang] [clang-format] Fix a bug in `DerivePointerAlignment: true` (PR #150744)

2025-07-26 Thread Björn Schäpers via cfe-commits
@@ -2641,28 +2641,19 @@ class Formatter : public TokenAnalyzer { int AlignmentDiff = 0; for (const AnnotatedLine *Line : Lines) { AlignmentDiff += countVariableAlignments(Line->Children); - for (FormatToken *Tok = Line->First; Tok && Tok->Next; Tok = Tok->Nex

[clang] [clang-format] Fix a bug in `DerivePointerAlignment: true` (PR #150744)

2025-07-26 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/150744 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] fix typo in docs (PR #150658)

2025-07-25 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/150658 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] fix typo in docs (PR #150658)

2025-07-25 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/150658 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix a bug in `DerivePointerAlignment: true` (PR #150387)

2025-07-24 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/150387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add AfterNot to SpaceBeforeParensOptions (PR #150367)

2025-07-24 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/150367 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Change SpaceAfterLogicalNot to enumeration type (PR #150166)

2025-07-23 Thread Björn Schäpers via cfe-commits
@@ -17762,14 +17762,19 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { } TEST_F(FormatTest, SpaceAfterLogicalNot) { - FormatStyle Spaces = getLLVMStyle(); - Spaces.SpaceAfterLogicalNot = true; + auto Spaces = getLLVMStyle(); + EXPECT_EQ(Spaces.SpaceAfterLogicalNot,

[clang] [clang-format] Change SpaceAfterLogicalNot to enumeration type (PR #150166)

2025-07-23 Thread Björn Schäpers via cfe-commits
@@ -4483,13 +4483,32 @@ struct FormatStyle { /// \version 3.5 bool SpaceAfterCStyleCast; - /// If ``true``, a space is inserted after the logical not operator (``!``). - /// \code - ///true: false: - ///! someExpression();

[clang] [clang-format] Change SpaceAfterLogicalNot to enumeration type (PR #150166)

2025-07-23 Thread Björn Schäpers via cfe-commits
@@ -4483,13 +4483,32 @@ struct FormatStyle { /// \version 3.5 bool SpaceAfterCStyleCast; - /// If ``true``, a space is inserted after the logical not operator (``!``). - /// \code - ///true: false: - ///! someExpression();

[clang] [clang-format][NFC] Clean up around StringRef initializations (PR #149765)

2025-07-21 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/149765 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix a bug in `BreakBeforeBinaryOperators: All` (PR #149695)

2025-07-20 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/149695 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle templates in qualified typenames (PR #143194)

2025-07-17 Thread Björn Schäpers via cfe-commits
@@ -3630,6 +3630,36 @@ static unsigned maxNestingDepth(const AnnotatedLine &Line) { return Result; } +// Returns the token after the first qualifier of the name, or nullptr if there +// is no qualifier. +static FormatToken* skipNameQualifier(const FormatToken *Tok) { --

[clang] [clang-format] Fix a regression of annotating PointerOrReference (PR #149039)

2025-07-17 Thread Björn Schäpers via cfe-commits
@@ -3122,6 +3122,9 @@ class AnnotatingParser { } } +if (PrevToken->isTypeName(LangOpts)) HazardyKnusperkeks wrote: Thanks. https://github.com/llvm/llvm-project/pull/149039 ___ cfe-commits mailing list

[clang] [clang-format] Fix a regression of annotating PointerOrReference (PR #149039)

2025-07-17 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/149039 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix a regression of annotating PointerOrReference (PR #149039)

2025-07-16 Thread Björn Schäpers via cfe-commits
@@ -3122,6 +3122,9 @@ class AnnotatingParser { } } +if (PrevToken->isTypeName(LangOpts)) HazardyKnusperkeks wrote: So this does not work with `bool foo = requires { static_cast(1); };`? https://github.com/llvm/llvm-project/pull/149039

[clang] [clang-format] Add IgnoreExtension to SortIncludes (PR #137840)

2025-07-15 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/137840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Remove code related to trigraphs (PR #148640)

2025-07-14 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/148640 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Simplify some logic in BreakableLineCommentSection (PR #148324)

2025-07-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/148324 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Simplify some logic in BreakableLineCommentSection (PR #148324)

2025-07-13 Thread Björn Schäpers via cfe-commits
@@ -927,14 +927,12 @@ BreakableLineCommentSection::BreakableLineCommentSection( } if (Lines[i].size() != IndentPrefix.size()) { -PrefixSpaceChange[i] = FirstLineSpaceChange; +assert(Lines[i].size() > IndentPrefix.size()); -if (SpacesInPref

[clang] [clang-format] Add MacrosSkippedByRemoveParentheses option (PR #148345)

2025-07-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/148345 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add FunctionLikeMacros option (PR #148345)

2025-07-13 Thread Björn Schäpers via cfe-commits
@@ -2786,6 +2786,11 @@ struct FormatStyle { /// \version 3.7 std::vector ForEachMacros; + /// A vector of function-like macros whose invocations should be skipped by + /// ``RemoveParentheses``. + /// \version 21 + std::vector FunctionLikeMacros; Hazar

[clang] [clang-format][NFC] Simplify some logic in BreakableLineCommentSection (PR #148324)

2025-07-13 Thread Björn Schäpers via cfe-commits
@@ -927,14 +927,12 @@ BreakableLineCommentSection::BreakableLineCommentSection( } if (Lines[i].size() != IndentPrefix.size()) { -PrefixSpaceChange[i] = FirstLineSpaceChange; +assert(Lines[i].size() > IndentPrefix.size()); -if (SpacesInPref

[clang] [clang-format][NFC] Simplify some logic in BreakableLineCommentSection (PR #148324)

2025-07-12 Thread Björn Schäpers via cfe-commits
@@ -927,14 +927,12 @@ BreakableLineCommentSection::BreakableLineCommentSection( } if (Lines[i].size() != IndentPrefix.size()) { -PrefixSpaceChange[i] = FirstLineSpaceChange; +assert(Lines[i].size() > IndentPrefix.size()); -if (SpacesInPref

[clang] [clang-format] Add FunctionLikeMacros option (PR #148345)

2025-07-12 Thread Björn Schäpers via cfe-commits
@@ -2786,6 +2786,11 @@ struct FormatStyle { /// \version 3.7 std::vector ForEachMacros; + /// A vector of function-like macros whose invocations should be skipped by + /// ``RemoveParentheses``. + /// \version 21 + std::vector FunctionLikeMacros; Hazar

[clang] [clang-format][NFC] Replace a function with StringRef::contains (PR #146245)

2025-07-10 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/146245 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Replace a function with StringRef::contains (PR #146245)

2025-07-10 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > Had we used `StringRef::contains` initially, would you still insist that it > be replaced with a "more performant" local function? Of course not, because no one would go look for it. https://github.com/llvm/llvm-project/pull/146245 _

[clang] [clang-format] Stop crashing when the input contains `??/\n` (PR #147156)

2025-07-06 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > > I added code to count the number of characters in the escape sequence > > probably just because the block of code used to have a comment saying > > someone should add the feature. > > > I am not sure we should support the trigraph. I don't know anyone who uses >

[clang] [clang-format][NFC] Replace size() with empty() (PR #147164)

2025-07-06 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/147164 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Propagate `LeadingEmptyLinesAffected` when joining lines (PR #146761)

2025-07-03 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. Please wait a few days, or until another approval. https://github.com/llvm/llvm-project/pull/146761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [clang-format][NFC] Replace a function with StringRef::contains (PR #146245)

2025-07-02 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > > While it is less code, I find a bit harder to understand and the code gen > > is far worse: https://gcc.godbolt.org/z/KzG4YnTh3 > > `IsBlank` is misleading because of `std::isblank` whereas `Blanks.contains` > is not, so the latter has better readability for me. A

[clang] [clang-format][NFC] Replace a function with StringRef::contains (PR #146245)

2025-06-29 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks commented: While it is less code, I find a bit harder to understand and the code gen is far worse: https://gcc.godbolt.org/z/KzG4YnTh3 https://github.com/llvm/llvm-project/pull/146245 ___ cfe-commits mailing list

[clang] [clang-format] Make EndsInComma in ContinuationIndenter consistent (PR #146256)

2025-06-29 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/146256 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix a bug in `ReflowComments: Always` (PR #146202)

2025-06-28 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/146202 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-06-26 Thread Björn Schäpers via cfe-commits
@@ -1647,7 +1647,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave; LLVMStyle.ShortNamespaceLines = 1; LLVMStyle.SkipMacroDefinitionBody = false; - LLVMStyle.SortIncludes = {/*Enabled=*/true,

[clang] [clang-format][NFC] Remove `\brief` from comments (PR #145853)

2025-06-26 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/145853 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-06-26 Thread Björn Schäpers via cfe-commits
@@ -1647,7 +1647,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave; LLVMStyle.ShortNamespaceLines = 1; LLVMStyle.SkipMacroDefinitionBody = false; - LLVMStyle.SortIncludes = {/*Enabled=*/true,

[clang] clang-format: Add IncludeSortKey option (PR #137840)

2025-06-26 Thread Björn Schäpers via cfe-commits
@@ -4382,8 +4382,18 @@ struct FormatStyle { ///#include "B/a.h" #include "a/b.h" /// \endcode bool IgnoreCase; +/// When sorting includes in each block, Only take file extensions into HazardyKnusperkeks wrote: ```suggestion //

[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)

2025-06-25 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/145243 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)

2025-06-25 Thread Björn Schäpers via cfe-commits
@@ -1295,13 +1305,18 @@ FormatToken *FormatTokenLexer::getNextToken() { case '/': // The text was entirely whitespace when this loop was entered. Thus // this has to be an escape sequence. -assert(Text.substr(i, 2) == "\\\r" || Text.substr(i, 2) ==

[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)

2025-06-25 Thread Björn Schäpers via cfe-commits
@@ -1295,13 +1305,18 @@ FormatToken *FormatTokenLexer::getNextToken() { case '/': // The text was entirely whitespace when this loop was entered. Thus // this has to be an escape sequence. -assert(Text.substr(i, 2) == "\\\r" || Text.substr(i, 2) ==

[clang] Remove unneeded checks for null; NFC (PR #145686)

2025-06-25 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/145686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Added AlignConsecutiveTableGenBreakingDAGArgColons option. (PR #86150)

2025-06-25 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: I don't actually understand your problem. Can you open an issue and give the input, the output and the expected output, along with your `.clang-format`? You can tag me and I'll have a look at it. https://github.com/llvm/llvm-project/pull/86150

[clang] [clang-format] Improve QualifierAlignment in guessing macros (PR #145468)

2025-06-24 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/145468 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)

2025-06-24 Thread Björn Schäpers via cfe-commits
@@ -1295,13 +1305,18 @@ FormatToken *FormatTokenLexer::getNextToken() { case '/': // The text was entirely whitespace when this loop was entered. Thus // this has to be an escape sequence. -assert(Text.substr(i, 2) == "\\\r" || Text.substr(i, 2) ==

[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)

2025-06-23 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. Please wait for @owenca . https://github.com/llvm/llvm-project/pull/145243 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)

2025-06-22 Thread Björn Schäpers via cfe-commits
@@ -0,0 +1,14 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s \ HazardyKnusperkeks wrote: We test those things in the unit tests. https://github.com/llvm/llvm-project/pull/145243 ___ cfe-commits mailing list cfe-commits@lists.l

[clang] [clang-format] Handle Trailing Whitespace After Line Continuation (P2223R2) (PR #145243)

2025-06-22 Thread Björn Schäpers via cfe-commits
@@ -0,0 +1,14 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s \ HazardyKnusperkeks wrote: That's not what I meant. We test in `clang/unittests/Format/FormatTest.cpp`. https://github.com/llvm/llvm-project/pull/145243 ___ cfe-com

[clang] [clang/docs] add a missing brace in ClangFormatStyleOptions.rst (PR #145145)

2025-06-21 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/145145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang/docs] add a missing brace in ClangFormatStyleOptions.rst (PR #145145)

2025-06-21 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/145145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Allow array alignment on non-rectangular arrays (PR #143781)

2025-06-16 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > > You can't change existing tests, you need an option if you want to pad with > > spaces > > It is unclear to me if this should be considered a bug fix, or a new feature. > Surely requiring new options are not required for every bug fix. > It boils down to the que

[clang] [clang-format][NFC] Clean up DisallowLineBreaks lambda (PR #144255)

2025-06-15 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/144255 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Clean up DisallowLineBreaks lambda (PR #144255)

2025-06-15 Thread Björn Schäpers via cfe-commits
@@ -706,42 +706,48 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, const FormatToken &Previous = *State.NextToken->Previous; auto &CurrentState = State.Stack.back(); - bool DisallowLineBreaksOnThisLine = - Style.LambdaBodyIndentati

[clang] [clang-format] Fix a bug in annotating braces (PR #144095)

2025-06-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/144095 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle templates in qualified typenames (PR #143194)

2025-06-12 Thread Björn Schäpers via cfe-commits
@@ -3651,6 +3674,21 @@ static FormatToken *getFunctionName(const AnnotatedLine &Line, continue; } +// Skip past template typename declarations that may precede the +// constructor/destructor name +if (Tok->is(tok::kw_template)) { Hazardy

  1   2   3   4   5   6   7   8   9   10   >