[PATCH] D115967: [clang-format][NFC] Handle wrapping after => in mustBreakBefore()

2021-12-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1964-1965 } - if (FormatTok->is(TT_FatArrow)) { -nextToken(); -// Fat arrows can be followed by simple expressions or by child blocks -// in curly braces. -

[PATCH] D115967: [clang-format][NFC] Handle wrapping after => in mustBreakBefore()

2021-12-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 395544. owenpan added a comment. Removed more redundant code. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115967/new/ https://reviews.llvm.org/D115967 Files: clang/lib/Format/TokenAnnotator.cpp clang/lib/Format/UnwrappedLineParser.cpp

[PATCH] D116229: [clang-format] Add option to align pointers in C style casts differently

2021-12-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D116229#3208507 , @curdeius wrote: > Why this option is useful? Why would someone want to have a different > alignment in casts than in other places? > As such I'm opposed to introducing one more option. Is there any well >

[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

2021-12-24 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG8ea64d5585ec: [clang-format] Fix short enums getting wrapped even when denied (authored by yodaldevoid, committed by owenpan). Repository: rG

[PATCH] D116592: [clang-format] Missing space after cast in a macro

2022-01-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. LGTM except for the nit. Comment at: clang/lib/Format/TokenAnnotator.cpp:1887 + // parentheses, look past it as these might be chained casts. + if (LeftOfParens->is(tok::r_paren) && !LeftOfParens->is(TT_CastRParen)) { if

[PATCH] D115967: [clang-format][NFC] Handle wrapping after => in mustBreakBefore()

2021-12-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1955-1957 +if (Style.isCSharp() && FormatTok->is(TT_FatArrow) && +tryToParseChildBlock()) + continue; peterstys wrote: > owenpan wrote: > > peterstys wrote: > >

[PATCH] D115967: [clang-format][NFC] Handle wrapping after => in mustBreakBefore()

2021-12-21 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGb9f6e09b850a: [clang-format][NFC] Handle wrapping after = in mustBreakBefore() (authored by owenpan). Changed prior to commit:

[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

2021-12-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:398-400 + if (Tok && Tok->is(tok::kw_typedef)) +Tok = Tok->getNextNonComment(); + if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct)) { Nits: - It's

[PATCH] D116318: [clang-format][NFC] Fix a bug in getPreviousToken() in the parser

2021-12-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D116318#3211689 , @HazardyKnusperkeks wrote: > I'm against that patch. > >> Don't pay for what you don't use. > > We should not put the size check into every call. That's what you must do now **without **this patch, which

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/docs/ClangFormatStyleOptions.rst:3419 + if (isa(D)) { vs. if (isa(D)) { + for (auto *A : D.attrs()) { for (auto *A : D.attrs()) + if (shouldProcessAttr(A)) { if

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 396573. owenpan added a comment. Fixed a bug and added a test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/ https://reviews.llvm.org/D116316 Files: clang/docs/ClangFormatStyleOptions.rst clang/include/clang/Format/Format.h

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/docs/ClangFormatStyleOptions.rst:3398 +**RemoveBracesLLVM** (``Boolean``) :versionbadge:`clang-format 14` + Remove optional braces of control statements (``if``, ``else``, ``for``, MyDeveloperDay wrote: > Can

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2303 + assert(IfRightBrace->MatchingParen == IfLeftBrace); + IfLeftBrace->MatchingParen = nullptr; + IfRightBrace->MatchingParen = nullptr; HazardyKnusperkeks

[PATCH] D116318: [clang-format][NFC] Fix a bug in getPreviousToken() in the parser

2021-12-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D116318#3211258 , @curdeius wrote: > Wasn't assert enough? Could you add a test with code that provokes the > problem? This fix is an NFC, so there will be no (user) test case for it. :) The current behavior does not match

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:23224 + + EXPECT_EQ("if (a)\n" +" if (b)\n" owenpan wrote: > MyDeveloperDay wrote: > > any reason these can't be verifyFormats? > Did you mean to add the expected part

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked 2 inline comments as done. owenpan added a comment. In D116316#3211269 , @curdeius wrote: > Could you have a look at preceding reviews and see if there wasn't a similar > patch before? I conversed

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 396493. owenpan added a comment. Addresses review comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/ https://reviews.llvm.org/D116316 Files: clang/docs/ClangFormatStyleOptions.rst clang/include/clang/Format/Format.h

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2021-12-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked 4 inline comments as done. owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2173 +void UnwrappedLineParser::KeepAncestorBraces() { + const int MaxNestingLevels = 2; + const int Size = NestedTooDeep.size();

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 397184. owenpan added a comment. - Fixed a bug found by applying the patch on the entire `clang` source tree. - Added an exception: the braces are not removed if the right one is followed by a comment on the same line. - Updated an existing test case and

[PATCH] D116527: [clang-format] Fix indentation for array variables with alignment of consecutive assignments and declarations.

2022-01-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Unless the test cases are wrong, they should not be changed. The original test case looked correct to me as it was doing a continuation indent between `type{` and `}`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D115967: [clang-format][NFC] Handle wrapping after => in mustBreakBefore()

2021-12-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1955-1957 +if (Style.isCSharp() && FormatTok->is(TT_FatArrow) && +tryToParseChildBlock()) + continue; peterstys wrote: > It seems that this block could be

[PATCH] D115990: AlignConsecutiveDeclarations not working for 'const' keyword in JavsScript

2021-12-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:1875 +// const a = in JavaScript. +if (Style.isJavaScript() && PreviousNotConst->is(tok::kw_const)) + return true; MyDeveloperDay wrote: > owenpan wrote: > > curdeius

[PATCH] D114320: [clang-format] Extend AllowShortBlocksOnASingleLine for else blocks

2021-11-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. Should we add an if-else example to the documentation? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114320/new/ https://reviews.llvm.org/D114320

[PATCH] D114142: [clang-format] [PR52527] can join * with /* to form an outside of comment error C4138

2021-11-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. LGTM, though I'd like to see a test case for `* //`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D114142/new/ https://reviews.llvm.org/D114142 ___ cfe-commits mailing list

[PATCH] D114151: [clang-format] [C++20] [Module] clang-format couldn't recognize partitions

2021-11-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1057 + nextToken(); + do { +if (FormatTok->is(tok::colon)) { A `while (!eof())` or `while (FormatTok->isNot(tok::eof)` would be safer here just in case the last line is

[PATCH] D114073: [clang-format][NFC] Add a default value to parseBlock()

2021-11-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks. owenpan added a project: clang-format. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo

[PATCH] D114142: [clang-format] [PR52527] can join * with /* to form an outside of comment error C4138

2021-11-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D114142#3139756 , @MyDeveloperDay wrote: > I'm thinking that those cases are handled else where I was aware of that, but I didn't see `* //` was handled and tested explicitly. IMO, using `tok::comment` and adding a test

[PATCH] D114151: [clang-format] [C++20] [Module] clang-format couldn't recognize partitions

2021-11-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:3226 +// No space between module :. +if (Left.isOneOf(Keywords.kw_module, tok::kw_export, Keywords.kw_import) && +Right.is(TT_ModulePartitionColon)) You can remove

[PATCH] D114073: [clang-format][NFC] Add a default value to parseBlock()

2021-11-17 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGe852cc0d5a8f: [clang-format][NFC] Add a default value to parseBlock() (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE

[PATCH] D113369: [clang-format] Extend SpaceBeforeParens for requires

2021-11-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:3145-3148 + else { +assert(Left.is(TT_RequiresExpression)); +return Style.SpaceBeforeParensOptions.AfterRequiresExpression; + } Nit: remove `else`.

[PATCH] D114430: [clang-format] NFC - recent changes caused clang-format to no longer be clang-formatted.

2021-11-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D114430#3152609 , @HazardyKnusperkeks wrote: > In D114430#3151082 , @klimek wrote: > >> Thanks for cleaning up after me, and sorry for the mess - do y'all have >> clang-format set up

[PATCH] D114151: [clang-format] [C++20] [Module] clang-format couldn't recognize partitions

2021-11-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1055-1077 + while (FormatTok) { +if (FormatTok->is(tok::colon)) { + FormatTok->setType(TT_ModulePartitionColon); +} +// Handle import as we would an include statement +else

[PATCH] D114142: [clang-format] [PR52527] can join * with /* to form an outside of comment error C4138

2021-11-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:3219 + // of comment. + if (Left.is(tok::star) && Right.is(TT_BlockComment)) +return true; Isn't `tok::comment` better than `TT_BlockComment` if a space is also required

[PATCH] D114142: [clang-format] [PR52527] can join * with /* to form an outside of comment error C4138

2021-11-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:3219 + // of comment. + if (Left.is(tok::star) && Right.is(TT_BlockComment)) +return true; MyDeveloperDay wrote: > owenpan wrote: > > Isn't `tok::comment` better than

[PATCH] D109557: Adds a BlockIndent option to AlignAfterOpenBracket

2021-11-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/ContinuationIndenter.cpp:951 + if (PreviousNonComment && PreviousNonComment->is(tok::l_paren)) { +State.Stack.back().BreakBeforeClosingParen = HazardyKnusperkeks wrote: > Remove the braces I

[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D95168#3100969 , @MyDeveloperDay wrote: > In D95168#3099920 , @owenpan wrote: > >> In D95168#3099739 , @MyDeveloperDay >> wrote: >> >>> - Look

[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D95168#3100376 , @HazardyKnusperkeks wrote: > In D95168#3099920 , @owenpan wrote: > >> In D95168#3099739 , @MyDeveloperDay >> wrote: >> >>> -

[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-11-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D91949#2747412 , @krasimir wrote: > Do we have some widely used code style that requires the new option > (https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options)? I have the same question.

[PATCH] D113320: [clang-format] Address fixme

2021-11-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Looks okay. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3064-3068 + for (const auto : Line.Tokens) { +for (const auto : Node.Children) + printDebugInfo(ChildNode, "\nChild: "); + } Nit: elide braces.

[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D95168#3105340 , @MyDeveloperDay wrote: >> I already had an implementation of RemoveBraces for the LLVM style (minus >> some exceptions). > > Why not share the implementation in a review then we can combine them here. I want

[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D95168#3102511 , @MyDeveloperDay wrote: > Then this is definitely why we want to think about these now and NOT leave > them to a separate review after the Insert case is committed. We can just leave a placeholder for the

[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D95168#3102550 , @MyDeveloperDay wrote: > This is a demo of what I mean {https://reviews.llvm.org/D113000} you can see > its pretty aggressive, I could kind of imagine people wanting a little more > control > > Sometimes

[PATCH] D95168: [clang-format] Add InsertBraces option

2021-11-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D95168#3099739 , @MyDeveloperDay wrote: > - Look further into possible Removal (I have an idea for how this might be > possible, and super useful for LLVM where we don't like single if {} ), I'd > like to round out on this

[PATCH] D115738: [clang-format] Fix formatting of the code that follows C# Lambda Expressions

2021-12-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Thanks for factoring the code. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1872 // calling `addUnwrappedLine()` here causes odd parsing errors. FormatTok->MustBreakBefore = true; }

[PATCH] D115738: [clang-format] Fix formatting of the code that follows C# Lambda Expressions

2021-12-16 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. Thanks! LGTM other than the extraneous braces on lines 1859-1861. (See https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements.) Comment at:

[PATCH] D115879: [clang-format] extern with new line brace without indentation

2021-12-16 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:3819 + Style.IndentExternBlock = FormatStyle::IEBS_NoIndent; + verifyFormat("extern \"C\"\n{ /*13*/\n}", Style); + verifyFormat("extern \"C\"\n{\n" curdeius wrote: > I'd prefer

[PATCH] D115879: [clang-format] extern with new line brace without indentation

2021-12-16 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1282-1300 if (FormatTok->Tok.is(tok::string_literal)) { nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { +if (Style.BraceWrapping.AfterExternBlock) { +

[PATCH] D114583: [clang-format] Adjust braced list detection

2021-12-05 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGc41b3b0fa0f4: [clang-format] Adjust braced list detection (authored by cpplearner, committed by owenpan). Repository: rG LLVM Github Monorepo

[PATCH] D115738: [clang-format] Fix formatting of the code that follows C# Lambda Expressions

2021-12-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1870 // C# may break after => if the next character is a newline. if (Style.isCSharp() && Style.BraceWrapping.AfterFunction == true) { // calling

[PATCH] D115738: [clang-format] Code following C# Lambda Expressions has wrong formatting

2021-12-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2007 +if (FormatTok->is(tok::l_brace)) { + if (Style.isCSharp() && Style.BraceWrapping.AfterFunction == true) { +FormatTok->MustBreakBefore = true;

[PATCH] D115769: [clang-format] Remove spurious JSON binding when DisableFormat = true

2021-12-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a reviewer: owenpan. owenpan added a comment. Can you add a test case? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D115769/new/ https://reviews.llvm.org/D115769 ___ cfe-commits mailing

[PATCH] D115738: [clang-format] Code following C# Lambda Expressions has wrong formatting

2021-12-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2007 +if (FormatTok->is(tok::l_brace)) { + if (Style.isCSharp() && Style.BraceWrapping.AfterFunction == true) { +FormatTok->MustBreakBefore = true;

[PATCH] D115647: [clang-format] FixNamespaceComments does not understand namespace aliases

2021-12-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:185-189 + const FormatToken *Previous = AnnotatedLines[StartLineIndex - 1]->Last; + while (Previous && Previous->is(tok::comment)) { +Previous = Previous->Previous; +

[PATCH] D106112: [clang-format] Break an unwrapped line at a K C parameter decl

2021-07-19 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG9da70ab3d43c: [clang-format] Break an unwrapped line at a KR C parameter decl (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES

[PATCH] D106112: [clang-format] Break an unwrapped line at a K C parameter decl

2021-07-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D106112#2883301 , @curdeius wrote: > Looks okay, but I was wondering if we don't want to guard all K > changes behind e.g. ```Standard: Cpp78``, so as not to possibly introduce > strange bugs in newer modes. > It may be an

[PATCH] D106112: [clang-format] Break an unwrapped line at a K C parameter decl

2021-07-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: djasper, klimek, MyDeveloperDay, curdeius, HazardyKnusperkeks. owenpan added a project: clang-format. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Break an unwrapped line

[PATCH] D115060: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-01-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. > But I suspect it is the Assignment of the `PreviousLine` since this is not > existent every time. Yep! > So I see the following solutions: > > 1. Only name `NextLine`, and use `I[-1]`. > 2. `const auto HasPreviousLine = I != AnnotatedLines.begin(); const auto > =

[PATCH] D115060: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Moving the handling of empty record blocks might be NFC? Maybe option 4 for now and the refactoring in another patch? Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:288 +// Try to merge a control statement block with left brace unwrapped.

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D116316#3224591 , @MyDeveloperDay wrote: > Owen I think we should push ahead with this rather than D95168: > [clang-format] Add Insert/Remove Braces option > as I've looked at what you've

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 397783. owenpan added a comment. Fixing a couple of major bugs found by running check-clang plus minor bug fixes and cleanup: - In `parseLevel()`, `HasOpeningBrace` and `case tok::r_brace:` don't necessarily mean the tokens are `{` and `}`, respectively. -

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398415. owenpan added a comment. - Braces should not be removed if the single-statement block might wrap or is already wrapped. - Added test cases. - Did a final round of cleanup. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398419. owenpan added a comment. Fixed a bug and added a test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/ https://reviews.llvm.org/D116316 Files: clang/docs/ClangFormatStyleOptions.rst clang/docs/ReleaseNotes.rst

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:435-454 +bool UnwrappedLineParser::precededByCommentOrPPDirective() const { + const size_t size = Lines.size(); + if (size > 0 && Lines[size - 1].InPPDirective) +return true; +#if 1 +

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 399632. owenpan added a comment. - Rebased to main. - Addressed review comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/ https://reviews.llvm.org/D116316 Files: clang/docs/ClangFormatStyleOptions.rst

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 399869. owenpan added a comment. - Fixed a bug that missed braces in nested blocks. - Added a test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/ https://reviews.llvm.org/D116316 Files: clang/docs/ClangFormatStyleOptions.rst

[PATCH] D116859: [clang-format] Fix break being added to macro define with ColumnLimit: 0

2022-01-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:4810 + + verifyFormat("#define A LOOONG() LOOONG()\n", + ZeroColumn); Please remove the newline and

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/docs/ClangFormatStyleOptions.rst:3398 +**RemoveBracesLLVM** (``Boolean``) :versionbadge:`clang-format 14` + Remove optional braces of control statements (``if``, ``else``, ``for``, curdeius wrote: > owenpan

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. @MyDeveloperDay @curdeius I will land this patch if you have no more comments. :) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/ https://reviews.llvm.org/D116316 ___ cfe-commits mailing list

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398860. owenpan added a comment. This revision is now accepted and ready to land. - Removed unnecessary code and cleaned up. - Tested on `clang` and `check-clang` again. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/

[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/include/clang/Format/Format.h:3059 + /// and ``while``) in C++ according to the LLVM coding style. + /// \warning + /// This option will be renamed and expanded to support other styles! HazardyKnusperkeks

[PATCH] D115060: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-01-16 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:215 +const auto = *I[1]; +const auto *PreviousLine = I != AnnotatedLines.begin() ? I[-1] : nullptr; +if (NextLine.Type == LT_Invalid || NextLine.First->MustBreakBefore)

[PATCH] D115060: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-01-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:215 +const auto = *I[1]; +const auto *PreviousLine = I != AnnotatedLines.begin() ? I[-1] : nullptr; +if (NextLine.Type == LT_Invalid || NextLine.First->MustBreakBefore)

[PATCH] D117414: [clang-format] Add return code to git-clang-format

2022-01-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added a reviewer: MyDeveloperDay. owenpan added a project: clang-format. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. https://github.com/llvm/llvm-project/issues/53220 Repository: rG

[PATCH] D117414: [clang-format] Add return code to git-clang-format

2022-01-16 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGedbb8a843c13: [clang-format] Add return code to git-clang-format (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST

[PATCH] D116767: [clang-format] Fix `BraceWrapping: AfterFunction` affecting synchronized blocks in Java.

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. This revision is now accepted and ready to land. LGTM except for the nits. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1528 // for them (the one we know is missing are lambdas). -if

[PATCH] D116318: [clang-format][NFC] Fix a bug in getPreviousToken() in the parser

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D116318#3212351 , @curdeius wrote: > I'm in the same position as @hazardyknusperkeks. > If you need something to simplify the code you can add a helper > `getPreviousTokenOrNull` or something like that in your patch. > But we

[PATCH] D116795: [clang-format] Use range-for loops. NFC.

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/lib/Format/AffectedRangeManager.cpp:66 return true; } return false; Remove braces. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D116767: [clang-format] Fix `BraceWrapping: AfterFunction` affecting synchronized blocks in Java.

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1528 // for them (the one we know is missing are lambdas). -if (Style.BraceWrapping.AfterFunction) +if ((Style.Language == FormatStyle::LK_Java) && +

[PATCH] D119419: [clang-format] Do not remove required spaces when aligning tokens.

2022-02-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. This revision is now accepted and ready to land. Comment at: clang/lib/Format/WhitespaceManager.cpp:407 +// We should not remove required spaces unless we break the line before. +

[PATCH] D120931: [clang-format] Fix namespace format when the name is a macro expansion

2022-03-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. This revision is now accepted and ready to land. LGTM, but please wait for other reviewers in case they have more comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120931/new/

[PATCH] D120931: [clang-format] Fix namespace format when the name is a macro expansion

2022-03-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:59-60 + +// Use the string after `namespace` until `{` or `::` or `(` as a name +// candidate. If the name is empty, use the candicate. +std::string FirstNSName;

[PATCH] D120931: [clang-format] Fix namespace format when the name is a macro expansion

2022-03-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:45-54 + int NestLevel = 1; + while (Tok && NestLevel > 0) { +Tok = Tok->getNextNonComment(); +if (Tok) { + if (Tok->is(tok::l_square)) +

[PATCH] D121042: [clang-format] Handle goto labels for RemoveBracesLLVM

2022-03-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository:

[PATCH] D120774: [clang-format] Handle builtins in constraint expression

2022-03-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3163 +case tok::identifier: default: Do we still need this line? Comment at:

[PATCH] D120774: [clang-format] Handle builtins in constraint expression

2022-03-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3163 +case tok::identifier: default: cjdb wrote: > owenpan wrote: > > Do we still need this line? > I'd prefer to get rid of `default` if we can. We can't. It's the

[PATCH] D121042: [clang-format] Handle goto labels for RemoveBracesLLVM

2022-03-05 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG28b76b1e23bb: [clang-format] Handle goto labels for RemoveBracesLLVM (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121042/new/

[PATCH] D121559: [clang-format] Fix crash on asm block with label

2022-03-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:829 OpeningBrace.setType(TT_DictLiteral); +if (Style.isJavaScript()) + OpeningBrace.overwriteFixedType(TT_DictLiteral);

[PATCH] D121559: [clang-format] Fix crash on asm block with label

2022-03-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. This patch also fixed 4 out of 6 of the same assertion failures on the .c files under `clang/test`. The remaining two are: 1. Analysis/inline-plist.c (#54367 ) 2. Sema/attr-external-source-symbol.c (54368

[PATCH] D121576: [clang-format] Don't unwrap lines preceded by line comments

2022-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Fixes

[PATCH] D121434: [clang-format][NFC] Group QualifierAlignment with other C++ passes

2022-03-11 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG9f616a467fc7: [clang-format][NFC] Group QualifierAlignment with other C++ passes (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D121450: [clang-format] Handle attributes before case label.

2022-03-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:578 +break; + LLVM_FALLTHROUGH; Can we remove this empty line? Comment at:

[PATCH] D121576: [clang-format] Don't unwrap lines preceded by line comments

2022-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 415031. owenpan added a comment. Reset the `Spaces` of the closing brace only if it can be unwrapped. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121576/new/ https://reviews.llvm.org/D121576 Files: clang/lib/Format/WhitespaceManager.cpp

[PATCH] D121682: [clang-format] Fix crashes due to missing l_paren

2022-03-16 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG7fb2d9f9b5ef: [clang-format] Fix crashes due to missing l_paren (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121682/new/

[PATCH] D121757: [clang-format] Take out common code for parsing blocks

2022-03-16 Thread Owen Pan via Phabricator via cfe-commits
owenpan requested changes to this revision. owenpan added a comment. This revision now requires changes to proceed. Because this patch would impact inserting/removing braces, we must test it against a large codebase. Before I landed `RemoveBracesLLVM` and `InsertBraces`, I had tested them with

[PATCH] D121846: [clang-format] Correctly recognize binary operators in template arguments with parenthesized literals.

2022-03-16 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:2186 + NextNonParen = NextNonParen->getNextNonComment(); +} +if (NextNonParen && (NextNonParen->Tok.isLiteral() || Remove braces. :)

[PATCH] D121434: [clang-format][NFC] Group QualifierAlignment with other C++ passes

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 414572. owenpan added a comment. Swapped the order of the definitions of `BracesRemover` and `BracesInserter`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121434/new/ https://reviews.llvm.org/D121434 Files: clang/lib/Format/Format.cpp Index:

[PATCH] D121434: [clang-format][NFC] Group QualifierAlignment with other C++ passes

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Also

[PATCH] D121550: [clang-format] Fix crash on invalid requires expression

2022-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. After applying this patch, we got a different assertion failure on a bunch of files in `clang/test`, e.g.: ~/llvm-project/clang$ for f in $(find . -name \*.cpp -o -name \*.c) ; do clang-format $f > /dev/null ; done Assertion failed: (OpeningParen.is(tok::l_paren)),

[PATCH] D121576: [clang-format] Don't unwrap lines preceded by line comments

2022-03-14 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG0a0cc3c58a74: [clang-format] Dont unwrap lines preceded by line comments (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121576/new/

[PATCH] D121576: [clang-format] Don't unwrap lines preceded by line comments

2022-03-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121576#3378934 , @MyDeveloperDay wrote: > I'm wondering if the presence of the comment would impact the CellCount, I > might go back and add some more unit tests for the "non rectangular" change I > made. > > So this fixes

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