[PATCH] D121269: [clang-format] Fix namespace format when the name is followed by a macro

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:33 + llvm::function_ref Fn) { + if (!Tok || !Tok->is(StartTok)) +return Tok; And other places below where applicable. Comment at: clang/

[PATCH] D121269: [clang-format] Fix namespace format when the name is followed by a macro

2022-03-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:108 + // which one is name. For example, `namespace A B {`. + while (Tok && !Tok->is(tok::l_brace)) { +if (FirstNSTok) { ===

[PATCH] D121352: [clang-format] Handle "// clang-format off" for RemoveBracesLLVM

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

[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 increases

[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: c

[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 https://reviews.llvm.org/D121434/

[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: clang/lib/Format/UnwrappedLineParser.h

[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 https://

[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 clang

[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] Don't unwrap lines preceded by line comments (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121576/new/ h

[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

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

2022-03-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Nvm. See https://github.com/llvm/llvm-project/issues/54384. Comment at: clang/lib/Format/TokenAnnotator.cpp:216 FormatToken &OpeningParen = *CurrentToken->Previous; assert(OpeningParen.is(tok::l_paren)); FormatToken *PrevNonComment = Open

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

2022-03-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: HazardyKnusperkeks, curdeius, MyDeveloperDay. 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 https://

[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/ https://rev

[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. :) Repo

[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] D121749: [clang-format][docs] Regenerate ClangFormatStyleOptions.rst

2022-03-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/docs/ClangFormatStyleOptions.rst:361 - * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``. Whether compound -assignments like ``+=`` are aligned along with ``=``. + * ``bool AlignCompound`` Only for ``Align

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

2022-03-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121757#3389092 , @sstwcw wrote: > This patch is only intended to reduce the number of times the functionality > gets implemented separately. Any change in behavior would be unintended. > And we also use the `parseIndentedB

[PATCH] D121906: [clang-format] Indent import statements in JavaScript.

2022-03-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added subscribers: HazardyKnusperkeks, krasimir, MyDeveloperDay, curdeius, owenpan. owenpan added a comment. Please add @krasimir @MyDeveloperDay @curdeius @HazardyKnusperkeks to Reviewers. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D1219

[PATCH] D121907: [clang-format] Use an enum for context types.

2022-03-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added subscribers: HazardyKnusperkeks, MyDeveloperDay, curdeius, owenpan. owenpan added a comment. If this patch is an NFC, please add `[NFC]` to the title. Please add @MyDeveloperDay @curdeius @HazardyKnusperkeks to Reviewers. Comment at: clang/lib/Format/TokenAnnota

[PATCH] D121890: [clang-format] Copy help options to the doc directory.

2022-03-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a subscriber: krasimir. owenpan added a comment. In D121890#3389171 , @sstwcw wrote: > The issue is #54418. > > Actually I don't know who I should add as reviewers. The patches for > clang-format don't always seem to have the same reviewer

[PATCH] D121755: [clang-format] Join spaceRequiredBefore and spaceRequiredBetween

2022-03-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121755#3391606 , @MyDeveloperDay wrote: > This just made a 300 lines function and a 500 line function with minimal > comments into a 800 line function.. For no real benefit? > > Because from what I can tell you haven't worke

[PATCH] D121907: [clang-format] Use an enum for context types. NFC

2022-03-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. LGTM. Any comments, @curdeius? Comment at: clang/lib/Format/TokenAnnotator.cpp:116 // template parameter, not an argument. -Contexts.back().InTemplateArgument = -Left->Previous && Left->Previous->isNot(to

[PATCH] D120884: [format] Use int8_t as the underlying type of all enums in FormatStyle

2022-03-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. Should we also simplify the regex https://github.com/llvm/llvm-project/blob/a3248e4b28ce09c3a749ecae5378dd0b3a8d42b1/clang/docs/tools/dump_format_style.py#L263? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://re

[PATCH] D121756: [clang-format] Clean up code looking for if statements

2022-03-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan requested changes to this revision. owenpan added inline comments. Comment at: clang/lib/Format/ContinuationIndenter.cpp:749 + if (Current.isNot(tok::comment) && + Previous.isConditionLParen(/*IncludeSpecial=*/true)) { // Treat the condition inside an if as if

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/Format.cpp:2692-2695 + for (int i = Matches.size() - 1; i > 0; i--) { +if (!Matches[i].empty()) + return Matches[i]; + } I think you missed `Matches[0]`. Comment at: clang/l

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-03-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:176-188 const char IncludeRegexPattern[] = -R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))"; +R"(^[\t\ ]*[@#][\t\ ]*(import|include)([^"]*("[^"]+")|[^<]*(<[^>]+>)|[\t\

[PATCH] D122301: [clang-format] Fix invalid code generation with comments in lambda

2022-03-23 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: https:/

[PATCH] D122064: [clang-format][docs] Fix incorrect 'clang-format 11' option markers

2022-04-06 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG1cd43464091c: [clang-format][docs] Fix incorrect 'clang-format 11' option markers (authored by kuzkry, committed by owenpan). Changed prior to commit: https://reviews.llvm.org/D122064?vs=416684&id=4210

[PATCH] D121916: [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.

2022-04-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121916#3440831 , @sstwcw wrote: > It looks like you forgot to chmod +x. Added in f67e3f6 . Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTI

[PATCH] D123535: [clang-format] Allow empty .clang-format file

2022-04-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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] D123535: [clang-format] Allow empty .clang-format file

2022-04-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D123535#3443604 , @curdeius wrote: > I have stumbled on it myself several times but never really needed a fix. > Out of curiosity, what motivates you to do this change? I was playing with adding/removing some options in a .cla

[PATCH] D123571: [clang-format] Clean up unit tests for AlignArrayOfStructures

2022-04-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks, feg208. 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. As men

[PATCH] D123535: [clang-format] Allow empty .clang-format file

2022-04-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 422335. owenpan added a comment. Updated the affected clang test. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123535/new/ https://reviews.llvm.org/D123535 Files: clang/lib/Format/Format.cpp clang/test/Format/style-on-command-line.cpp Index:

[PATCH] D123535: [clang-format] Allow empty .clang-format file

2022-04-12 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 rG4e814a6f2db9: [clang-format] Allow empty .clang-format file (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D123535: [clang-format] Allow empty .clang-format file

2022-04-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 422373. owenpan added a comment. Updated command line tests. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123535/new/ https://reviews.llvm.org/D123535 Files: clang/lib/Format/Format.cpp clang/test/Format/style-on-command-line.cpp Index: clan

[PATCH] D121756: [clang-format] Clean up code looking for if statements

2022-04-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Please see D123741 . It should make it easier to see if you are making NFC changes at other places as well. Comment at: clang/lib/Format/TokenAnnotator.cpp:252-256 +} else if (OpeningParen.isConditionLParen(/*Inclu

[PATCH] D121756: [clang-format] Clean up code looking for if statements

2022-04-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:133-136 -(isKeywordWithCondition(*Line.First) || - CurrentToken->getStartOfNonWhitespace() == - CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(

[PATCH] D123676: [clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

2022-04-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1791 +tokenCanStartNewLine(*FormatTok) && Text == Text.upper() && +!PreviousToken->isTypeFinalized()) { PreviousToken->setFinalizedType(TT_FunctionLikeOrFreestan

[PATCH] D123676: [clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

2022-04-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/FormatTokenLexer.cpp:1031-1035 + if (it->second.Finalized) { +FormatTok->setFinalizedType(it->second.Type); + } else { +FormatTok->setType(it->second.Type); + } It seems we

[PATCH] D123676: [clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

2022-04-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1791 +tokenCanStartNewLine(*FormatTok) && Text == Text.upper() && +!PreviousToken->isTypeFinalized()) { PreviousToken->setFinalizedType(TT_FunctionLikeOrFreestan

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-04-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Should we handle `#import` and `@import` for Object-C only so as to simply the regex for C++? Comment at: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h:136 +/// #include +/// @include bar; +/// #include "bar.h" I think you m

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-04-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. LGTM as I defer to @MyDeveloperDay. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121370/new/ https://reviews.llvm.org/D121370 ___ cfe-commits mai

[PATCH] D124036: [clang-format] Don't skip PP lines if original line was a PP line when trying to merge lines

2022-04-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:310-313 for (; J != AnnotatedLines.begin(); --J) -if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level) +if ((TheLine->InPPDirective || !(*J)->InPPDirecti

[PATCH] D124152: [clang-format] Fix a crash on AllowShortFunctionsOnASingleLine

2022-04-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: aeubanks, curdeius, MyDeveloperDay, 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. Fixe

[PATCH] D123741: [clang-format][NFC] Clean up code in token annotator

2022-04-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 rG7343f768d144: [clang-format][NFC] Clean up code in token annotator (authored by owenpan). Herald added a project: clang. Herald added a subscriber: c

[PATCH] D124152: [clang-format] Fix a crash on AllowShortFunctionsOnASingleLine

2022-04-21 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG221c2b68ddc6: [clang-format] Fix a crash on AllowShortFunctionsOnASingleLine (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124152/new/

[PATCH] D124215: [clang-format][NFC] Use isComment() in setCommentLineLevels()

2022-04-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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 replace a

[PATCH] D118873: [clang-format] Revert a feature in RemoveBracesLLVM

2022-02-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, 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. Revert the handling of a single-statement b

[PATCH] D118873: [clang-format] Revert a feature in RemoveBracesLLVM

2022-02-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D118873#3292956 , @curdeius wrote: > Ok, so now (until a new fix), it will always remove the braces for a single > statement even if it's multi-line. That's fine. Yep. Repository: rG LLVM Github Monorepo CHANGES SINCE LA

[PATCH] D118873: [clang-format] Revert a feature in RemoveBracesLLVM

2022-02-03 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 rGeaef54f21388: [clang-format] Revert a feature in RemoveBracesLLVM (authored by owenpan). Changed prior to commit: https://reviews.llvm.org/D118873

[PATCH] D118879: [clang-format] Avoid merging macro definitions.

2022-02-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:1812 + Style.BraceWrapping.AfterFunction = true; + // Test that a macro definition gets never merged with the following + // definition. ===

[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, 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. The `l_brace` token in a macro definition s

[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 405881. owenpan added a comment. Added a test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D118969/new/ https://reviews.llvm.org/D118969 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Index

[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D118969#3295909 , @curdeius wrote: > Well, I thought about this approach but actually a macro line should never be > merged together with a preceding line, so I went for a generic approach. That's why I didn't say yours would

[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 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 rG35f7dd601d33: [clang-format][NFC] Fix a bug in setting type FunctionLBrace (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SIN

[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D118969#3297699 , @HazardyKnusperkeks wrote: > Ah because of a race condition, I couldn't accept anymore. :) Sorry! I should have waited a little longer. :D Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

[PATCH] D118991: [clang-format][docs] Fix incorrect 'clang-format 14' configuration options markers

2022-02-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 rG6cd0015e7827: [clang-format][docs] Fix incorrect 'clang-format 14' option markers (authored by kuzkry, committed by owenpan). Repository: rG LLVM

[PATCH] D119067: [clang-format] Fix DefinitionBlockSeparator extra empty lines

2022-02-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/DefinitionBlockSeparator.cpp:50-64 FormatToken *CurrentToken = Line->First; +int BracketLevel = 0; while (CurrentToken) { - if (CurrentToken->isOneOf(tok::kw_class, tok::kw_struct) || - (Style

[PATCH] D119117: [clang-format] Fix formatting of the array form of delete.

2022-02-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added inline comments. Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:94 +TEST_F(TokenAnnotatorTest, UnderstandsNewAndDelete) { + auto Tokens = annotate("delete (void *)p;"); The test name contains “new” and “

[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. +assert(Changes[i].NewlinesBefo

[PATCH] D119597: [clang-format][NFC] Give State.Stack.back() a meaningful name

2022-02-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/ContinuationIndenter.cpp:1514 + auto &CurrentState = State.Stack.back(); + Can you make it `const` here? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D

[PATCH] D119648: [clang-format] Fix PointerAlignment within lambdas in a multi-variable declaration statement.

2022-02-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Does any C++ standard support init statements in `while` loops? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119648/new/ https://reviews.llvm.org/D119648 ___ cfe-commits mailing

[PATCH] D119650: [clang-format] Handle PointerAlignment in `if` statements with initializers (C++17) the same way as in `for` loops.

2022-02-12 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/TokenAnnotator.cpp:31 +/// with an initializer. +static bool startsWithStatementWithInitializer(const AnnotatedLine &Line) { + return Line

[PATCH] D119648: [clang-format] Fix PointerAlignment within lambdas in a multi-variable declaration statement.

2022-02-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:8415-8417 + verifyFormat("if (int *p, *q; p != q) {\n p = p->next;\n}", Style); + verifyFormat("/*comment*/ if (int *p, *q; p != q) {\n p = p->next;\n}", + Style);

[PATCH] D124215: [clang-format][NFC] Use isComment() in setCommentLineLevels()

2022-04-22 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 rGc9e7eec7bc41: [clang-format][NFC] Use isComment() in setCommentLineLevels() (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SI

[PATCH] D124452: [clang-format] Adjust editor cursor position past #include blocks

2022-04-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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 https://

[PATCH] D124452: [clang-format] Adjust editor cursor position past #include blocks

2022-04-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 425376. owenpan added a comment. Updated the test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124452/new/ https://reviews.llvm.org/D124452 Files: clang/lib/Format/Format.cpp clang/unittests/Format/SortIncludesTest.cpp Index: clang/uni

[PATCH] D124452: [clang-format] Adjust editor cursor position past #include blocks

2022-04-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked an inline comment as done. owenpan added inline comments. Comment at: clang/unittests/Format/SortIncludesTest.cpp:895 + Style.IncludeBlocks = Style.IBS_Regroup; + std::string Code = "#include \"b\"\n" // Start of line: 0 + "\n"

[PATCH] D124452: [clang-format] Adjust editor cursor position past #include blocks

2022-04-27 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. owenpan marked an inline comment as done. Closed by commit rGdb57acff2647: [clang-format] Adjust editor cursor position past #include blocks (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST A

[PATCH] D124589: [clang-format] Fix a bug that misformats Access Specifier after *[]

2022-04-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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 https://

[PATCH] D124589: [clang-format] Fix a bug that misformats Access Specifier after *[]

2022-04-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 425710. owenpan added a comment. Also checks the token before `*` and adds a test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124589/new/ https://reviews.llvm.org/D124589 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/F

[PATCH] D124589: [clang-format] Fix a bug that misformats Access Specifier after *[]

2022-04-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D124589#3479241 , @curdeius wrote: > Looks more or less correct, but I am afraid that this change may misbehave in > some rare cases. > Consider `*[](auto *x) { return x; }();`, so an immediately invoked lambda > returning a

[PATCH] D124589: [clang-format] Fix a bug that misformats Access Specifier after *[]

2022-05-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 426307. owenpan added a comment. Instead of looking back, look ahead in `tryToParseLambdaIntroducer()`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124589/new/ https://reviews.llvm.org/D124589 Files: clang/lib/Format/UnwrappedLineParser.cpp c

[PATCH] D124589: [clang-format] Fix a bug that misformats Access Specifier after *[]

2022-05-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Now that we look ahead instead of looking back, it doesn't matter what comes before `*[]` or `[]`. Comment at: clang/unittests/Format/FormatTest.cpp:3342 + "public:\n" + " std::unique_ptr b() { return nullptr; }\n" +

[PATCH] D124589: [clang-format] Fix a bug that misformats Access Specifier after *[]

2022-05-02 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGc8603db0711e: [clang-format] Fix a bug that misformats Access Specifier after *[] (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124589

[PATCH] D124818: [clang-format][NFC] Clean up tryToParseLambdaIntroducer()

2022-05-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: HazardyKnusperkeks, curdeius, MyDeveloperDay. 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] D124818: [clang-format][NFC] Clean up tryToParseLambdaIntroducer()

2022-05-03 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG397188036d4c: [clang-format][NFC] Clean up tryToParseLambdaIntroducer() (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124818/new/ htt

[PATCH] D124868: [clang-format] Fix a bug in AlignConsecutiveAssignments

2022-05-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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 https://

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-05-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. > Now support @ and #.Clearly support "" and <> as ell as an `as well as`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121370/new/ https://reviews.llvm.org/D121370 _

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-05-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121370#3489245 , @krasimir wrote: > In D121370#3488401 , @kwk wrote: > >> @krasimir could you please test this patch on your side? > > @kwk thank you! the new version of the patch look

[PATCH] D124748: [clang-format] Fix whitespace counting stuff

2022-05-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Is this patch NFC? Comment at: clang/lib/Format/FormatTokenLexer.cpp:859-867 +switch (Cur[0]) { +case '\n': +case '\r': +case '\f': +case '\v': +case ' ': +case '\t': I'd replace the `switch` with `if (isspac

[PATCH] D124868: [clang-format] Fix a bug in AlignConsecutiveAssignments

2022-05-04 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 rG342e1c77c360: [clang-format] Fix a bug in AlignConsecutiveAssignments (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LA

[PATCH] D124956: [clang-format] Fix another bug in AlignConsecutiveAssignments

2022-05-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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. Similar to D12

[PATCH] D124956: [clang-format] Fix another bug in AlignConsecutiveAssignments

2022-05-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. No, because the first part of that test case would cause non-consecutive assignments to be aligned. (See https://github.com/llvm/llvm-project/issues/55265.) Only then would the `if` block be treated as a braced list and get misindented. We should definitely use test ca

[PATCH] D124956: [clang-format] Fix another bug in AlignConsecutiveAssignments

2022-05-05 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG8b626a2caa67: [clang-format] Fix another bug in AlignConsecutiveAssignments (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124956/new/

[PATCH] D125064: [clang-format][NFC] Make all TokenAnnotator member functions const

2022-05-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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] D123676: [clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

2022-05-06 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 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D123676/new/ https://reviews.llvm.org/D123676 _

[PATCH] D125085: [clang-format] Correctly handle SpaceBeforeParens for builtins.

2022-05-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:3439-3441 +(Left.is(tok::identifier) || Left.Tok.getIdentifierInfo() || + Left.isFunctionLikeKeyword() || Left.is(tok::r_paren) || + Left.isSimpleTypeSpecifier())) -

[PATCH] D125064: [clang-format][NFC] Make all TokenAnnotator member functions const

2022-05-06 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGaf4cf1c6b8ed: [clang-format][NFC] Make all TokenAnnotator member functions const (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125064/

[PATCH] D125137: [clang-format] Don't remove braces if a 1-statement body would wrap

2022-05-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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. Reimplement th

[PATCH] D125137: [clang-format] Don't remove braces if a 1-statement body would wrap

2022-05-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:25374 verifyFormat("if (a) {\n" " b = c >= 0 ? d\n" " : e;\n" Jeroen wrote: > Will it also add braces if they where not there yet? No,

[PATCH] D125137: [clang-format] Don't remove braces if a 1-statement body would wrap

2022-05-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan planned changes to this revision. owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:465 + +bool UnwrappedLineParser::mightFitOnOneLine() const { + const auto ColumnLimit = Style.ColumnLimit; HazardyKnusperkeks wrote: > A

[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector

2022-07-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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] D128709: [clang-format] Handle Verilog attributes

2022-07-11 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision. owenpan added a comment. Can you mark D128709#3617654 as done? Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1466-1471 + } else if (FormatTok->is(tok::l_paren)) { +const FormatToken *

[PATCH] D129466: [clang-format][NFC] Replace most of std::vector with SmallVector

2022-07-13 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG36229fa3886b: [clang-format][NFC] Replace most of std::vector with SmallVector (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129466/ne

[PATCH] D129742: [clang-format] Fix invalid-code-generation by RemoveBracesLLVM

2022-07-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: HazardyKnusperkeks, curdeius, MyDeveloperDay. 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. When removing

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