[clang] ee51f35 - [clang-format][doc] Add OneLineFormatOffRegex to format-off section

2025-08-16 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2025-08-16T20:59:07-07:00 New Revision: ee51f35993d9623563551f9bb9521824992967b6 URL: https://github.com/llvm/llvm-project/commit/ee51f35993d9623563551f9bb9521824992967b6 DIFF: https://github.com/llvm/llvm-project/commit/ee51f35993d9623563551f9bb9521824992967b6.diff LOG:

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

2025-08-05 Thread Owen Pan via cfe-commits
owenca 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 th

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

2025-08-04 Thread Owen Pan via cfe-commits
https://github.com/owenca requested changes to this pull request. It seems that we don't need to add a separate formatting pass for this new option as changing the case of letters in numeric literals has no impact on any existing passes. IMO, the best place to handle this is in `FormatTokenLex

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

2025-08-03 Thread Owen Pan 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 Owen Pan via cfe-commits
owenca wrote: I suggest `Prefix`, `HexDigit`, `ExponentLetter`, and `Suffix` for the sub-option names and `Leave`, `Lower`, and `Upper` for the enum values. For example: ``` NumericLiteralCase: Prefix: Lower # 0x, 0b, etc. HexDigit: Upper # ABCDEF ExponentLetter: Lower # e a

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

2025-08-03 Thread Owen Pan 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 Owen Pan 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 Owen Pan via cfe-commits
owenca wrote: Please wait for @HazardyKnusperkeks and @mydeveloperday. 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][NFC] Maximize usage of isOneOf() in TokenAnnotator (PR #151658)

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

2025-08-01 Thread Owen Pan via cfe-commits
owenca wrote: /cherry-pick 9281797a577b7954521fb9192d41e457ca2ca42e 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-08-01 Thread Owen Pan via cfe-commits
https://github.com/owenca milestoned 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][NFC] Maximize usage of isOneOf() in TokenAnnotator (PR #151658)

2025-08-01 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/151658 Also make a StringRef literal `static constexpr`. >From 4ada74523ecab8e5cdeaabf1769ee85461cc5c55 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 31 Jul 2025 23:57:57 -0700 Subject: [PATCH] [clang-format][NFC]

[clang] [clang-format] Disable IntegerLiteralSeparator for C++ before c++14 (PR #151273)

2025-07-30 Thread Owen Pan via cfe-commits
owenca wrote: /cherry-pick 5fc482cfc0fa70c98e14d64d83dffbf7da03c303 https://github.com/llvm/llvm-project/pull/151273 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Disable IntegerLiteralSeparator for C++ before c++14 (PR #151273)

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

[clang] [clang-format] Disable IntegerLiteralSeparator for C++ before c++14 (PR #151273)

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

[clang] [clang-format] Disalbe IntegerLiteralSeparator for C++ before c++14 (PR #151273)

2025-07-29 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/151273 >From 9fab68a7aa71e6ffe6ad6476359a21884b084576 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 29 Jul 2025 21:09:46 -0700 Subject: [PATCH] [clang-format] Disalbe IntegerLiteralSeparator for C++ before c++14

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

2025-07-28 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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 Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH 1/3] [clang-format] Fix a bug in `DerivePointerAlignment: true` This

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

2025-07-27 Thread Owen Pan 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 Owen Pan via cfe-commits
https://github.com/owenca edited 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 Owen Pan 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 Owen Pan 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 Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH 1/2] [clang-format] Fix a bug in `DerivePointerAlignment: true` This

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

2025-07-27 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH 1/2] [clang-format] Fix a bug in `DerivePointerAlignment: true` This

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

2025-07-27 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH 1/2] [clang-format] Fix a bug in `DerivePointerAlignment: true` This

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

2025-07-27 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH 1/2] [clang-format] Fix a bug in `DerivePointerAlignment: true` This

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

2025-07-27 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH 1/2] [clang-format] Fix a bug in `DerivePointerAlignment: true` This

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

2025-07-27 Thread Owen Pan 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 Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH] [clang-format] Fix a bug in `DerivePointerAlignment: true` This effec

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

2025-07-26 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/150744 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 26 Jul 2025 01:56:52 -0700 Subject: [PATCH] [clang-format] Fix a bug in `DerivePointerAlignment: true` This effec

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

2025-07-26 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/150744 This effectively reverts a4d4859dc70c046ad928805ddeaf8fa101793394 which didn't fix the problem that `int*,` was not counted as "Left" alignment. Fixes #150327 >From 7418fe966ff3a3e9f3c6c431beafbdde47a1de30 Mon

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

2025-07-24 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. 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-24 Thread Owen Pan via cfe-commits
owenca wrote: > Style Guide has been updated internally. I don't know how long it takes to > make its way to the public site, so I'd like to proceed. I've pasted the > updated text into the commit description above. I still think we should wait until it becomes official. WDYT @mydeveloperday

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

2025-07-24 Thread Owen Pan via cfe-commits
owenca wrote: /cherry-pick a4d4859dc70c046ad928805ddeaf8fa101793394 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 closed 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 Owen Pan via cfe-commits
owenca wrote: /cherry-pick 97c953406d68357dddb8b624cd32c8e435a9fcfb 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] Add AfterNot to SpaceBeforeParensOptions (PR #150367)

2025-07-24 Thread Owen Pan via cfe-commits
https://github.com/owenca closed 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] Add AfterNot to SpaceBeforeParensOptions (PR #150367)

2025-07-24 Thread Owen Pan via cfe-commits
https://github.com/owenca milestoned 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] 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

  1   2   3   4   5   6   7   8   9   10   >