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

2025-07-24 Thread Owen Pan via cfe-commits
https://github.com/owenca milestoned 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] Fix a bug in `DerivePointerAlignment: true` (PR #150387)

2025-07-24 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/150387 Fixes #150327 >From 12777c2044cc9daac3fffcb96c0c1f4c772e9147 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 24 Jul 2025 01:22:36 -0700 Subject: [PATCH] [clang-format] Fix a bug in `DerivePointerAlignment: tr

[clang] [clang-format] Stop ctor initializer from being inlined (PR #150361)

2025-07-24 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/150361 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Stop ctor initializer from being inlined (PR #150361)

2025-07-23 Thread Owen Pan via cfe-commits
@@ -7771,6 +7771,37 @@ TEST_F(FormatTest, ConstructorInitializers) { "Constructor() :\n" "// Comment forcing unwanted break.\n" "() {}"); + + // Braced initializers with trailing commas. + verifyFormat("MyClass::MyC

[clang] [clang-format] Stop ctor initializer from being inlined (PR #150361)

2025-07-23 Thread Owen Pan via cfe-commits
@@ -7771,6 +7771,37 @@ TEST_F(FormatTest, ConstructorInitializers) { "Constructor() :\n" "// Comment forcing unwanted break.\n" "() {}"); + + // Braced initializers with trailing commas. + verifyFormat("MyClass::MyC

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

2025-07-23 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/150166 ___ 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 Owen Pan via cfe-commits
owenca wrote: It's better to add a value to `SpaceBeforeParensOptions` instead. See #150367. https://github.com/llvm/llvm-project/pull/150166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

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

2025-07-23 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/150367 Closes #149971 >From bbe06c902d24df2ae9163ba0b43eca45e82c6506 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 23 Jul 2025 15:51:34 -0700 Subject: [PATCH] [clang-format] Add AfterNot to SpaceBeforeParensOption

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

2025-07-23 Thread Owen Pan 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 Owen Pan 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 Owen Pan 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-22 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/150166 Replace true/false with SAN_Exclaim/SAN_Never and add SAN_Always. Closes #149971 >From b5442f59d649b38086ccd91d40c7c291dd924cc8 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 22 Jul 2025 22:07:05 -0700 Subj

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

2025-07-21 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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] Google Style: disable DerivePointerAlignment. (PR #149602)

2025-07-21 Thread Owen Pan via cfe-commits
owenca wrote: > > Can you add a link to the relevant section of the style guide? > > The new policy is not yet published, but I added a link to the section which > will be changed. This patch looks good now, but IMO we should wait until the new style is published. https://github.com/llvm/llv

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

2025-07-20 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/149765 Consistently use `constexpr StringRef Code("string literal");`. >From 318739aa86bc2ef00d2a32fc1141722b441ece41 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 20 Jul 2025 22:28:24 -0700 Subject: [PATCH] [clan

[clang] f3a3270 - [clang-format][NFC] Delete redundant type names after FormatStyle::

2025-07-20 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2025-07-20T20:27:37-07:00 New Revision: f3a3270dbca3649b7d56aaa42cb8481fb34e2d67 URL: https://github.com/llvm/llvm-project/commit/f3a3270dbca3649b7d56aaa42cb8481fb34e2d67 DIFF: https://github.com/llvm/llvm-project/commit/f3a3270dbca3649b7d56aaa42cb8481fb34e2d67.diff LOG:

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

2025-07-20 Thread Owen Pan via cfe-commits
https://github.com/owenca edited 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] Fix a bug in `BreakBeforeBinaryOperators: All` (PR #149695)

2025-07-20 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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] Fix a bug in `BreakBeforeBinaryOperators: All` (PR #149695)

2025-07-20 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/149695 Fixes #149520 >From 00d145827caea33cbec8f49a03e4c8b56fc40e01 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 20 Jul 2025 00:58:58 -0700 Subject: [PATCH] [clang-format] Fix a bug in `BreakBeforeBinaryOperators

[clang] [clang-format] Google Style: disable DerivePointerAlignment. (PR #149602)

2025-07-19 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/149602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Google Style: disable DerivePointerAlignment. (PR #149602)

2025-07-18 Thread Owen Pan via cfe-commits
@@ -12287,6 +12287,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { ", *a);"); verifyGoogleFormat("int const* a = &b;"); + verifyFormat("int const* a = &b;", "int const *a = &b;", getGoogleStyle()); ---

[clang] [clang-format] Google Style: disable DerivePointerAlignment. (PR #149602)

2025-07-18 Thread Owen Pan via cfe-commits
@@ -1753,7 +1753,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { GoogleStyle.AttributeMacros.push_back("absl_nullable"); GoogleStyle.AttributeMacros.push_back("absl_nullability_unknown"); GoogleStyle.BreakTemplateDeclarations = FormatStyle::BTDS_Yes

[clang] [clang-format] Google Style: disable DerivePointerAlignment. (PR #149602)

2025-07-18 Thread Owen Pan via cfe-commits
@@ -12891,27 +12892,30 @@ TEST_F(FormatTest, UnderstandsEllipsis) { } TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) { + FormatStyle Style = getLLVMStyle(); owenca wrote: ```suggestion auto Style = getGoogleStyle(); ASSERT_FALSE(Style.DeriveP

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

2025-07-17 Thread Owen Pan via cfe-commits
owenca wrote: /cherry-pick a8f5e9ed6b44562938ce07e2790be90be8f0a6b5 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] Remove code related to trigraphs (PR #148640)

2025-07-17 Thread Owen Pan via cfe-commits
@@ -1300,22 +1293,16 @@ FormatToken *FormatTokenLexer::getNextToken() { Style.TabWidth - (Style.TabWidth ? Column % Style.TabWidth : 0); break; case '\\': - case '?': - case '/': -// The text was entirely whitespace when this loop was

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

2025-07-17 Thread Owen Pan via cfe-commits
https://github.com/owenca milestoned 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] Add IgnoreExtension to SortIncludes (PR #137840)

2025-07-17 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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] Handle templates in qualified typenames (PR #143194)

2025-07-16 Thread Owen Pan 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] Handle templates in qualified typenames (PR #143194)

2025-07-16 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/143194 ___ 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-16 Thread Owen Pan via cfe-commits
https://github.com/owenca requested changes to this pull request. Please run `ninja clang-format-check-format` before `git push`. Also, run `ninja polly-check-format`, which gives the assertion failure below: ``` Assertion failed: (Tok->is(TT_TemplateOpener)), function getFunctionName, file Tok

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

2025-07-16 Thread Owen Pan via cfe-commits
@@ -3122,6 +3122,9 @@ class AnnotatingParser { } } +if (PrevToken->isTypeName(LangOpts)) owenca wrote: It works if `TypeNames: [MyType]` is added to the config, but I've added a heuristic so that it won't be necessary. https://github.com/llvm/

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

2025-07-16 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/149039 >From 2418846a33683555f2e14de91aa42c1ec38b3fdb Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 16 Jul 2025 01:59:40 -0700 Subject: [PATCH 1/2] [clang-format] Fix a regression of annotating PointerOrReference

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

2025-07-16 Thread Owen Pan via cfe-commits
https://github.com/owenca edited 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 Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/149039 Fixes 149010 >From 2418846a33683555f2e14de91aa42c1ec38b3fdb Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 16 Jul 2025 01:59:40 -0700 Subject: [PATCH] [clang-format] Fix a regression of annotating PointerOr

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

2025-07-15 Thread Owen Pan via cfe-commits
https://github.com/owenca edited 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] Add IgnoreExtension to SortIncludes (PR #137840)

2025-07-15 Thread Owen Pan via cfe-commits
https://github.com/owenca edited 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: Add IncludeSortKey option (PR #137840)

2025-07-15 Thread Owen Pan via cfe-commits
https://github.com/owenca 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: Add IncludeSortKey option (PR #137840)

2025-07-15 Thread Owen Pan via cfe-commits
@@ -4385,8 +4385,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 +/// account if two includes compare equal otherwise. +/

[clang] [llvm] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)

2025-07-14 Thread Owen Pan via cfe-commits
@@ -622,15 +622,26 @@ template <> struct ScalarEnumerationTraits { } }; -template <> struct ScalarEnumerationTraits { - static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) { -IO.enumCase(Value, "None", FormatStyle::SFS_None); -IO.enumCase(Value,

[clang] [llvm] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)

2025-07-14 Thread Owen Pan via cfe-commits
@@ -1180,16 +1183,47 @@ TEST_F(FormatTestJS, InliningFunctionLiterals) { "}", Style); - Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty; + Style.AllowShortFunctionsOnASingleLine = + FormatStyle::ShortFunctionStyle::setEmptyO

[clang] [llvm] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)

2025-07-14 Thread Owen Pan via cfe-commits
@@ -623,20 +623,29 @@ TEST(ConfigParseTest, ParsesConfiguration) { CHECK_PARSE("AllowShortBlocksOnASingleLine: true", AllowShortBlocksOnASingleLine, FormatStyle::SBS_Always); - Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; CHECK_PARSE("A

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

2025-07-13 Thread Owen Pan via cfe-commits
owenca wrote: IIRC, we had so many issues with ``AlignArrayOfStructures`` that at one point we were discussing whether to disable it. Even after @mydeveloperday had reduced its functionality to only handling rectangular arrays, we still had to fix quite a few bugs including crashes before it w

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

2025-07-13 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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 Owen Pan 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 Owen Pan via cfe-commits
https://github.com/owenca closed 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 MacrosSkippedByRemoveParentheses option (PR #148345)

2025-07-13 Thread Owen Pan via cfe-commits
https://github.com/owenca edited 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 Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/148345 >From 3affefb96efe2d2955be66c247276b81d5d1d3a1 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 12 Jul 2025 00:09:49 -0700 Subject: [PATCH 1/2] [clang-format] Add FunctionLikeMacros option This allows RemovePa

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

2025-07-13 Thread Owen Pan 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 Owen Pan 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; owenc

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

2025-07-12 Thread Owen Pan 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 Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/148345 This allows RemoveParentheses to skip the invocations of function-like macros. Fixes #68354. Fixes #147780. >From 3affefb96efe2d2955be66c247276b81d5d1d3a1 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 12 J

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

2025-07-11 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/148324 None >From 88f34fb41704bdd6f6de743a5b467cdc3c938cc4 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 11 Jul 2025 18:18:18 -0700 Subject: [PATCH] [clang-format][NFC] Simplify some logic in BreakableLineComment

[clang] 2f1673e - Follow up on #147623

2025-07-11 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2025-07-11T18:15:27-07:00 New Revision: 2f1673eaa0e3b0c98cdd66429849ec27e220055b URL: https://github.com/llvm/llvm-project/commit/2f1673eaa0e3b0c98cdd66429849ec27e220055b DIFF: https://github.com/llvm/llvm-project/commit/2f1673eaa0e3b0c98cdd66429849ec27e220055b.diff LOG:

[clang] [clang-format] Split line comments separated by backslashes (PR #147648)

2025-07-10 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/147648 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Split line comments separated by backslashes (PR #147648)

2025-07-10 Thread Owen Pan via cfe-commits
@@ -513,9 +513,9 @@ struct FormatStyle { ENAS_LeftWithLastLine, /// Align escaped newlines in the right-most column. /// \code -/// #define A \ -/// int ;

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

2025-07-10 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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] Split line comments separated by backslashes (PR #147648)

2025-07-09 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/147648 >From 3efb5ca11d67ad36c4cbb1ea78220a1ca69a8339 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 8 Jul 2025 21:16:12 -0700 Subject: [PATCH 1/2] [clang-format] Split line comments separated by backslashes Fixes

[clang] [clang-format] Split line comments separated by backslashes (PR #147648)

2025-07-09 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/147648 >From 3efb5ca11d67ad36c4cbb1ea78220a1ca69a8339 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 8 Jul 2025 21:16:12 -0700 Subject: [PATCH 1/2] [clang-format] Split line comments separated by backslashes Fixes

[clang] [clang-format] Split line comments separated by backslashes (PR #147648)

2025-07-08 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/147648 Fixes #147341 >From 3efb5ca11d67ad36c4cbb1ea78220a1ca69a8339 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 8 Jul 2025 21:16:12 -0700 Subject: [PATCH] [clang-format] Split line comments separated by backslas

[clang] Address a handful of C4146 compiler warnings where literals can be replaced with std::numeric_limits (PR #147623)

2025-07-08 Thread Owen Pan via cfe-commits
@@ -777,7 +779,7 @@ template <> struct MappingTraits { IO.mapOptional("Maximum", signedMaximum); Space.Maximum = static_cast(signedMaximum); -if (Space.Maximum != -1u) +if (Space.Maximum != std::numeric_limits::max()) owenca wrote: ```suggest

[clang] a5af874 - [clang-format][NFC] Use `empty()` instead of comparing size() to 0 or 1

2025-07-06 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2025-07-06T23:54:00-07:00 New Revision: a5af8745039f906c4fc4184a1fe0d35d42355f52 URL: https://github.com/llvm/llvm-project/commit/a5af8745039f906c4fc4184a1fe0d35d42355f52 DIFF: https://github.com/llvm/llvm-project/commit/a5af8745039f906c4fc4184a1fe0d35d42355f52.diff LOG:

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

2025-07-06 Thread Owen Pan via cfe-commits
owenca wrote: Had we used `StringRef::contains` initially, would you still insist that it be replaced with a "more performant" local function? Please note that the code is not on a performance critical path, and the difference in time it takes to run the relevant unit tests for 100 times is wi

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

2025-07-06 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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][NFC] Replace size() with empty() (PR #147164)

2025-07-05 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/147164 None >From e6945b8f51409e1ffd71a47b70e06599774d213e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 5 Jul 2025 15:15:05 -0700 Subject: [PATCH] [clang-format][NFC] Replace size() with empty() --- clang/lib/F

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

2025-07-05 Thread Owen Pan via cfe-commits
owenca 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 > it. The C2y draft does

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

2025-07-05 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/146761 ___ 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-05 Thread Owen Pan via cfe-commits
@@ -986,7 +986,7 @@ class LineJoiner { void join(AnnotatedLine &A, const AnnotatedLine &B) { assert(!A.Last->Next); assert(!B.First->Previous); -if (B.Affected) +if (B.Affected || (B.LeadingEmptyLinesAffected && A.Last->Children.empty())) owe

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

2025-07-05 Thread Owen Pan via cfe-commits
@@ -986,7 +986,7 @@ class LineJoiner { void join(AnnotatedLine &A, const AnnotatedLine &B) { assert(!A.Last->Next); assert(!B.First->Previous); -if (B.Affected) +if (B.Affected || (B.LeadingEmptyLinesAffected && A.Last->Children.empty())) owe

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

2025-07-04 Thread Owen Pan via cfe-commits
@@ -986,7 +986,7 @@ class LineJoiner { void join(AnnotatedLine &A, const AnnotatedLine &B) { assert(!A.Last->Next); assert(!B.First->Previous); -if (B.Affected) +if (B.Affected || (B.LeadingEmptyLinesAffected && A.Last->Children.empty())) owe

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

2025-07-04 Thread Owen Pan via cfe-commits
@@ -41,6 +41,8 @@ TEST_F(FormatTestSelective, RemovesTrailingWhitespaceOfFormattedLine) { EXPECT_EQ("int a;", format("int a; ", 0, 0)); EXPECT_EQ("int a;\n", format("int a; \n \n \n ", 0, 0)); EXPECT_EQ("int a;\nint b;", format("int a; \nint b;", 0,

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

2025-06-29 Thread Owen Pan via cfe-commits
owenca 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. As to the generated cod

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

2025-06-29 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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][NFC] Replace a function with StringRef::contains (PR #146245)

2025-06-28 Thread Owen Pan via cfe-commits
https://github.com/owenca edited 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] Make EndsInComma in ContinuationIndenter consistent (PR #146256)

2025-06-28 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/146256 None >From b7dd2cee0b6064f29e1f9562d26675152bb2756b Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 28 Jun 2025 18:13:43 -0700 Subject: [PATCH] [clang-format] Make EndsInComma in ContinuationIndenter consist

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

2025-06-28 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/146245 None >From 60a0768fef885cb87e564f6dba7e101befd6ab0d Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 28 Jun 2025 15:52:58 -0700 Subject: [PATCH] [clang-format[NFC] Replace a function with StringRef::contains

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

2025-06-28 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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] Fix an off-by-1 bug with -length option (PR #143302)

2025-06-28 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/143302 ___ 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 Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/146202 Fixes #39150 >From 00c0c25a5f17a0077cfc8660020391684aa5 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 28 Jun 2025 00:25:02 -0700 Subject: [PATCH] [clang-format] Fix a bug in `ReflowComments: Always` Fi

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

2025-06-26 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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] Fix an off-by-1 bug with -length option (PR #143302)

2025-06-26 Thread Owen Pan via cfe-commits
@@ -296,12 +296,16 @@ static bool fillRanges(MemoryBuffer *Code, } if (!EmptyLengths) Length = Lengths[I]; +if (Length == 0) { + errs() << "error: length should be at least 1\n"; + return true; +} if (Offset + Length > CodeSize) { err

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

2025-06-26 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/145853 This was done before in https://reviews.llvm.org/D46320 >From 889e392fcf49c05ceea7949690b207b73f83d49b Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 26 Jun 2025 01:14:58 -0700 Subject: [PATCH] [clang-format

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

2025-06-26 Thread Owen Pan 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 Owen Pan 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] Fix an off-by-1 bug with -length option (PR #143302)

2025-06-25 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/143302 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix an off-by-1 bug with -length option (PR #143302)

2025-06-25 Thread Owen Pan via cfe-commits
@@ -296,12 +296,16 @@ static bool fillRanges(MemoryBuffer *Code, } if (!EmptyLengths) Length = Lengths[I]; +if (Length == 0) { + errs() << "error: length should be at least 1\n"; + return true; +} if (Offset + Length > CodeSize) { err

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

2025-06-25 Thread Owen Pan via cfe-commits
@@ -25768,6 +25768,29 @@ TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) { verifyFormat("foo(operator, , -42);", Style); } +TEST_F(FormatTest, LineSpliceWithTrailingWhitespace) { + // Test that each sequence of a backslash (\) immediately followed by zero or + // more hor

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

2025-06-25 Thread Owen Pan via cfe-commits
@@ -25768,6 +25768,29 @@ TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) { verifyFormat("foo(operator, , -42);", Style); } +TEST_F(FormatTest, LineSpliceWithTrailingWhitespace) { + // Test that each sequence of a backslash (\) immediately followed by zero or + // more hor

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

2025-06-25 Thread Owen Pan via cfe-commits
@@ -1205,14 +1206,23 @@ static size_t countLeadingWhitespace(StringRef Text) { while (Cur < End) { if (isspace(Cur[0])) { ++Cur; -} else if (Cur[0] == '\\' && (Cur[1] == '\n' || Cur[1] == '\r')) { - // A '\' followed by a newline always escapes the newline,

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

2025-06-25 Thread Owen Pan via cfe-commits
@@ -1025,6 +1025,9 @@ clang-format ``enum`` enumerator lists. - Add ``OneLineFormatOffRegex`` option for turning formatting off for one line. - Add ``SpaceAfterOperatorKeyword`` option. +- Support trailing whitespace in line splicing. + (P2223R2

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

2025-06-25 Thread Owen Pan via cfe-commits
@@ -1205,14 +1206,23 @@ static size_t countLeadingWhitespace(StringRef Text) { while (Cur < End) { if (isspace(Cur[0])) { ++Cur; -} else if (Cur[0] == '\\' && (Cur[1] == '\n' || Cur[1] == '\r')) { - // A '\' followed by a newline always escapes the newline,

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

2025-06-25 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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 Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. 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-24 Thread Owen Pan 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-24 Thread Owen Pan via cfe-commits
@@ -1205,14 +1206,23 @@ static size_t countLeadingWhitespace(StringRef Text) { while (Cur < End) { if (isspace(Cur[0])) { owenca wrote: ```suggestion if (isWhitespace(Cur[0])) { ``` https://github.com/llvm/llvm-project/pull/145243 ___

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

2025-06-24 Thread Owen Pan via cfe-commits
@@ -1205,14 +1206,23 @@ static size_t countLeadingWhitespace(StringRef Text) { while (Cur < End) { if (isspace(Cur[0])) { ++Cur; -} else if (Cur[0] == '\\' && (Cur[1] == '\n' || Cur[1] == '\r')) { - // A '\' followed by a newline always escapes the newline,

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

2025-06-24 Thread Owen Pan 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] Improve QualifierAlignment in guessing macros (PR #145468)

2025-06-23 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/145468 Fixes #145388 >From 349d309467c1251a9206f665886bde06b96ced32 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Mon, 23 Jun 2025 23:32:31 -0700 Subject: [PATCH] [clang-format] Improve QualifierAlignment in guessing m

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

2025-06-23 Thread Owen Pan via cfe-commits
@@ -25768,6 +25768,29 @@ TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) { verifyFormat("foo(operator, , -42);", Style); } +TEST_F(FormatTest, LineSpliceWithTrailingWhitespace) { + // Test that each sequence of a backslash (\) immediately followed by zero or + // more hor

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

2025-06-23 Thread Owen Pan via cfe-commits
@@ -25768,6 +25768,29 @@ TEST_F(FormatTest, OperatorPassedAsAFunctionPtr) { verifyFormat("foo(operator, , -42);", Style); } +TEST_F(FormatTest, LineSpliceWithTrailingWhitespace) { + // Test that each sequence of a backslash (\) immediately followed by zero or + // more hor

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

2025-06-21 Thread Owen Pan via cfe-commits
@@ -6992,7 +6992,7 @@ the configuration (without a prefix: ``Auto``). .. code-block:: c++ namespace N1 { - namespace N2 + namespace N2 { owenca wrote: This file is generated from `clang/include/clang/Format/Format.h`. Please edit that fil

  1   2   3   4   5   6   7   8   9   10   >