[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread Owen Pan via cfe-commits
owenca wrote: It seems [AlignOperands](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#alignoperands) is supposed to do what this new option would, so maybe we should fix/extend `AlignOperands` instead? https://github.com/llvm/llvm-project/pull/95013 _

[clang] [clang-format] Fix a bug in annotating `*` in `#define`s (PR #99433)

2024-07-17 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/99433 Fixes #99271. >From ebf25d890ff47be48bd153942d943906943a247b Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 17 Jul 2024 22:30:21 -0700 Subject: [PATCH] [clang-format] Fix a bug in annotating `*` in `#define`s

[clang] [clang-format] Fix a misannotation of PointerOrReference (PR #101291)

2024-07-30 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/101291 Fixes #101138. >From 0a162016899abb8a477e0fedad5be0416464ad4a Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 30 Jul 2024 23:20:12 -0700 Subject: [PATCH] [clang-format] Fix a misannotation of PointerOrReferen

[clang] [clang-format] Fix a misannotation of PointerOrReference (PR #101291)

2024-07-30 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/101291 >From c59345d3b70a5343af22f78837ef8a47bea35e41 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 30 Jul 2024 23:20:12 -0700 Subject: [PATCH] [clang-format] Fix a misannotation of PointerOrReference Fixes #10113

[clang] [clang-format] Fix a misannotation of PointerOrReference (PR #101291)

2024-08-01 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/101291 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle parenthesized list in RemoveParentheses (PR #100852)

2024-08-02 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/100852 >From f06f3ab5e59217348e72179c9581be338efa8789 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 26 Jul 2024 19:17:33 -0700 Subject: [PATCH] [clang-format] Handle parenthesized list in RemoveParentheses Also, r

[clang] [clang-format] Handle parenthesized list in RemoveParentheses (PR #100852)

2024-08-03 Thread Owen Pan via cfe-commits
https://github.com/owenca demilestoned https://github.com/llvm/llvm-project/pull/100852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] d86a995 - [clang-format][doc] Fix a typo.

2024-08-04 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2024-08-04T21:14:52-07:00 New Revision: d86a995ab78905cd055f8a93812c3b94cf042499 URL: https://github.com/llvm/llvm-project/commit/d86a995ab78905cd055f8a93812c3b94cf042499 DIFF: https://github.com/llvm/llvm-project/commit/d86a995ab78905cd055f8a93812c3b94cf042499.diff LOG:

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -146,6 +147,33 @@ static bool startsNextParameter(const FormatToken &Current, Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma)); } +// Returns \c true if \c Token in an alignable binary operator +static bool isAlignableBinaryOperator(const FormatToken

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/95013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
https://github.com/owenca commented: This patch also fixes #58014 and #57280, so you can include them in the commit message. https://github.com/llvm/llvm-project/pull/95013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -27630,6 +27630,245 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) { verifyFormat("return sizeof \"5\";"); } +TEST_F(FormatTest, BreakBinaryOperations) { + auto Style = getLLVMStyleWithColumns(60); + // Logical operations + verifyFormat("if (condition1 && conditi

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -2231,6 +2231,41 @@ struct FormatStyle { /// \version 3.7 bool BreakBeforeTernaryOperators; + /// Different ways to break binary operations. + enum BreakBinaryOperationsStyle : int8_t { +/// Don't break binary operations +/// \code +///aaa + * ccc

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -2231,6 +2231,41 @@ struct FormatStyle { /// \version 3.7 bool BreakBeforeTernaryOperators; + /// Different ways to break binary operations. + enum BreakBinaryOperationsStyle : int8_t { +/// Don't break binary operations +/// \code +///aaa + * ccc

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -2231,6 +2231,41 @@ struct FormatStyle { /// \version 3.7 bool BreakBeforeTernaryOperators; + /// Different ways to break binary operations. + enum BreakBinaryOperationsStyle : int8_t { +/// Don't break binary operations +/// \code +///aaa + * ccc

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -27630,6 +27630,245 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) { verifyFormat("return sizeof \"5\";"); } +TEST_F(FormatTest, BreakBinaryOperations) { + auto Style = getLLVMStyleWithColumns(60); + // Logical operations + verifyFormat("if (condition1 && conditi

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -27630,6 +27630,245 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) { verifyFormat("return sizeof \"5\";"); } +TEST_F(FormatTest, BreakBinaryOperations) { + auto Style = getLLVMStyleWithColumns(60); + // Logical operations owenca wrote: ```suggest

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
@@ -146,6 +147,33 @@ static bool startsNextParameter(const FormatToken &Current, Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma)); } +// Returns \c true if \c Token in an alignable binary operator +static bool isAlignableBinaryOperator(const FormatToken

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-04 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/95013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add BreakBinaryOperations configuration (PR #95013)

2024-08-05 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/95013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Change BinPackParameters to an enum to add a BreakAlways (PR #101882)

2024-08-05 Thread Owen Pan via cfe-commits
owenca wrote: We should rename the option and its values to e.g. `BreakParameters` and `Never`/`OnePerLine`/`Always`. See also https://github.com/llvm/llvm-project/pull/95013#discussion_r1703578003. https://github.com/llvm/llvm-project/pull/101882 __

[clang] [clang-format] Fix a bug in annotating CastRParen (PR #102261)

2024-08-06 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/102261 Fixes #102102. >From b72a629d16d5bc3ce800a562fd41ba2dfd1fe1eb Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 6 Aug 2024 18:10:20 -0700 Subject: [PATCH] [clang-format] Fix a bug in annotating CastRParen Fixe

[clang] [clang-format] Change BinPackParameters to an enum to add a BreakAlways (PR #101882)

2024-08-07 Thread Owen Pan via cfe-commits
owenca wrote: > When you say rename, do you mean deprecate `BinPackParameters` like in these > changes > [6739bb5](https://github.com/llvm/llvm-project/commit/6739bb5006bc28e2bdbdb2326eb2c957546634aa) > but using `BreakParameters` and `Never`/`OnePerLine`/`Always` for the names? Yes, deprecat

[clang] [clang-format] Skip block commented out includes when sorting them (PR #97787)

2024-07-04 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/97787 Fixes #97539. >From 73d92b38268e5b44d6ed7e6ac9219267003cc7fb Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 4 Jul 2024 21:39:38 -0700 Subject: [PATCH] [clang-format] Skip block commented out includes when sor

[clang] [clang-format] Skip block commented out includes when sorting them (PR #97787)

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

[clang] [clang-format][NFC] Annotate function decl l_paren (PR #97938)

2024-07-06 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/97938 None >From eb53318b3c5dec2452c4a0d5aed7944ebdd99380 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 6 Jul 2024 22:21:26 -0700 Subject: [PATCH] [clang-format][NFC] Annotate function decl l_paren --- clang/lib

[clang] [clang-format] Improve BlockIndent at ColumnLimit (PR #93140)

2024-07-06 Thread Owen Pan via cfe-commits
@@ -803,6 +803,60 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, tok::kw_switch); }; + // Detecting functions is brittle. It wo

[clang] [clang-format][NFC] Annotate function decl l_paren (PR #97938)

2024-07-08 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/97938 >From eb53318b3c5dec2452c4a0d5aed7944ebdd99380 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 6 Jul 2024 22:21:26 -0700 Subject: [PATCH 1/2] [clang-format][NFC] Annotate function decl l_paren --- clang/lib/F

[clang] [clang-format][NFC] Annotate function/ctor/dtor declaration l_paren (PR #97938)

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

[clang] [clang-format][NFC] Annotate function/ctor/dtor declaration l_paren (PR #97938)

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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current, Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma)); } +// Returns \c true if \c Current starts a new operand in a binary operation. owenca wrote: Did you me

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -3153,6 +3153,15 @@ class ExpressionParser { parse(Precedence + 1); int CurrentPrecedence = getCurrentPrecedence(); + if (!Style.BinPackBinaryOperations && + (CurrentPrecedence > prec::Conditional) && + (CurrentPrecedence < prec::PointerTo

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current, Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma)); } +// Returns \c true if \c Current starts a new operand in a binary operation. +static bool startsNextOperand(const Forma

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current, Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma)); } +// Returns \c true if \c Current starts a new operand in a binary operation. +static bool startsNextOperand(const Forma

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -27628,6 +27628,109 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) { verifyFormat("return sizeof \"5\";"); } +TEST_F(FormatTest, BinPackBinaryOperations) { + auto Style = getLLVMStyleWithColumns(60); + // Logical operations + verifyFormat("if (condition1 && condi

[clang] [clang-format] Fix a bug in TCAS_Leave using tabs for indentation (PR #98427)

2024-07-10 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/98427 Fixes #92530. >From fa1da3d06ed2207902df4911933bd40f0d514e51 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 10 Jul 2024 20:52:18 -0700 Subject: [PATCH] [clang-format] Fix a bug in TCAS_Leave using tabs for i

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
https://github.com/owenca commented: Also, we need ConfigParseTest for the new option. https://github.com/llvm/llvm-project/pull/95013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -3153,6 +3153,15 @@ class ExpressionParser { parse(Precedence + 1); int CurrentPrecedence = getCurrentPrecedence(); + if (!Style.BinPackBinaryOperations && + (CurrentPrecedence > prec::Conditional) && + (CurrentPrecedence < prec::PointerTo

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -27628,6 +27628,109 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) { verifyFormat("return sizeof \"5\";"); } +TEST_F(FormatTest, BinPackBinaryOperations) { + auto Style = getLLVMStyleWithColumns(60); + // Logical operations + verifyFormat("if (condition1 && condi

[clang] [clang-format] Fix a bug in `AlignAfterOpenBracket: DontAlign` (PR #94561)

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

[clang] [clang-format][NFC] Remove an else after a return statement (PR #94548)

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

[clang] [clang-format]: Annotate colons found in inline assembly (PR #92617)

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

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits
https://github.com/owenca commented: What happens if the comment is unindented, with and without an empty line below it? https://github.com/llvm/llvm-project/pull/94776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits
@@ -4828,7 +4833,10 @@ void UnwrappedLineParser::readToken(int LevelDifference) { PPBranchLevel > 0) { Line->Level += PPBranchLevel; } - flushComments(isOnNewLine(*FormatTok)); + + if (!UnbracedBodyDepth) owenca wrote: Ditto.

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits
@@ -796,6 +796,44 @@ TEST_F(FormatTestComments, ParsesCommentsAdjacentToPPDirectives) { format("namespace {}\n /* Test */#define A")); } +TEST_F(FormatTestComments, DeIdentsCommentBeforeIfdefAfterBracelessIf) { + verifyFormat("void f() {\n" +

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

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

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits
@@ -4811,8 +4813,11 @@ void UnwrappedLineParser::readToken(int LevelDifference) { (!Style.isVerilog() || Keywords.isVerilogPPDirective(*Tokens->peekNextToken())) && FirstNonCommentOnLine) { - distributeComments(Comments, FormatTok); -

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits
@@ -338,6 +338,9 @@ class UnwrappedLineParser { // `decltype(auto)`. bool IsDecltypeAutoFunction = false; + // Current nesting depth within unbraced codeblocks. owenca wrote: ```suggestion // Nesting depth of unbraced body of a control statement. ```

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits
@@ -796,6 +796,24 @@ TEST_F(FormatTestComments, ParsesCommentsAdjacentToPPDirectives) { format("namespace {}\n /* Test */#define A")); } + +TEST_F(FormatTestComments, DeIdentsCommentBeforeIfdefAfterBracelessIf) { + EXPECT_EQ("void f() {\n"

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-09 Thread Owen Pan via cfe-commits
owenca wrote: This patch formats ``` void f() { if (foo) bar(); // Comment #if BAZ baz(); #endif } ``` to ``` void f() { if (foo) bar(); // Comment #if BAZ baz(); #endif } ``` The trailing comment shouldn't be wrapped. https://github.com/llvm/llvm-project/pull/94776 _

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-09 Thread Owen Pan via cfe-commits
@@ -22858,6 +22858,36 @@ TEST_F(FormatTest, FormatsLambdas) { " //\n" "});"); + FormatStyle LLVMStyle = getLLVMStyleWithColumns(60); + + verifyFormat("int main() {\n" + " very_long_function_name_yes_it_is_really_long(\n" + "

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-09 Thread Owen Pan via cfe-commits
@@ -22858,6 +22858,36 @@ TEST_F(FormatTest, FormatsLambdas) { " //\n" "});"); + FormatStyle LLVMStyle = getLLVMStyleWithColumns(60); + + verifyFormat("int main() {\n" + " very_long_function_name_yes_it_is_really_long(\n" + "

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-09 Thread Owen Pan via cfe-commits
@@ -1457,6 +1457,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { !Current.isOneOf(tok::colon, tok::comment)) { return ContinuationIndent; } + if (Current.is(TT_TrailingReturnArrow) && + Previous.isOneOf(tok::kw_noexcept, tok::k

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-09 Thread Owen Pan via cfe-commits
@@ -22858,6 +22858,36 @@ TEST_F(FormatTest, FormatsLambdas) { " //\n" "});"); + FormatStyle LLVMStyle = getLLVMStyleWithColumns(60); + + verifyFormat("int main() {\n" + " very_long_function_name_yes_it_is_really_long(\n" + "

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-09 Thread Owen Pan via cfe-commits
owenca wrote: > Technically also applies to attributes applied to the return type of the > lambda, i.e. > > ``` > int main() { > very_long_function_name_yes_it_is_really_long( > // also happens with constexpr specifier > [](auto n) [[attribute]] > -> std::enable_if_t< >

[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-06-09 Thread Owen Pan via cfe-commits
@@ -1864,7 +1894,11 @@ FormatStyle getWebKitStyle() { Style.ObjCSpaceAfterProperty = true; Style.PointerAlignment = FormatStyle::PAS_Left; Style.SpaceBeforeCpp11BracedList = true; - Style.SpaceInEmptyBlock = true; + Style.SpaceInEmptyBraces = FormatStyle::SIEBO_Custom;

[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-06-09 Thread Owen Pan via cfe-commits
owenca wrote: > See [#93635 > (comment)](https://github.com/llvm/llvm-project/issues/93635#issuecomment-2138778128). @khei4 maybe an `enum` for `SpaceInEmptyBraces` with `Always`, `Never`, and `Custom`. (IMO `Leave` doesn't make sense.) With `Custom`, a list of boolean suboptions e.g. `Functi

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-09 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/94560 ___ 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 indenting lambda trailing arrows (PR #94560)

2024-06-10 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/94560 ___ 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 indenting lambda trailing arrows (PR #94560)

2024-06-10 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/94560 ___ 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 indenting lambda trailing arrows (PR #94560)

2024-06-10 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/94560 ___ 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 annotating lambda l_square (PR #95084)

2024-06-11 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/95084 Fixes #95072. >From b89f8a5bcbf525d779565219951359162655929e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 11 Jun 2024 01:32:32 -0700 Subject: [PATCH] [clang-format] Fix a bug in annotating lambda l_square

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-11 Thread Owen Pan via cfe-commits
owenca wrote: > Am I right that no one has a major issue with the patch? So fixing the > "const" issue and adding a unit test will let that in? Can you add a unit test? https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-11 Thread Owen Pan via cfe-commits
owenca wrote: @mydeveloperday requested it. See https://github.com/llvm/llvm-project/pull/91317#pullrequestreview-2095010527. There are calls to `getStyle()` in `ConfigParseTest.cpp`. Maybe add a test there? https://github.com/llvm/llvm-project/pull/91317 _

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -584,6 +584,23 @@ TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) { EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator); } +TEST_F(TokenAnnotatorTest, UnderstandsTemplateTemplateParameters) { + auto Tokens = annotate("template typename X,\n" +

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -127,7 +127,7 @@ class AnnotatingParser { SmallVector &Scopes) : Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false), IsCpp(Style.isCpp()), LangOpts(getFormattingLangOpts(Style)), -Keywords(Keywords), Scopes(Scopes) {

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -1269,10 +1269,17 @@ class AnnotatingParser { if (CurrentToken && CurrentToken->is(tok::less)) { CurrentToken->setType(TT_TemplateOpener); next(); - if (!parseAngle()) + TemplateDeclarationDepth++; + if (!parseAngle()) { +TemplateDeclar

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -1269,10 +1269,17 @@ class AnnotatingParser { if (CurrentToken && CurrentToken->is(tok::less)) { CurrentToken->setType(TT_TemplateOpener); next(); - if (!parseAngle()) + TemplateDeclarationDepth++; + if (!parseAngle()) { +TemplateDeclar

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -584,6 +584,23 @@ TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) { EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator); } +TEST_F(TokenAnnotatorTest, UnderstandsTemplateTemplateParameters) { + auto Tokens = annotate("template typename X,\n" +

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -584,6 +584,23 @@ TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) { EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator); } +TEST_F(TokenAnnotatorTest, UnderstandsTemplateTemplateParameters) { + auto Tokens = annotate("template typename X,\n" +

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -584,6 +584,23 @@ TEST_F(TokenAnnotatorTest, UnderstandsNonTemplateAngleBrackets) { EXPECT_TOKEN(Tokens[20], tok::greater, TT_BinaryOperator); } +TEST_F(TokenAnnotatorTest, UnderstandsTemplateTemplateParameters) { + auto Tokens = annotate("template typename X,\n" +

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-11 Thread Owen Pan via cfe-commits
https://github.com/owenca deleted https://github.com/llvm/llvm-project/pull/95025 ___ 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 annotating lambda l_square (PR #95084)

2024-06-11 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/95084 >From b89f8a5bcbf525d779565219951359162655929e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 11 Jun 2024 01:32:32 -0700 Subject: [PATCH 1/2] [clang-format] Fix a bug in annotating lambda l_square Fixes #9507

[clang] [clang-format] Fix a bug in annotating lambda l_square (PR #95084)

2024-06-11 Thread Owen Pan via cfe-commits
@@ -1591,6 +1591,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) { EXPECT_TOKEN(Tokens[15], tok::arrow, TT_TrailingReturnArrow); EXPECT_TOKEN(Tokens[17], tok::l_brace, TT_LambdaLBrace); + Tokens = annotate("auto l = [] -> struct S { return {}; };");

[clang] [clang-format] Fix a bug in annotating lambda l_square (PR #95084)

2024-06-12 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/95084 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-12 Thread Owen Pan via cfe-commits
@@ -1269,10 +1269,17 @@ class AnnotatingParser { if (CurrentToken && CurrentToken->is(tok::less)) { CurrentToken->setType(TT_TemplateOpener); next(); - if (!parseAngle()) + TemplateDeclarationDepth++; + if (!parseAngle()) { +TemplateDeclar

[clang] [clang-format] Don't over-indent comment below unbraced body (PR #95354)

2024-06-12 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/95354 Fixes #45002. >From 02f1731d57d40e51605f667c8a0b1223b159e645 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 12 Jun 2024 22:04:17 -0700 Subject: [PATCH] [clang-format] Don't overindent comment below unbraced b

[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-12 Thread Owen Pan via cfe-commits
owenca wrote: @Erich-Reitz you were on the right track. See #95354. https://github.com/llvm/llvm-project/pull/94776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95503)

2024-06-13 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/95503 Closes #95094. >From 6684ed759ce118bb28e9da22be51bcfece2a1909 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 13 Jun 2024 21:25:08 -0700 Subject: [PATCH] [clang-format] Handle AttributeMacro before access modi

[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)

2024-06-13 Thread Owen Pan via cfe-commits
@@ -1269,10 +1269,17 @@ class AnnotatingParser { if (CurrentToken && CurrentToken->is(tok::less)) { CurrentToken->setType(TT_TemplateOpener); next(); - if (!parseAngle()) + TemplateDeclarationDepth++; + if (!parseAngle()) { +TemplateDeclar

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
@@ -4027,12 +4031,10 @@ Expected getStyle(StringRef StyleName, StringRef FileName, // Reset possible inheritance Style.InheritsParentConfig = false; - auto dropDiagnosticHandler = [](const llvm::SMDiagnostic &, void *) {}; - auto applyChildFormatTexts = [&](FormatStyl

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
@@ -4027,12 +4031,10 @@ Expected getStyle(StringRef StyleName, StringRef FileName, // Reset possible inheritance Style.InheritsParentConfig = false; - auto dropDiagnosticHandler = [](const llvm::SMDiagnostic &, void *) {}; - owenca wrote: Sorry! We do n

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
@@ -1452,6 +1452,35 @@ TEST(ConfigParseTest, GetStyleOfSpecificFile) { ASSERT_EQ(*Style, getGoogleStyle()); } +TEST(ConfigParseTest, GetStyleOutput) { +// With output +::testing::internal::CaptureStderr(); +llvm::vfs::InMemoryFileSystem FS; +auto Style = getS

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
@@ -1452,6 +1452,35 @@ TEST(ConfigParseTest, GetStyleOfSpecificFile) { ASSERT_EQ(*Style, getGoogleStyle()); } +TEST(ConfigParseTest, GetStyleOutput) { +// With output +::testing::internal::CaptureStderr(); +llvm::vfs::InMemoryFileSystem FS; +auto Style = getS

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

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

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
@@ -1452,6 +1452,35 @@ TEST(ConfigParseTest, GetStyleOfSpecificFile) { ASSERT_EQ(*Style, getGoogleStyle()); } +TEST(ConfigParseTest, GetStyleOutput) { +// With output +::testing::internal::CaptureStderr(); +llvm::vfs::InMemoryFileSystem FS; +auto Style = getS

[clang] [clang-format] Don't over-indent comment below unbraced body (PR #95354)

2024-06-14 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/95354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/91317 >From c1e0ad6ee57a95fa4321bbe91aa754167da9fb3b Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Tue, 7 May 2024 12:27:29 +0200 Subject: [PATCH 1/2] [clang-format] Add DiagHandler for getStyle function It al

[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/91317 >From c1e0ad6ee57a95fa4321bbe91aa754167da9fb3b Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Tue, 7 May 2024 12:27:29 +0200 Subject: [PATCH 1/3] [clang-format] Add DiagHandler for getStyle function It al

[clang] [clang-format] Add DiagHandler parameter to format::getStyle() (PR #91317)

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

[clang] [clang-format] Add DiagHandler parameter to format::getStyle() (PR #91317)

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

[clang] [clang-format] Add DiagHandler parameter to format::getStyle() (PR #91317)

2024-06-14 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/91317 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95634)

2024-06-14 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/95634 Closes #95094. >From 1c4ab4a5fd869de44795abd48bbaa43176e7275e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 14 Jun 2024 23:36:58 -0700 Subject: [PATCH] [clang-format] Handle AttributeMacro before access modi

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95503)

2024-06-14 Thread Owen Pan via cfe-commits
@@ -57,7 +57,10 @@ class LevelIndentTracker { /// Update the indent state given that \p Line is going to be formatted /// next. void nextLine(const AnnotatedLine &Line) { -Offset = getIndentOffset(*Line.First); +const auto *Tok = Line.First; +if (Tok->is(TT_At

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95634)

2024-06-15 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/95634 >From 1c4ab4a5fd869de44795abd48bbaa43176e7275e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 14 Jun 2024 23:36:58 -0700 Subject: [PATCH 1/2] [clang-format] Handle AttributeMacro before access modifiers Clos

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95634)

2024-06-16 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/95634 >From 1c4ab4a5fd869de44795abd48bbaa43176e7275e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 14 Jun 2024 23:36:58 -0700 Subject: [PATCH 1/3] [clang-format] Handle AttributeMacro before access modifiers Clos

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95634)

2024-06-16 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/95634 >From 1c4ab4a5fd869de44795abd48bbaa43176e7275e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 14 Jun 2024 23:36:58 -0700 Subject: [PATCH 1/4] [clang-format] Handle AttributeMacro before access modifiers Clos

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95634)

2024-06-16 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/95634 >From 1c4ab4a5fd869de44795abd48bbaa43176e7275e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 14 Jun 2024 23:36:58 -0700 Subject: [PATCH 1/5] [clang-format] Handle AttributeMacro before access modifiers Clos

[clang] [clang-format] Handle AttributeMacro before access modifiers (PR #95503)

2024-06-16 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/95503 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

<    2   3   4   5   6   7   8   9   10   11   >