[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 = *CurrentToken->Previous; assert(OpeningParen.is(tok::l_paren)); FormatToken *PrevNonComment =

[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

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

2022-03-09 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] 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:

[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

[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

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

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

2022-03-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3163 +case tok::identifier: default: HazardyKnusperkeks wrote: > HazardyKnusperkeks wrote: > > owenpan wrote: > > > cjdb wrote: > > > > owenpan wrote: > > > > > Do we

[PATCH] D121069: [clang-format] Minimize the damage caused by AlignArrayOfStructures when working on non square arrays

2022-03-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/WhitespaceManager.h:318 Next = Next->NextColumnElement) { + if (RowCount > MaxRowCount) { +break; owenpan wrote: > curdeius wrote: > > You can elide braces. Personally I use

[PATCH] D121069: [clang-format] Minimize the damage caused by AlignArrayOfStructures when working on non square arrays

2022-03-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/WhitespaceManager.h:321 + } auto Start = (CellStart + RowCount * CellCount); auto End = Start + Offset; MyDeveloperDay wrote: > Ultimately these calculations are incorrect unless

[PATCH] D121069: [clang-format] Minimize the damage caused by AlignArrayOfStructures when working on non square arrays

2022-03-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/WhitespaceManager.cpp:1073 + auto *Start = + (Cells.begin() + RowCount * CellDescs.CellCounts[RowCount]); auto *End = Start + Offset; Can we use `CellCounts[0]` instead?

[PATCH] D121069: [clang-format] Minimize the damage caused by AlignArrayOfStructures when working on non square arrays

2022-03-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121069#3362424 , @MyDeveloperDay wrote: > NOTE: I've tried to collate all the reported crashing examples and run this > fix through them (both Left and Right) all pass except this one below > > > > void foo() > { >

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked an inline comment as done. owenpan added inline comments. Comment at: clang/lib/Format/Format.cpp:1850 + for (FormatToken *Token = Line->First; Token; Token = Token->Next) { +if (Token->Finalized || Token->BraceCount == 0) + continue;

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 410244. owenpan added a comment. In `insertBraces()` in `Format.cpp`, skip an annotated line if its first token is finalized. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120217/new/ https://reviews.llvm.org/D120217 Files:

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 410365. owenpan marked an inline comment as done. owenpan added a comment. If the line immediately following `// clang-format off` is a line comment, `assert(!Token->Finalized)` will fail. Fixed it and updated the corresponding unit test. CHANGES SINCE

[PATCH] D120503: [clang-format] Handle trailing comment for InsertBraces

2022-02-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay. 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] D120512: [clang-format] Fix requires related crash

2022-02-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D120512#3344027 , @curdeius wrote: > LGTM. But your test case is far from the reproduce in the issue report, so > please confirm with @owenpan. See here

[PATCH] D120503: [clang-format] Handle trailing comment for InsertBraces

2022-02-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2340-2341 if (!L.InPPDirective) { Tok = getLastNonComment(L); -if (Tok) +if (Tok) { + Tok = L.Tokens.back().Tok; HazardyKnusperkeks

[PATCH] D120503: [clang-format] Handle trailing comment for InsertBraces

2022-02-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 411256. owenpan added a comment. - Simplified the code that backtracks to the token which the right braces are to be inserted after. - Added a missing newline in the new testcase. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120503/new/

[PATCH] D120503: [clang-format] Handle trailing comment for InsertBraces

2022-02-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2340-2341 if (!L.InPPDirective) { Tok = getLastNonComment(L); -if (Tok) +if (Tok) { + Tok = L.Tokens.back().Tok; owenpan wrote: >

[PATCH] D120503: [clang-format] Handle trailing comment for InsertBraces

2022-02-25 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 rGc05da55bdf54: [clang-format] Handle trailing comment for InsertBraces (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE

[PATCH] D120511: [clang-format] Allow to set token types final

2022-02-25 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/FormatToken.h:382 + } + bool typeIsFinalized() const { return TypeIsFinalized; } I thought you didn't like using the same [[ https://reviews.llvm.org/D116316#inline-1112220 | name ]] for both a

[PATCH] D120034: [clang-format] PROPOSAL - WIP: Added ability to parse template arguments

2022-02-17 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. +1. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120034/new/ https://reviews.llvm.org/D120034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-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 rG77e60bc42c48: [clang-format] Add option to insert braces after control statements (authored by owenpan). Repository: rG LLVM Github Monorepo

[PATCH] D120359: [clang-format][NFC] Remove redundant semi

2022-02-23 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. Oops! For some reason, I thought the patch was //removing// the semi. See also D117301 . Repository: rG LLVM Github Monorepo CHANGES SINCE

[PATCH] D120398: [format] follow up: Use unsigned char as the base of all enums in FormatStyle

2022-03-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Can we use `int8_t` instead of `unsigned char` to keep the enum types signed (and update the changes made in D93758 )? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120398/new/

[PATCH] D120873: [clang-format] Handle wrapped else for RemoveBracesLLVM

2022-03-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 rG1aa608a0208b: [clang-format] Handle wrapped else for RemoveBracesLLVM (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE

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

2022-03-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3090-3093 +#define TYPE_TRAIT(N, I, K) case tok::kw_##I: +#define ARRAY_TYPE_TRAIT(I, E, K) case tok::kw_##I: +#define EXPRESSION_TRAIT(I, E, K) case tok::kw_##I: +#include

[PATCH] D120873: [clang-format] Handle wrapped else for RemoveBracesLLVM

2022-03-02 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. Removes the

[PATCH] D120902: [clang-format] Fix assertion failure/crash with `AllowShortFunctionsOnASingleLine: Inline/InlineOnly`.

2022-03-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:313 break; + if ((*J)->Level == TheLine->Level) +return false; To be safe? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST

[PATCH] D120902: [clang-format] Fix assertion failure/crash with `AllowShortFunctionsOnASingleLine: Inline/InlineOnly`.

2022-03-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:313 break; + if ((*J)->Level == TheLine->Level) +return false; curdeius wrote: > owenpan wrote: > > To be safe? > Good idea. Will do. > Any

[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 = State.Stack.back(); + Can you make it `const` here? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D119597/new/

[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

[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 ) { + return

[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] D120511: [clang-format] Allow to set token types final

2022-02-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/FormatToken.h:394 + } + bool typeIsFinalized() const { return TypeIsFinalized; } curdeius wrote: > Nit, to make everyone happy, the function could be called `isTypeFinalized`. +1. CHANGES SINCE

[PATCH] D120511: [clang-format] Allow to set token types final

2022-02-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/FormatToken.h:382 + } + bool typeIsFinalized() const { return TypeIsFinalized; } HazardyKnusperkeks wrote: > owenpan wrote: > > I thought you didn't like using the same [[ > >

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: 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. This new option `InsertBraces` has been

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2303 +static FormatToken *getLastNonComment(const UnwrappedLine ) { + for (const auto : llvm::reverse(Line.Tokens)) +if (Token.Tok->isNot(tok::comment)) HazardyKnusperkeks

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 410216. owenpan added a comment. Rebased and addressed review comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120217/new/ https://reviews.llvm.org/D120217 Files: clang/docs/ClangFormatStyleOptions.rst clang/docs/ReleaseNotes.rst

[PATCH] D120217: [clang-format] Add an option to insert braces after control statements

2022-02-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2449 } else { - addUnwrappedLine(); - ++Line->Level; - parseStructuralElement(); - if (FormatTok->is(tok::eof)) -addUnwrappedLine(); - --Line->Level; +

[PATCH] D120220: [clang-format][NFC] Fix typos and inconsistencies

2022-02-20 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 rGaacc110bdce7: [clang-format][NFC] Fix typos and inconsistencies (authored by kuzkry, committed by owenpan). Repository: rG LLVM Github Monorepo

[PATCH] D120220: [clang-format][NFC] Fix typos and inconsistencies

2022-02-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/Format.cpp:1664 + // Ensure the list has 'type' in it auto type = std::find(Style->QualifierOrder.begin(), HazardyKnusperkeks wrote: > ;) Good catch! I will add it when landing D120217.

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

[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

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

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

2022-03-23 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGf74413d16345: [clang-format] Fix invalid code generation with comments in lambda (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION

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

2022-03-29 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121757#3415402 , @sstwcw wrote: > I ran check-clang after formatting the entire code base with the new version. > It turned out it did break some tests. It seems to be because it messed up > these comments. > > diff

[PATCH] D122548: [clang-format] Don't format qualifiers in PPDirective

2022-03-27 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 #54513

[PATCH] D122468: [clang-format] Fix SeparateDefinitionBlocks breaking up function-try-block.

2022-03-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. We can refactor by extending `_verifyFormat()` instead of adding a new function. Comment at: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp:46 const FormatStyle = getLLVMStyle(),

[PATCH] D122756: [clang-format] Fix a crash in qualifier alignment

2022-03-30 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. Related to

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

2022-03-31 Thread Owen Pan via Phabricator via cfe-commits
owenpan requested changes to this revision. owenpan added inline comments. This revision now requires changes to proceed. Comment at: clang/lib/Format/TokenAnnotator.cpp:252-256 +} else if (OpeningParen.isConditionLParen(/*IncludeFor=*/false) || +

[PATCH] D122756: [clang-format] Fix a crash in qualifier alignment

2022-04-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan closed this revision. owenpan added a comment. rG492cb7bf9164 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122756/new/ https://reviews.llvm.org/D122756

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

2022-04-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:252-256 +} else if (OpeningParen.isConditionLParen(/*IncludeFor=*/false) || + (OpeningParen.Previous && +OpeningParen.Previous->isOneOf(TT_BinaryOperator,

[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] D122548: [clang-format] Don't format qualifiers in PPDirective

2022-03-28 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rGeee536dd3185: [clang-format] Dont format qualifiers in PPDirective (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122548/new/

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

2022-03-25 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121756#3398165 , @sstwcw wrote: > It turned out this patch does change behavior. > > - while ( > - FormatTok->isOneOf(tok::identifier, tok::kw_requires, > tok::coloncolon)) { > + while

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

2022-03-24 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2707-2708 + if (FormatTok->is(tok::l_brace)) { +CompoundStatementIndenter Indenter(this, Style, Line->Level); +FormatToken *LeftBrace = FormatTok; +parseBlock(); You

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

2022-03-25 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121757#3406814 , @sstwcw wrote: > I tried formatting the files in `clang-formatted-files.txt`. Besides the > files in the list that get changed when formatted with the program built from > `main`, none gets changed when I

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

2022-03-25 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D121757#3407539 , @owenpan wrote: > In D121757#3406814 , @sstwcw wrote: > >> I tried formatting the files in `clang-formatted-files.txt`. Besides the >> files in the list that get

[PATCH] D118706: [clang-format] Correctly parse C99 digraphs: "<:", ":>", "<%", "%>", "%:", "%:%:".

2022-02-01 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/Format.cpp:3246 + // Turning on digraphs in standards before C++0x is error-prone, because e.g. + // the sequence "<::" will be

[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

[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

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

[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

[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

[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

[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

[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] 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] 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) || -

[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
This revision was automatically updated to reflect the committed changes. Closed by commit rG533fbae8d8d8: [clang-format] Add experimental option to remove LLVM braces (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116316/new/

[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] D117398: [clang-format] Fix bug in parsing `operator<` with template

2022-01-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments. Comment at: clang/lib/Format/FormatTokenLexer.cpp:433-446 bool FourthTokenIsLess = false; - if (Tokens.size() > 3) -FourthTokenIsLess = (Tokens.end() - 4)[0]->is(tok::less); - auto First = Tokens.end() - 3; + if (Tokens.size() > 3) { +

[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] D117759: [clang-format][NFC] Clean up tryMergeLessLess()

2022-01-20 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 rGc95afac89e00: [clang-format][NFC] Clean up tryMergeLessLess() (authored by owenpan). Changed prior to commit:

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

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs Revision". This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGd97025ad3a70: [clang-format][NFC] Fix a bug in

[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 updated this revision to Diff 398308. owenpan added a comment. - Rebased to `main`. - Removed unused code. - Updated release notes. 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-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398231. owenpan added a comment. - Use `verifyFormat` instead of `EXPECT_EQ`. - Make this option have less impact on the unwrapped line parser by checking `Style.RemoveBracesLLVM`. - Remove some unused code. CHANGES SINCE LAST ACTION

[PATCH] D117301: [clang][NFC] Wrap TYPE_SWITCH in "do while (0)" in the interpreter

2022-01-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 401257. owenpan added a comment. - Also wrapped `COMPOSITE_TYPE_SWITCH` with do-while. - Cleaned up the macro definitions by removing the superfluous do-while statements. - Removed the unused `INT_TPYE_SWITCH` macro. CHANGES SINCE LAST ACTION

[PATCH] D117759: [clang-format][NFC] Clean up tryMergeLessLess()

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

[PATCH] D117759: [clang-format][NFC] Clean up tryMergeLessLess()

2022-01-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 401579. owenpan added a comment. Further cleanup. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117759/new/ https://reviews.llvm.org/D117759 Files: clang/lib/Format/FormatTokenLexer.cpp Index: clang/lib/Format/FormatTokenLexer.cpp

[PATCH] D117769: [clang-format] Refactor: add FormatToken::hasWhitespaceBefore(). NFC.

2022-01-20 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/D117769/new/ https://reviews.llvm.org/D117769

[PATCH] D117759: [clang-format][NFC] Clean up tryMergeLessLess()

2022-01-20 Thread Owen Pan via Phabricator via cfe-commits
owenpan requested review of this revision. owenpan marked an inline comment as done. owenpan added inline comments. Comment at: clang/lib/Format/FormatTokenLexer.cpp:440-441 - if (First[2]->is(tok::less) || First[1]->isNot(tok::less) || - First[0]->isNot(tok::less) ||

[PATCH] D117301: [clang][NFC] Wrap TYPE_SWITCH in "do while (0)" in the interpreter

2022-01-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D117301#3253874 , @RKSimon wrote: > what about COMPOSITE_TYPE_SWITCH and INT_TYPE_SWITCH - should they be updated > as well? I left them alone because `COMPOSITE_TYPE_SWITCH` didn't cause a dangling `else` problem and

[PATCH] D117301: [clang][NFC] Wrap TYPE_SWITCH in "do while (0)" in the interpreter

2022-01-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 rG7cd441ff537e: [clang][NFC] Wrap TYPE_SWITCH in do while (0) in the interpreter (authored by owenpan). Repository: rG LLVM Github Monorepo

[PATCH] D117301: [clang][NFC] Wrap TYPE_SWITCH in "do while (0)" in the interpreter

2022-01-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: jfb, rsmith, RKSimon, nand. owenpan added a project: clang. owenpan requested review of this revision. Herald added a subscriber: cfe-commits. Wraps the expansion of TYPE_SWITCH of the constexpr interpreter in `do { ... } while (0)` so that

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

2022-04-05 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/D121757/new/ https://reviews.llvm.org/D121757

[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

[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

[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

[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

[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

[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()) {

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

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