[PATCH] D139281: [clang-format] Fix an assertion failure in block parsing

2022-12-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: sstwcw, HazardyKnusperkeks, MyDeveloperDay, rymiel. 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. This ass

[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-12-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. @gedare do you need us to commit this patch on your behalf (using "Gedare Bloom ")? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137762/new/ https://reviews.llvm.org/D137762 __

[PATCH] D139281: [clang-format] Fix an assertion failure in block parsing

2022-12-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D139281#3969880 , @HazardyKnusperkeks wrote: > We should rename, remove, or re add the functionality for this function. Or > else someone new will come along and be confused. +1 Repository: rG LLVM Github Monorepo CHANG

[PATCH] D139281: [clang-format] Fix an assertion failure in block parsing

2022-12-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 480364. owenpan added a comment. Moved `isBlockBegin()` to `UnwrappedLineParser`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139281/new/ https://reviews.llvm.org/D139281 Files: clang/lib/Format/FormatToken.h clang/lib/Format/UnwrappedLinePar

[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-12-06 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 rGb40e9dce0a67: [clang-format] Avoid breaking )( with BlockIndent (authored by gedare, committed by owenpan). Repository: rG LLVM Github Monorepo C

[PATCH] D138263: [clang-format] Supress aligning of trailing namespace comments

2022-12-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. Can you rebase (preferably after landing D138402 )? Comment at: clang/lib/Format/WhitespaceManager.cpp:991 +bool DontAlignThisComment = +i > 0 && Changes[i - 1].Tok->is(TT_NamespaceRBrace); bool WasAli

[PATCH] D139281: [clang-format] Fix an assertion failure in block parsing

2022-12-06 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 rG15f121e85384: [clang-format] Fix an assertion failure in block parsing (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGES SINCE L

[PATCH] D139257: [clang-format] Link the braces of a block in UnwrappedLineParser

2022-12-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. I have second thoughts about linking block braces in `UnwrappedLineParser`. Consider the following example: #if A while (a) { // Linked to the r_brace below #else while(b) { // Also linked to the r_brace below #endif foo(); } // Linked to the l_brace of

[PATCH] D138263: [clang-format] Supress aligning of trailing namespace comments

2022-12-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D138263#3975828 , @owenpan wrote: > Can you rebase (preferably after landing D138402 > )? See D139257#3983332 . If it gets reverted, we have to do s

[PATCH] D139257: [clang-format] Link the braces of a block in UnwrappedLineParser

2022-12-08 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. See https://github.com/llvm/llvm-project/issues/59417. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139257/new/ https://reviews.llvm.org/D139257 ___ cfe-commits mailing list cfe

[PATCH] D139760: Revert "[clang-format] Link the braces of a block in UnwrappedLineParser"

2022-12-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: HazardyKnusperkeks, MyDeveloperDay, rymiel. 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. But keep the add

[PATCH] D139760: Revert "[clang-format] Link the braces of a block in UnwrappedLineParser"

2022-12-10 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 rG91b5d508e350: Revert "[clang-format] Link the braces of a block in UnwrappedLineParser" (authored by owenpan). Repository: rG LLVM Github Monorepo

[PATCH] D139801: [clang-format] Adds 'friend' to QualifierOrder.

2022-12-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D139801#3989812 , @HazardyKnusperkeks wrote: > My idea would be hardcoded `friend` as first entry, regardless of the chosen > sequence. > But others may have a different opinion on that. It would be confusing with `QAS_Right

[PATCH] D139999: [clang-format][NFC] Don't run any passes if Environment::make fails

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

[PATCH] D139999: [clang-format][NFC] Don't run any passes if Environment::make fails

2022-12-14 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 rG0e89f1cca495: [clang-format][NFC] Don't run any passes if Environment::make fails (authored by owenpan). Repository: rG LLVM Github Monorepo CHAN

[PATCH] D140058: [clang-format][NFC] Turn on some code-changing options one by one

2022-12-14 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel. 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. For the code-cha

[PATCH] D140058: [clang-format][NFC] Turn on some code-changing options one by one

2022-12-15 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 rG240e29c5015d: [clang-format][NFC] Turn on some code-changing options one by one (authored by owenpan). Repository: rG LLVM Github Monorepo CHANGE

[PATCH] D140058: [clang-format][NFC] Turn on some code-changing options one by one

2022-12-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment. In D140058#4000332 , @rupprecht wrote: > In D140058#4000311 , @rupprecht > wrote: > >> This is causing a test failure: >> https://buildkite.com/llvm-project/upstream-bazel/builds/48607#0

[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 &NextLine = *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 &NextLine = *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] 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 `INT_T

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

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

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

[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
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: https://reviews.llvm.org/D117759?vs=401579&id=4017

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

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

[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 https://lists.llvm.org/cgi-

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

[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; + p

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

[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 &Line) { + for (const auto &Token : llvm::reverse(Line.Tokens)) +if (Token.Tok->isNot(tok::comment)) HazardyKn

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

[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. Repositor

[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: clang/docs/ClangForma

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

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

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

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

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

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

[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; owenpan wrote: > HazardyK

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

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

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

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

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

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

[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 "clang/Basic/TokenKinds

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

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

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

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

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

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

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

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

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

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

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

2021-12-30 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 wrote

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

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

[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 (!LeftOfParen

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

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

[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 (Style.BraceW

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

[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) && +Line->Toke

[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 + const

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

[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 getPreviousToken(

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

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

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

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

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

[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 clang/docs/ReleaseNotes.rs

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

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

[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 cfe-commits@li

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

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

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

[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 &NextLine = *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 &NextLine = *I[1]; +const auto *PreviousLine = I != AnnotatedLines.begin() ? I[-1] : nullptr; +if (NextLine.Type == LT_Invalid || NextLine.First->MustBreakBefore) --

[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; +

<    7   8   9   10   11   12   13   >