[clang] [clang-format] Add SpacesInParensOption for attributes and filtering for repeated parens (PR #77522)

2024-01-20 Thread Owen Pan via cfe-commits
owenca wrote: > The code is [self-hosted](https://git.rtems.org/rtems/) and [mirrored on > GitHub](https://github.com/RTEMS/rtems) with a [documented style > guide](https://docs.rtems.org/branches/master/eng/coding-formatting.html). In > addition, I have been and will continue to be willing to

[clang] [clang-format] Handle templated elaborated type specifier in function… (PR #77013)

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

[clang] [clang-format] Handle templated elaborated type specifier in function… (PR #77013)

2024-01-20 Thread Owen Pan via cfe-commits
@@ -3873,6 +3873,9 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { const FormatToken &InitialToken = *FormatTok; nextToken(); + auto IsNonMacroIdentifier = [](FormatToken *Tok) { owenca wrote: Nit: ```suggestion auto IsNonMacroIdentifier =

[clang] [clang-format]: Fix formatting of if statements with BlockIndent (PR #77699)

2024-01-20 Thread Owen Pan via cfe-commits
@@ -768,15 +768,25 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // parenthesis by disallowing any further line breaks if there is no line // break after the opening parenthesis. Don't break if it doesn't conserve // columns. + const

[clang] [clang-format]: Fix formatting of if statements with BlockIndent (PR #77699)

2024-01-20 Thread Owen Pan via cfe-commits
@@ -768,15 +768,25 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // parenthesis by disallowing any further line breaks if there is no line // break after the opening parenthesis. Don't break if it doesn't conserve // columns. + const

[clang] [clang-format] Add SpacesInParensOption for attributes and filtering for repeated parens (PR #77522)

2024-01-20 Thread Owen Pan via cfe-commits
owenca wrote: > Covering all double parens in a single sub-option is not precise enough for > code bases that may want to have `__attribute__(( x ))` but also allow `if ( > ( x ) )`. We should not go overboard with supporting all kinds of options/suboptions imaginable. I don't think we should

[clang] [clang-format] Handle templated elaborated type specifier in function… (PR #77013)

2024-01-20 Thread Owen Pan via cfe-commits
@@ -14583,9 +14583,10 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) { verifyFormat("template <> struct X < 15, i<3 && 42 < 50 && 33 < 28> {};"); verifyFormat("int i = SomeFunction(a b);"); - // FIXME: - // This now gets parsed incorrectly as class definit

[clang] [clang-format] Fix poor spacing in `AlignArrayOfStructures: Left` (PR #77868)

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

[clang] [clang-format] Fix poor spacing in `AlignArrayOfStructures: Left` (PR #77868)

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

[clang] [clang-format] Fix poor spacing in `AlignArrayOfStructures: Left` (PR #77868)

2024-01-20 Thread Owen Pan via cfe-commits
@@ -1366,11 +1366,12 @@ void WhitespaceManager::alignArrayInitializersLeftJustified( auto &Cells = CellDescs.Cells; // Now go through and fixup the spaces. auto *CellIter = Cells.begin(); - // The first cell needs to be against the left brace. - if (Changes[CellIter->I

[clang] [clang-format] Add MainIncludeChar option. (PR #78752)

2024-01-20 Thread Owen Pan via cfe-commits
@@ -0,0 +1,27 @@ +// Test the combination of regrouped include directives, via regexes and owenca wrote: > Ok I will move them there, thanks :) Should I remove these lit tests or are > they complementary? Please remove them from the lit tests. https://github.c

[clang] [llvm] [clang-tools-extra] [clang-format] Option to ignore macro definitions (PR #70338)

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

[clang] [clang-format] Add SkipMacroDefinitionBody option (PR #78682)

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

[clang] [clang-format] Add SkipMacroDefinitionBody option (PR #78682)

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

[clang] [clang-format] Add SkipMacroDefinitionBody option (PR #78682)

2024-01-19 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/78682 Closes #67991. Co-authored-by: @tomekpaszek >From 620e614b242055c3b8cbd81efd9bbc64a0ee4e56 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 18 Jan 2024 23:34:13 -0800 Subject: [PATCH] [clang-format] Option to

[clang-tools-extra] [clang] [llvm] [clang-format] Option to ignore macro definitions (PR #70338)

2024-01-18 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/70338 >From 25ca978ef9caf372997f2ebf227fb2b2ca443aa0 Mon Sep 17 00:00:00 2001 From: Tomek Paszek Date: Sat, 11 Nov 2023 19:38:00 +0100 Subject: [PATCH 01/15] Added an option to ignore macro definitions. --- clang/incl

[clang] [clang-format] adds a space after not inside macros (PR #78176)

2024-01-16 Thread Owen Pan via cfe-commits
owenca wrote: This should work: ``` --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -4402,9 +4402,17 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if (Left.Finalized) return Right.hasWhitespaceBefore(); - // Never ever me

[clang] [clang-format] adds a space after not inside macros (PR #78176)

2024-01-15 Thread Owen Pan via cfe-commits
owenca wrote: > I think this is kind of too specific. +1. > Also I agree with [#78166 > (comment)](https://github.com/llvm/llvm-project/issues/78166#issuecomment-1892311219) > that `WhitespaceSensitiveMacros` should be used. I don't think we should require that the option be used. https://g

[clang] [clang-format] adds a space after not inside macros (PR #78176)

2024-01-15 Thread Owen Pan via cfe-commits
@@ -4842,7 +4842,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, return true; } if (Left.is(TT_UnaryOperator)) { -if (Right.isNot(tok::l_paren)) { +if (!Right.isOneOf(tok::r_paren, tok::l_paren, tok::exclaim)) { owenca

[clang] [clang-format][NFC] Use FileCheck for clang-format-ignore lit test (PR #77977)

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

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-12 Thread Owen Pan via cfe-commits
owenca wrote: See #77977. https://github.com/llvm/llvm-project/pull/76733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Use FileCheck for clang-format-ignore lit test (PR #77977)

2024-01-12 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/77977 None >From 4f516c1ee4ab99af2c3135ca161a82e6428d3ee9 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 12 Jan 2024 12:30:17 -0800 Subject: [PATCH] [clang-format][NFC] Use FileCheck for clang-format-ignore lit te

[clang] [clang-format] Handle possible crash in `getCells` (PR #77723)

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

[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

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

[clang] [clang-format] Add SpaceInParensOption for __attribute__ keyword (PR #77522)

2024-01-11 Thread Owen Pan via cfe-commits
owenca wrote: > The __attribute((specifier-list)) currently is formatted based on the > SpacesInParensOptions.Other (previously, SpacesInParentheses). This change > allows finer control over addition of spaces between the consecutive parens, > and between the inner parens and the list of attri

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-10 Thread Owen Pan via cfe-commits
owenca wrote: > This still breaks tests on win: http://45.33.8.238/win/88113/step_7.txt I didn't get any email for the failure. Is this a regular LLVM buildbot? If it chokes on `grep -Fx`, can you (or whoever has access to it) install a POSIX-compliant grep? It seems all other Windows buildbot

[clang] [clang-format] Don't allow casts in front of ampamp (PR #77704)

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

[clang] [clang-format] Handle possible crash in `getCells` (PR #77723)

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

[clang] [clang-format] Fix crash involving array designators (PR #77045)

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

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-10 Thread Owen Pan via cfe-commits
owenca wrote: > While I was trying to find a minimal reproducer to the bug, I accidentally > found that this patch fix another crash, and doesn't fix the linked issue. Can you open another pull request to [fix](https://github.com/llvm/llvm-project/pull/77045#discussion_r1442578220) the other

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

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

[clang] [clang-format] Don't apply severe penalty if no possible column formats (PR #76675)

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

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

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

[clang] [clang-format] Do not update cursor pos if no includes replacement (PR #77456)

2024-01-10 Thread Owen Pan via cfe-commits
owenca wrote: > The change is done 👍 Is the code formatting check broken? See [here](https://github.com/llvm/llvm-project/pull/76059#issuecomment-1865850011). https://github.com/llvm/llvm-project/pull/77456 ___ cfe-commits mailing list cfe-commits@li

[clang] c69ec70 - [clang-format][NFC] Don't use clang-format style in config files

2024-01-10 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2024-01-10T00:58:35-08:00 New Revision: c69ec700adec315b3daa55742f2ef655242fa297 URL: https://github.com/llvm/llvm-project/commit/c69ec700adec315b3daa55742f2ef655242fa297 DIFF: https://github.com/llvm/llvm-project/commit/c69ec700adec315b3daa55742f2ef655242fa297.diff LOG:

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-10 Thread Owen Pan via cfe-commits
owenca wrote: Relanded as b53628a52d19. (See [here](https://github.com/llvm/llvm-project/commit/42ec976184acd40436acd7104ad715c60ca3e7ed#commitcomment-136674701)). https://github.com/llvm/llvm-project/pull/76733 ___ cfe-commits mailing list cfe-commit

[clang] b53628a - Reland "[clang-format] Optimize processing .clang-format-ignore files"

2024-01-09 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2024-01-09T21:34:21-08:00 New Revision: b53628a52d1947c51e250d6fa4ff5dd12b737aa0 URL: https://github.com/llvm/llvm-project/commit/b53628a52d1947c51e250d6fa4ff5dd12b737aa0 DIFF: https://github.com/llvm/llvm-project/commit/b53628a52d1947c51e250d6fa4ff5dd12b737aa0.diff LOG:

[clang] [clang-format] Fix crash involving array designators (PR #77045)

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

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -2315,6 +2315,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (Next->is(tok::greater)) return false; } + if (tok::isLiteral(FormatTok->Tok.getKind())) +return false; owenca wrote: You are right! Then how about the following

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -1079,6 +1079,7 @@ clang-format - Add ``ObjCPropertyAttributeOrder`` which can be used to sort ObjC property attributes (like ``nonatomic, strong, nullable``). - Add ``.clang-format-ignore`` files. +- Add ``AlignFunctionPointers`` sub-option for ``AlignConsecutiveDeclarat

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

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

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -255,6 +255,41 @@ TEST_F(FormatTestMacroExpansion, Style); } +TEST_F(FormatTestMacroExpansion, CommaAsOperator) { + FormatStyle Style = getGoogleStyle(); + Style.ColumnLimit = 42; + Style.Macros.push_back("MACRO(a, b, c)=a=(b); if(x) c"); + veri

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -255,6 +255,41 @@ TEST_F(FormatTestMacroExpansion, Style); } +TEST_F(FormatTestMacroExpansion, CommaAsOperator) { + FormatStyle Style = getGoogleStyle(); + Style.ColumnLimit = 42; + Style.Macros.push_back("MACRO(a, b, c)=a=(b); if(x) c"); + veri

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -255,6 +255,41 @@ TEST_F(FormatTestMacroExpansion, Style); } +TEST_F(FormatTestMacroExpansion, CommaAsOperator) { + FormatStyle Style = getGoogleStyle(); + Style.ColumnLimit = 42; + Style.Macros.push_back("MACRO(a, b, c)=a=(b); if(x) c"); + veri

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -255,6 +255,41 @@ TEST_F(FormatTestMacroExpansion, Style); } +TEST_F(FormatTestMacroExpansion, CommaAsOperator) { + FormatStyle Style = getGoogleStyle(); + Style.ColumnLimit = 42; + Style.Macros.push_back("MACRO(a, b, c)=a=(b); if(x) c"); + veri

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -255,6 +255,41 @@ TEST_F(FormatTestMacroExpansion, Style); } +TEST_F(FormatTestMacroExpansion, CommaAsOperator) { + FormatStyle Style = getGoogleStyle(); + Style.ColumnLimit = 42; owenca wrote: ```suggestion FormatStyle Style =

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Owen Pan via cfe-commits
owenca wrote: Please add an assertion in `WhitespaceManager.h`: ``` --- a/clang/lib/Format/WhitespaceManager.h +++ b/clang/lib/Format/WhitespaceManager.h @@ -282,6 +282,7 @@ private: for (auto PrevIter = Start; PrevIter != End; ++PrevIter) { // If we broke the line the initial spaces

[clang] [clang-format] Fix crash involving array designators (PR #77045)

2024-01-09 Thread Owen Pan via cfe-commits
@@ -2315,6 +2315,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() { if (Next->is(tok::greater)) return false; } + if (tok::isLiteral(FormatTok->Tok.getKind())) +return false; owenca wrote: ```suggestion ``` Instead, I would change l

[clang] [clang-format] Don't apply severe penalty if no possible column formats (PR #76675)

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

[clang] [clang-format] Fix crash involving array designators and dangling comma (PR #77045)

2024-01-08 Thread Owen Pan via cfe-commits
@@ -1444,16 +1444,26 @@ WhitespaceManager::CellDescriptions WhitespaceManager::getCells(unsigned Start, } else if (C.Tok->is(tok::comma)) { if (!Cells.empty()) Cells.back().EndIndex = i; -if (C.Tok->getNextNonComment()->isNot(tok::r_brace)) // d

[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-08 Thread Owen Pan via cfe-commits
@@ -8498,9 +8498,6 @@ TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) { "__attribute__((unused));"); Style = getGoogleStyle(); - ASSERT_THAT(Style.AttributeMacros, owenca wrote: Please also delete line 10: ``` #include

[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-08 Thread Owen Pan via cfe-commits
@@ -2209,7 +2209,8 @@ class AnnotatingParser { (!NextNonComment && !Line.InMacroBody) || (NextNonComment && (NextNonComment->isPointerOrReference() || - NextNonComment->isOneOf(tok::identifier, tok::string_literal { + (Line.InPragm

[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

2024-01-08 Thread Owen Pan via cfe-commits
owenca wrote: > > can you also add a test to clang/unittests/Format/TokenAnnotatorTest.cpp > > that ensures trailing attribute-like macros receive `StartOfName` > > annotation to make sure we don't regress the signal in the future? > > ok, that opened a whole can of worms. > > ``` > Tokens =

[clang] [Format] Fix isStartOfName to recognize attributes (PR #76804)

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

[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

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

[clang] [clang-format] Fix crash involving array designators and dangling comma (PR #77045)

2024-01-08 Thread Owen Pan via cfe-commits
@@ -1444,16 +1444,26 @@ WhitespaceManager::CellDescriptions WhitespaceManager::getCells(unsigned Start, } else if (C.Tok->is(tok::comma)) { if (!Cells.empty()) Cells.back().EndIndex = i; -if (C.Tok->getNextNonComment()->isNot(tok::r_brace)) // d

[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -2499,6 +2499,15 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[6], BK_Block); } +TEST_F(TokenAnnotatorTest, StreamOperator) { + auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";"); + ASSERT_EQ(Tokens.size(), 9u) << Tokens; + EXPE

[clang] [clang-tools-extra] [llvm] [mlir] [emacs] Fix Emacs library formatting (PR #76110)

2024-01-06 Thread Owen Pan via cfe-commits
owenca wrote: @darkfeline I'm ok with adding the Version comment in clang/tools/clang-format/clang-format.el, but you may have to explicitly request others to review the rest of the patch. https://github.com/llvm/llvm-project/pull/76110 ___ cfe-commi

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -76,40 +76,49 @@ template <> struct MappingTraits { FormatStyle::AlignConsecutiveStyle( {/*Enabled=*/false, /*AcrossEmptyLines=*/false, /*AcrossComments=*/false, /*AlignCompound=*/false, + /*AlignF

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -978,7 +978,14 @@ void WhitespaceManager::alignConsecutiveDeclarations() { AlignTokens( Style, - [](Change const &C) { + [&](Change const &C) { +if (Style.AlignConsecutiveDeclarations.AlignFunctionPointers) { + for (FormatToken *Prev = C.T

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -225,6 +225,22 @@ struct FormatStyle { /// bbb = 2; /// \endcode bool AlignCompound; +/// Only for ``AlignConsecutiveDeclarations``. Whether function pointers +/// are aligned. owenca wrote: ```suggestion /// Only for ``AlignConsec

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -76,40 +76,49 @@ template <> struct MappingTraits { FormatStyle::AlignConsecutiveStyle( {/*Enabled=*/false, /*AcrossEmptyLines=*/false, /*AcrossComments=*/false, /*AlignCompound=*/false, + /*AlignF

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

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

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -76,40 +76,49 @@ template <> struct MappingTraits { FormatStyle::AlignConsecutiveStyle( {/*Enabled=*/false, /*AcrossEmptyLines=*/false, /*AcrossComments=*/false, /*AlignCompound=*/false, + /*AlignF

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -76,40 +76,49 @@ template <> struct MappingTraits { FormatStyle::AlignConsecutiveStyle( {/*Enabled=*/false, /*AcrossEmptyLines=*/false, /*AcrossComments=*/false, /*AlignCompound=*/false, + /*AlignF

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
@@ -76,40 +76,49 @@ template <> struct MappingTraits { FormatStyle::AlignConsecutiveStyle( {/*Enabled=*/false, /*AcrossEmptyLines=*/false, /*AcrossComments=*/false, /*AlignCompound=*/false, + /*AlignF

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-06 Thread Owen Pan via cfe-commits
https://github.com/owenca commented: Please also update the release notes. LGTM otherwise. https://github.com/llvm/llvm-project/pull/69340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [clang-format]: Split alignment of declarations around assignment (PR #69340)

2024-01-05 Thread Owen Pan via cfe-commits
owenca wrote: > @owenca this waits for re-review Can you rebase the patch? https://github.com/llvm/llvm-project/pull/69340 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-05 Thread Owen Pan via cfe-commits
@@ -2499,6 +2499,15 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[6], BK_Block); } +TEST_F(TokenAnnotatorTest, StreamOperator) { + auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";"); + ASSERT_EQ(Tokens.size(), 9u) << Tokens; + EXPE

[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-05 Thread Owen Pan via cfe-commits
@@ -5151,6 +5151,14 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, return true; if (Left.IsUnterminatedLiteral) return true; + // FIXME: Breaking after newlines seems useful in general. Turn this into an + // option and recognize more cases like

[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-05 Thread Owen Pan via cfe-commits
@@ -2499,6 +2499,15 @@ TEST_F(TokenAnnotatorTest, BraceKind) { EXPECT_BRACE_KIND(Tokens[6], BK_Block); } +TEST_F(TokenAnnotatorTest, StreamOperator) { + auto Tokens = annotate("\"foo\\n\" << aux << \"foo\\n\" << \"foo\";"); + ASSERT_EQ(Tokens.size(), 9u) << Tokens; + EXPE

[clang] [clang-format] Break after string literals with trailing line breaks (PR #76795)

2024-01-05 Thread Owen Pan via cfe-commits
@@ -5151,6 +5151,14 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, return true; if (Left.IsUnterminatedLiteral) return true; + // FIXME: Breaking after newlines seems useful in general. Turn this into an + // option and Recognize more cases like

[clang] [clang-format] Fix crash involving array designators and dangling comma (PR #77045)

2024-01-05 Thread Owen Pan via cfe-commits
@@ -1444,7 +1444,8 @@ WhitespaceManager::CellDescriptions WhitespaceManager::getCells(unsigned Start, } else if (C.Tok->is(tok::comma)) { if (!Cells.empty()) Cells.back().EndIndex = i; -if (C.Tok->getNextNonComment()->isNot(tok::r_brace)) // dan

[clang] [clang-format] Fix crash involving array designators and dangling comma (PR #77045)

2024-01-05 Thread Owen Pan via cfe-commits
@@ -21084,6 +21084,12 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) { "};", Style); + verifyNoCrash("Foo f[] = {\n" +"[0] = { 1, },\n" +"[1] { 1, },\n" +"};", +Style); -

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2024-01-04 Thread Owen Pan via cfe-commits
owenca wrote: Actually, it's commit 42ec976184ac. Please see [here](https://github.com/llvm/llvm-project/pull/76733#issuecomment-1876707005). https://github.com/llvm/llvm-project/pull/76327 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-04 Thread Owen Pan via cfe-commits
owenca wrote: It had passed my local tests (x64 Native Tools Command Prompt for VS 2022) and the buildkite win build, so I wonder if it has something to do with the grep in the failed buildbot (only https://lab.llvm.org/buildbot/#/builders/123/builds/23808 so far) as I only used the POSIX opt

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

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

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-03 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/76733 >From 7f8da18dc59706df8f1ee15d22076b4794881579 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Mon, 1 Jan 2024 19:10:30 -0800 Subject: [PATCH 1/2] [clang-format] Optimize processing .clang-format-ignore files Reus

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

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

[clang] [clang-format] Optimize processing .clang-format-ignore files (PR #76733)

2024-01-02 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/76733 Reuse the patterns governing the previous input file being formatted if the the current input file is from the same directory. >From 7f8da18dc59706df8f1ee15d22076b4794881579 Mon Sep 17 00:00:00 2001 From: Owen Pa

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2023-12-31 Thread Owen Pan via cfe-commits
@@ -2919,6 +2912,12 @@ class ExpressionParser { void addFakeParenthesis(FormatToken *Start, prec::Level Precedence, FormatToken *End = nullptr) { +// Do not assign fake parenthesis to tokens that are part of an +// unexpanded macro call. The

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2023-12-31 Thread Owen Pan via cfe-commits
@@ -255,6 +255,44 @@ TEST_F(FormatTestMacroExpansion, Style); } +TEST_F(FormatTestMacroExpansion, CommaAsOperator) { + FormatStyle Style = getGoogleStyle(); + Style.Macros.push_back("ASSIGN_OR_RETURN(a, b, c)=a=(b); if(x) c"); + verifyFormat(R"(ASSI

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2023-12-31 Thread Owen Pan via cfe-commits
@@ -255,6 +255,44 @@ TEST_F(FormatTestMacroExpansion, Style); } +TEST_F(FormatTestMacroExpansion, CommaAsOperator) { + FormatStyle Style = getGoogleStyle(); + Style.Macros.push_back("ASSIGN_OR_RETURN(a, b, c)=a=(b); if(x) c"); + verifyFormat(R"(ASSI

[clang] [ClangFormat] Fix formatting bugs. (PR #76245)

2023-12-31 Thread Owen Pan via cfe-commits
@@ -416,10 +421,15 @@ struct FormatToken { /// to another one please use overwriteFixedType, or even better remove the /// need to reassign the type. void setFinalizedType(TokenType T) { +if (MacroCtx && MacroCtx->Role == MR_UnexpandedArg) + return; + ---

[clang] bd3d358 - [clang-format][doc] Add the link to POSIX 2.13

2023-12-30 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2023-12-30T01:32:10-08:00 New Revision: bd3d358ec68f686a280ae628f9074fdff1f10fe9 URL: https://github.com/llvm/llvm-project/commit/bd3d358ec68f686a280ae628f9074fdff1f10fe9 DIFF: https://github.com/llvm/llvm-project/commit/bd3d358ec68f686a280ae628f9074fdff1f10fe9.diff LOG:

[clang] fe2e677 - [clang-format][doc] Add .clang-format-ignore to the release notes

2023-12-29 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2023-12-29T23:12:16-08:00 New Revision: fe2e677aa7aebedd316b1a688db8410855a213c1 URL: https://github.com/llvm/llvm-project/commit/fe2e677aa7aebedd316b1a688db8410855a213c1 DIFF: https://github.com/llvm/llvm-project/commit/fe2e677aa7aebedd316b1a688db8410855a213c1.diff LOG:

[clang] 3507959 - [clang-format][doc] Fix format errors.

2023-12-29 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2023-12-29T22:52:07-08:00 New Revision: 3507959e441ed9470818e7c6ef16d9bbcfe6a999 URL: https://github.com/llvm/llvm-project/commit/3507959e441ed9470818e7c6ef16d9bbcfe6a999 DIFF: https://github.com/llvm/llvm-project/commit/3507959e441ed9470818e7c6ef16d9bbcfe6a999.diff LOG:

[clang] ca8441d - [clang-format][NFC] Fix a typo.

2023-12-29 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2023-12-29T19:47:08-08:00 New Revision: ca8441d6dbd36003288ef412295e7b946a8bb893 URL: https://github.com/llvm/llvm-project/commit/ca8441d6dbd36003288ef412295e7b946a8bb893 DIFF: https://github.com/llvm/llvm-project/commit/ca8441d6dbd36003288ef412295e7b946a8bb893.diff LOG:

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

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

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2023-12-29 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/76327 >From 4afd12db61528b40d842a7fbee9af37c2235822c Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 24 Dec 2023 01:18:55 -0800 Subject: [PATCH 1/9] [clang-format] Add .clang-format.ignore for ignoring files Closes

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2023-12-29 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/76327 >From 4afd12db61528b40d842a7fbee9af37c2235822c Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 24 Dec 2023 01:18:55 -0800 Subject: [PATCH 1/8] [clang-format] Add .clang-format.ignore for ignoring files Closes

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2023-12-29 Thread Owen Pan via cfe-commits
@@ -570,6 +571,70 @@ static int dumpConfig(bool IsSTDIN) { return 0; } +// Check whether `FilePath` is ignored according to the nearest +// .clang-format-ignore file based on the rules below: +// - A blank line is skipped. +// - Leading and trailing spaces of a line are trim

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2023-12-29 Thread Owen Pan via cfe-commits
@@ -570,6 +571,70 @@ static int dumpConfig(bool IsSTDIN) { return 0; } +// Check whether `FilePath` is ignored according to the nearest +// .clang-format-ignore file based on the rules below: +// - A blank line is skipped. +// - Leading and trailing spaces of a line are trim

[clang] [clang-format] Fix bad indentation with attribute and templated type (PR #76336)

2023-12-29 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/76336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix bad indentation with attribute and templated type (PR #76336)

2023-12-28 Thread Owen Pan via cfe-commits
@@ -26492,6 +26492,10 @@ TEST_F(FormatTest, BreakAfterAttributes) { verifyFormat("[[nodiscard]]\n" "Foo& operator-(Foo&);", Style); + + verifyFormat("[[maybe_unused]]\n" + "foo f;", owenca wrote: ```suggestion

[clang] [clang-format] Fix bad indentation with attribute and templated type (PR #76336)

2023-12-28 Thread Owen Pan via cfe-commits
@@ -26492,6 +26492,10 @@ TEST_F(FormatTest, BreakAfterAttributes) { verifyFormat("[[nodiscard]]\n" "Foo& operator-(Foo&);", Style); + + verifyFormat("[[maybe_unused]]\n" + "foo f;", + Style); owenca w

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2023-12-28 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/76327 >From 4afd12db61528b40d842a7fbee9af37c2235822c Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 24 Dec 2023 01:18:55 -0800 Subject: [PATCH 1/7] [clang-format] Add .clang-format.ignore for ignoring files Closes

[clang] [clang-format] Add .clang-format-ignore for ignoring files (PR #76327)

2023-12-28 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/76327 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add .clang-format.ignore for ignoring files (PR #76327)

2023-12-28 Thread Owen Pan via cfe-commits
@@ -570,6 +571,74 @@ static int dumpConfig(bool IsSTDIN) { return 0; } +// Check whether `FilePath` is ignored according to the nearest +// .clang-format-ignore file based on the rules below: +// - A blank line is skipped. +// - Leading and trailing spaces of a line are trim

[clang] [clang-format] Add .clang-format.ignore for ignoring files (PR #76327)

2023-12-28 Thread Owen Pan via cfe-commits
@@ -570,6 +571,74 @@ static int dumpConfig(bool IsSTDIN) { return 0; } +// Check whether `FilePath` is ignored according to the nearest +// .clang-format-ignore file based on the rules below: +// - A blank line is skipped. +// - Leading and trailing spaces of a line are trim

<    6   7   8   9   10   11   12   13   14   15   >