[clang] [clang-format] Add Leave to AlwaysBreakTemplateDeclarations (PR #80569)

2024-02-07 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/80569 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][docs] Fix version (PR #81185)

2024-02-08 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/81185 #78752 was not merged in time for clang-format 18. From 0a6d07033cbc8218763bbee44df688b29bf7aa55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Thu, 8 Feb 2024 21:08:52 +0

[clang] [clang-format] Add BreakAfterReturnType option to deprecate AlwaysBreakAfterReturnType. (PR #80827)

2024-02-08 Thread Björn Schäpers via cfe-commits
@@ -1010,7 +1010,8 @@ struct FormatStyle { /// \version 3.7 DefinitionReturnTypeBreakingStyle AlwaysBreakAfterDefinitionReturnType; - /// The function declaration return type breaking style to use. + /// The function declaration return type breaking style to use. This +

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-08 Thread Björn Schäpers via cfe-commits
@@ -833,13 +885,207 @@ class AnnotatingParser { Left->setType(TT_ArrayInitializerLSquare); } FormatToken *Tok = CurrentToken; + if (Style.isTableGen()) { +if (CurrentToken->isOneOf(tok::comma, tok::minus, tok::ellipsis)) { + // '-' and

[clang] [clang-format] Update FormatToken::isSimpleTypeSpecifier() (PR #80241)

2024-02-08 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/80241 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Rename option AlwaysBreakTemplateDeclarations (PR #81093)

2024-02-09 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/81093 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Rename option AlwaysBreakTemplateDeclarations (PR #81093)

2024-02-09 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks commented: I'd go contrary to your [comment](https://github.com/llvm/llvm-project/pull/80827#issuecomment-1935386091) and rename the attribute. Because otherwise you still have the contradiction within the code. https://github.com/llvm/llvm-project/pull/8

[clang] [clang-format][docs] Fix version (PR #81185)

2024-02-09 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/81185 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Make LangOpts global in namespace Format (PR #81390)

2024-02-11 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/81390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-11 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/80299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Don't remove parentheses in macro definitions (PR #81444)

2024-02-12 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/81444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Always add a space after #if and #elif (PR #81578)

2024-02-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/81578 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Support of TableGen basic format restrictions. (PR #81611)

2024-02-13 Thread Björn Schäpers via cfe-commits
@@ -55,5 +55,268 @@ TEST_F(FormatTestTableGen, NoSpacesInSquareBracketLists) { verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;"); } +TEST_F(FormatTestTableGen, LiteralsAndIdentifiers) { + verifyFormat("def LiteralAndIdentifiers {\n" + " let someInteg

[clang] [clang-format] Add --fail-on-incomplete-format. (PR #84346)

2024-03-07 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks commented: I think you need to run `clang/docs/tools/dump_format_help.py`. https://github.com/llvm/llvm-project/pull/84346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mail

[clang] [clang-format] Add --fail-on-incomplete-format. (PR #84346)

2024-03-07 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/84346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add --fail-on-incomplete-format. (PR #84346)

2024-03-07 Thread Björn Schäpers via cfe-commits
@@ -535,6 +541,9 @@ static bool format(StringRef FileName) { Rewrite.getEditBuffer(ID).write(outs()); } } + if (ErrorOnIncompleteFormat && !Status.FormatComplete) +return true; + return false; HazardyKnusperkeks wrote: ```suggestion retur

[clang] [clang-format] Add --fail-on-incomplete-format. (PR #84346)

2024-03-08 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > I think you need to run `clang/docs/tools/dump_format_help.py`. https://github.com/llvm/llvm-project/pull/84346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-09 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: That's okay for clang-format, but you couldn't use libFormat with different languages at once anymore. I dislike global state in libraries. https://github.com/llvm/llvm-project/pull/84599 ___ cfe-commits mailing list cfe-com

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-10 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: Then I'd go back to `Style.isCpp()`. What happens if you use libFormat concurrently? https://github.com/llvm/llvm-project/pull/84599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-11 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > > What happens if you use libFormat concurrently? > > Can you elaborate? Doesn't each process get its own copy of the globals of a > shared library? I mean multiple threads in the same process with different languages. maybe unlikely, but not impossible. https://g

[clang] [clang-format][NFC] Enable RemoveSemicolon for clang-format style (PR #82735)

2024-02-23 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/82735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add AlignConsecutiveTableGenCondOperatorColons option. (PR #82878)

2024-02-24 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/82878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add AlignConsecutiveTableGenCondOperatorColons option. (PR #82878)

2024-02-24 Thread Björn Schäpers via cfe-commits
@@ -849,7 +851,12 @@ void WhitespaceManager::alignConsecutiveAssignments() { } void WhitespaceManager::alignConsecutiveBitFields() { - if (!Style.AlignConsecutiveBitFields.Enabled) + alignConsecutiveColons(Style.AlignConsecutiveBitFields, TT_BitFieldColon); +} + +void Whites

[clang] [clang-format] Add AlignConsecutiveTableGenCondOperatorColons option. (PR #82878)

2024-02-24 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/82878 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add a parameter to getStyle() and guessLanguage() (PR #82911)

2024-02-25 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/82911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add AlignConsecutiveTableGenCondOperatorColons option. (PR #82878)

2024-02-25 Thread Björn Schäpers via cfe-commits
@@ -849,7 +851,12 @@ void WhitespaceManager::alignConsecutiveAssignments() { } void WhitespaceManager::alignConsecutiveBitFields() { - if (!Style.AlignConsecutiveBitFields.Enabled) + alignConsecutiveColons(Style.AlignConsecutiveBitFields, TT_BitFieldColon); +} + +void Whites

[clang] [clang-format][NFC] Skip ObjCHeaderStyleGuesser for empty code (PR #82957)

2024-02-26 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/82957 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add AlignConsecutiveTableGenDefinitions option. (PR #83008)

2024-02-26 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/83008 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Replace Style.isCpp() with IsCpp (PR #83533)

2024-03-01 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: The question is: why? And why handle c++ different than all other languages? https://github.com/llvm/llvm-project/pull/83533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listin

[clang] [clang-format] Enable again some operator tests (PR #83380)

2024-03-01 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/83380 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Replace Style.isCpp() with IsCpp (PR #83533)

2024-03-02 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/83533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][doc] fix documentation for clang-format (PR #83415)

2024-03-04 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/83415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [polly] [clang-format] Add Automatic and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-02-04 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/78011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-05 Thread Björn Schäpers via cfe-commits
@@ -833,13 +885,207 @@ class AnnotatingParser { Left->setType(TT_ArrayInitializerLSquare); } FormatToken *Tok = CurrentToken; + if (Style.isTableGen()) { +if (CurrentToken->isOneOf(tok::comma, tok::minus, tok::ellipsis)) { + // '-' and

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-05 Thread Björn Schäpers via cfe-commits
@@ -256,6 +256,18 @@ class AnnotatingParser { } } } + if (Style.isTableGen()) { +if (CurrentToken->isOneOf(tok::comma, tok::equal)) { + // They appears as a separator. Unless it is not in class definition. HazardyKn

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-05 Thread Björn Schäpers via cfe-commits
@@ -833,13 +885,207 @@ class AnnotatingParser { Left->setType(TT_ArrayInitializerLSquare); } FormatToken *Tok = CurrentToken; + if (Style.isTableGen()) { +if (CurrentToken->isOneOf(tok::comma, tok::minus, tok::ellipsis)) { + // '-' and

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-05 Thread Björn Schäpers via cfe-commits
@@ -1423,11 +1692,30 @@ class AnnotatingParser { if (!Tok->getPreviousNonComment()) Line.IsContinuation = true; } + if (Style.isTableGen()) { +if (Tok->is(Keywords.kw_assert)) { + if (!parseTableGenValue()) +return false

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-05 Thread Björn Schäpers via cfe-commits
@@ -833,13 +885,207 @@ class AnnotatingParser { Left->setType(TT_ArrayInitializerLSquare); } FormatToken *Tok = CurrentToken; + if (Style.isTableGen()) { +if (CurrentToken->isOneOf(tok::comma, tok::minus, tok::ellipsis)) { + // '-' and

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-05 Thread Björn Schäpers via cfe-commits
@@ -816,7 +816,7 @@ void FormatTokenLexer::handleTableGenMultilineString() { auto CloseOffset = Lex->getBuffer().find("}]", OpenOffset); if (CloseOffset == StringRef::npos) return; - auto Text = Lex->getBuffer().substr(OpenOffset, CloseOffset + 2); + auto Text = Lex->

[clang] [clang-format] Support of TableGen value annotations. (PR #80299)

2024-02-05 Thread Björn Schäpers via cfe-commits
@@ -833,13 +885,207 @@ class AnnotatingParser { Left->setType(TT_ArrayInitializerLSquare); } FormatToken *Tok = CurrentToken; + if (Style.isTableGen()) { +if (CurrentToken->isOneOf(tok::comma, tok::minus, tok::ellipsis)) { + // '-' and

[clang] [Format] Fix detection of languages when reading from stdin (PR #79051)

2024-01-23 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/79051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-01-23 Thread Björn Schäpers via cfe-commits
@@ -4542,18 +4542,51 @@ struct FormatStyle { /// Other: true /// \endcode struct SpacesInParensCustom { +/// Override any of the following options to prevent addition of space +/// between the first two parentheses in situations where a pair of +/// parent

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

2024-01-23 Thread Björn Schäpers via cfe-commits
@@ -4006,11 +3993,58 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, } if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) { -return (Right.is(TT_CastRParen) || -(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) -

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

2024-01-23 Thread Björn Schäpers via cfe-commits
@@ -4542,18 +4542,51 @@ struct FormatStyle { /// Other: true HazardyKnusperkeks wrote: Add the options here too? https://github.com/llvm/llvm-project/pull/77522 ___ cfe-commits mailing list cfe-commits@lists.llv

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

2024-01-23 Thread Björn Schäpers via cfe-commits
@@ -4006,11 +3993,58 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, } if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) { -return (Right.is(TT_CastRParen) || -(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) -

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

2024-01-23 Thread Björn Schäpers via cfe-commits
@@ -4006,11 +3993,58 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, } if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) { -return (Right.is(TT_CastRParen) || -(Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) -

[clang] [clang-format] Add options to set number of empty lines after includes (PR #78957)

2024-01-23 Thread Björn Schäpers via cfe-commits
@@ -0,0 +1,159 @@ +//===--- IncludesSeparator.cpp ---*- C++ -*-===// HazardyKnusperkeks wrote: Maybe you could work something out with the line type? https://github.com/llvm/llvm-project/blob/4fcd7cf22deff4a63d2bac12c909be7266f8b353/clang/

[clang] [clang-format] Fix a bug in AnnotatingParser::rParenEndsCast() (PR #79549)

2024-01-26 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/79549 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[polly] [clang] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-28 Thread Björn Schäpers via cfe-commits
@@ -922,8 +922,23 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int f:: HazardyKnusperkeks wrote: I'd go with short names, and just name them like `LongName` o

[clang] [polly] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-28 Thread Björn Schäpers via cfe-commits
@@ -587,7 +590,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { !State.Line->ReturnTypeWrapped && // Don't break before a C# function when no break after return type. (!Style.isCSharp() || - Style.AlwaysBreakAfterReturnType != FormatS

[clang] [polly] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-28 Thread Björn Schäpers via cfe-commits
@@ -922,8 +922,23 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int f:: +/// bar(); /// \endcode RTBS_None, +/// Break after return t

[clang] [polly] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-28 Thread Björn Schäpers via cfe-commits
@@ -922,8 +922,23 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int f:: +/// bar(); /// \endcode RTBS_None, +/// Break after return t

[clang] [polly] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-28 Thread Björn Schäpers via cfe-commits
@@ -474,7 +474,7 @@ class State: opts = sorted(opts, key=lambda x: x.name) options_text = "\n\n".join(map(str, opts)) -with open(DOC_FILE) as f: +with open(DOC_FILE, encoding="utf-8") as f: HazardyKnusperkeks wrote: Unrelated. https://github.com/llvm/llvm-pr

[clang] [polly] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-28 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > @mydeveloperday @HazardyKnusperkeks @rymiel this patch fixes a very old bug > and will cause behavior changes whether the default is changed to the new > `AllowShortType` or left at `None`. Which way should we go? What would change if the default was kept at `None`?

[polly] [clang] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-29 Thread Björn Schäpers via cfe-commits
@@ -587,7 +590,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { !State.Line->ReturnTypeWrapped && // Don't break before a C# function when no break after return type. (!Style.isCSharp() || - Style.AlwaysBreakAfterReturnType != FormatS

[polly] [clang] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-29 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > > @mydeveloperday @HazardyKnusperkeks @rymiel this patch fixes a very old bug > > and will cause behavior changes whether the default is changed to the new > > `AllowShortType` or left at `None`. Which way should we go? > > Now I'm leaning toward keeping the existin

[clang] [clang-format] Explicitly open DOC_FILE with utf-8 in dump_format_style.py (PR #79805)

2024-01-29 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. Thanks. https://github.com/llvm/llvm-project/pull/79805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[polly] [clang] [clang-format] Add AllowShortType option for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-29 Thread Björn Schäpers via cfe-commits
@@ -922,8 +922,23 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int f:: +/// bar(); /// \endcode RTBS_None, +/// Break after return t

[clang] [clang-format] Simplify the AfterPlacementOperator option (PR #79796)

2024-01-29 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/79796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle generic selections inside parentheses (PR #79785)

2024-01-29 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/79785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle generic selections inside parentheses (PR #79785)

2024-01-29 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/79785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Handle generic selections inside parentheses (PR #79785)

2024-01-29 Thread Björn Schäpers via cfe-commits
@@ -1694,8 +1694,11 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State, // Special case for generic selection expressions, its comma-separated // expressions are not aligned to the opening paren like regular calls, but // rather continuation-in

[clang] [clang-format] Support of TableGen tokens with unary operator like form, bang operators and numeric literals. (PR #78996)

2024-01-29 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. I didn't say anything because I was also waiting on @mydeveloperday. I see no problem with the current approach and think token annotator tests are enough. https://github.com/llvm/llvm-project/pull/78996

[llvm] [flang] [clang] [compiler-rt] [lldb] [mlir] [lld] [openmp] [libcxx] [clang-format] SpacesInSquareBrackets not working for Java (PR #77833)

2024-01-11 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/77833 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-01-12 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/77013 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -4007,26 +3992,45 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, return true; } - // TODO: check consecutive parens if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) { -if (Right.is(TT_CastRParen) || -(Left.MatchingParen &&

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

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -17016,6 +17056,158 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) { verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces); verifyFormat("size_t idx = (*foo)(a - 1);", Spaces); verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces); + + // Check NonConsecutive space

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

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -17001,6 +17056,158 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) { verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces); verifyFormat("size_t idx = (*foo)(a - 1);", Spaces); verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces); + + // Check NonConsecutive space

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

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -17016,6 +17056,158 @@ TEST_F(FormatTest, ConfigurableSpacesInParens) { verifyFormat("size_t idx = (a->foo)(a - 1);", Spaces); verifyFormat("size_t idx = (*foo)(a - 1);", Spaces); verifyFormat("size_t idx = (*(foo))(a - 1);", Spaces); + + // Check NonConsecutive space

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks requested changes to this pull request. I think you want too much in one change. Maybe first only handle #42112 for what I will be really grateful. And then the stuff with the _license_, because I see discussion there. As far as I can tell you just declare

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/77918 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -171,6 +187,31 @@ void DefinitionBlockSeparator::separateBlocks( return false; }; +// Separate License text. +const bool isComment = Lines[I]->isComment(); HazardyKnusperkeks wrote: ```suggestion const bool IsComment = Lines[I]->isCom

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -586,7 +586,8 @@ template <> struct ScalarEnumerationTraits { static void enumeration(IO &IO, FormatStyle::SeparateDefinitionStyle &Value) { IO.enumCase(Value, "Leave", FormatStyle::SDS_Leave); -IO.enumCase(Value, "Always", FormatStyle::SDS_Always); +IO.enumCa

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -65,18 +81,18 @@ void DefinitionBlockSeparator::separateBlocks( } return false; }; - unsigned NewlineCount = - (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Always ? 1 : 0) + 1; + unsigned NewlineCount = getNewlineCount(Style.SeparateDefinitionBlocks);

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -65,18 +81,18 @@ void DefinitionBlockSeparator::separateBlocks( } return false; }; - unsigned NewlineCount = - (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Always ? 1 : 0) + 1; + unsigned NewlineCount = getNewlineCount(Style.SeparateDefinitionBlocks);

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -17,80 +17,97 @@ namespace clang { namespace format { namespace { +std::string +separateDefinitionBlocks(llvm::StringRef Code, + const std::vector &Ranges, + const FormatStyle &Style = getLLVMStyle()) { + LLVM_DEBUG(llvm::errs

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -586,7 +586,8 @@ template <> struct ScalarEnumerationTraits { static void enumeration(IO &IO, FormatStyle::SeparateDefinitionStyle &Value) { IO.enumCase(Value, "Leave", FormatStyle::SDS_Leave); -IO.enumCase(Value, "Always", FormatStyle::SDS_Always); +IO.enumCa

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

2024-01-12 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/76804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Stop aligning the to continuation lines (PR #76378)

2024-01-12 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > Can someone review this please? Did you see it when I opened the pull request > 2 weeks ago or only when I added the reviewers just now? I thought reviewers > would be added automatically. Every member of @pr-subscribers-clang-format will be informed, and I look int

[clang] [clang-format] Stop aligning the to continuation lines (PR #76378)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -1304,6 +1304,18 @@ TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) { "}", Style); + // When the where line is not to be formatted, following lines should not take HazardyKnusperkeks wrote: ```suggestion // When the

[clang] [clang-format] Stop aligning the to continuation lines (PR #76378)

2024-01-12 Thread Björn Schäpers via cfe-commits
@@ -1304,6 +1304,18 @@ TEST_F(FormatTestCSharp, CSharpGenericTypeConstraints) { "}", Style); + // When the where line is not to be formatted, following lines should not take + // on its indentation. + verifyFormat("class ItemFactory\n" ---

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

2024-01-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/77977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-01-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/77522 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add ShortReturnTypeLength option. (PR #78011)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -3928,6 +3928,13 @@ struct FormatStyle { /// \version 13 unsigned ShortNamespaceLines; + /// When AlwaysBreakAfterReturnType is None, line breaks are prevented after HazardyKnusperkeks wrote: ```suggestion /// When ``AlwaysBreakAfterReturnType`` is

[clang] [clang-format] Add ShortReturnTypeLength option. (PR #78011)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -3928,6 +3928,13 @@ struct FormatStyle { /// \version 13 unsigned ShortNamespaceLines; + /// When AlwaysBreakAfterReturnType is None, line breaks are prevented after + /// short return types. This configures the character limit for a type to be + /// regarded as shor

[clang] [clang-format] Add PenaltyBreakScopeResolution option. (PR #78015)

2024-01-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/78015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Stop aligning the to continuation lines (PR #76378)

2024-01-13 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/76378 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-13 Thread Björn Schäpers via cfe-commits
HazardyKnusperkeks wrote: > > Maybe first only handle #42112 for what I will be really grateful. > > #42112 requests separating both license text and include directives blocks. > My bad, I only looked at the title, not the text. > > And then the stuff with the _license_, because I see discuss

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -17,80 +17,97 @@ namespace clang { namespace format { namespace { +std::string +separateDefinitionBlocks(llvm::StringRef Code, + const std::vector &Ranges, + const FormatStyle &Style = getLLVMStyle()) { + LLVM_DEBUG(llvm::errs

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -586,7 +586,8 @@ template <> struct ScalarEnumerationTraits { static void enumeration(IO &IO, FormatStyle::SeparateDefinitionStyle &Value) { IO.enumCase(Value, "Leave", FormatStyle::SDS_Leave); -IO.enumCase(Value, "Always", FormatStyle::SDS_Always); +IO.enumCa

[clang] [clang-format] Separate License text and include blocks (PR #77918)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -586,7 +586,8 @@ template <> struct ScalarEnumerationTraits { static void enumeration(IO &IO, FormatStyle::SeparateDefinitionStyle &Value) { IO.enumCase(Value, "Leave", FormatStyle::SDS_Leave); -IO.enumCase(Value, "Always", FormatStyle::SDS_Always); +IO.enumCa

[clang] [clang-format] TableGen multi line string support. (PR #78032)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -272,6 +274,14 @@ void FormatTokenLexer::tryMergePreviousTokens() { return; } } + if (Style.isTableGen()) { +if (tryMergeTokens({tok::l_square, tok::l_brace}, HazardyKnusperkeks wrote: ```suggestion if (Style.isTableGen() && tryMergeToken

[clang] [clang-format] TableGen multi line string support. (PR #78032)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -763,6 +773,53 @@ void FormatTokenLexer::handleCSharpVerbatimAndInterpolatedStrings() { resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset + 1))); } +void FormatTokenLexer::handleTableGenMultilineString() { + FormatToken *MultiLineString = Tokens.back(); +

[clang] [clang-format] TableGen multi line string support. (PR #78032)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -1710,7 +1710,7 @@ class AnnotatingParser { TT_UnionLBrace, TT_RequiresClause, TT_RequiresClauseInARequiresExpression, TT_RequiresExpression, TT_RequiresExpressionLParen, TT_RequiresExpressionLBrace, -TT_BracedListLBrace)) { +

[clang] [clang-format] TableGen multi line string support. (PR #78032)

2024-01-13 Thread Björn Schäpers via cfe-commits
@@ -2193,6 +2193,11 @@ TEST_F(TokenAnnotatorTest, UnderstandTableGenTokens) { ASSERT_TRUE(Keywords.isTableGenDefinition(*Tokens[0])); ASSERT_TRUE(Tokens[0]->is(Keywords.kw_def)); ASSERT_TRUE(Tokens[1]->is(TT_StartOfName)); + + // Code, the multiline string token. ---

[clang] [clang-format] Add PenaltyBreakScopeResolution option. (PR #78015)

2024-01-14 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/78015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add ShortReturnTypeLength option. (PR #78011)

2024-01-14 Thread Björn Schäpers via cfe-commits
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/78011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] TableGen multi line string support. (PR #78032)

2024-01-14 Thread Björn Schäpers via cfe-commits
@@ -274,13 +274,13 @@ void FormatTokenLexer::tryMergePreviousTokens() { return; } } - if (Style.isTableGen()) { -if (tryMergeTokens({tok::l_square, tok::l_brace}, - TT_TableGenMultiLineString)) { - // Multi line string starts with [{

[clang] [clang-format] TableGen multi line string support. (PR #78032)

2024-01-14 Thread Björn Schäpers via cfe-commits
@@ -778,45 +778,31 @@ void FormatTokenLexer::handleTableGenMultilineString() { if (MultiLineString->isNot(TT_TableGenMultiLineString)) return; - bool PrevIsRBrace = false; - const char *FirstBreak = nullptr; - const char *LastBreak = nullptr; - const char *Begin = Mu

[clang] [clang-format] TableGen multi line string support. (PR #78032)

2024-01-14 Thread Björn Schäpers via cfe-commits
@@ -778,45 +778,31 @@ void FormatTokenLexer::handleTableGenMultilineString() { if (MultiLineString->isNot(TT_TableGenMultiLineString)) return; - bool PrevIsRBrace = false; - const char *FirstBreak = nullptr; - const char *LastBreak = nullptr; - const char *Begin = Mu

<    1   2   3   4   5   6   7   8   9   >