[clang] 961fd77 - [clang-format][docs] Fix incorrect 'clang-format 4' option markers
Author: Krystian Kuzniarek Date: 2022-09-05T09:38:22+02:00 New Revision: 961fd77687d27089acf0a09ea29a87fb8ccd7522 URL: https://github.com/llvm/llvm-project/commit/961fd77687d27089acf0a09ea29a87fb8ccd7522 DIFF: https://github.com/llvm/llvm-project/commit/961fd77687d27089acf0a09ea29a87fb8ccd7522.diff LOG: [clang-format][docs] Fix incorrect 'clang-format 4' option markers Introduced by 23a5090c6, some style option markers indicated 'clang-format 4', though their respective options were available in earlier releases. Differential Revision: https://reviews.llvm.org/D129934 Added: Modified: clang/docs/ClangFormatStyleOptions.rst clang/include/clang/Format/Format.h Removed: diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index d3e1d71fd04b7..8bc24c81c9ec2 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -3670,7 +3670,7 @@ the configuration (without a prefix: ``Auto``). -**ReflowComments** (``Boolean``) :versionbadge:`clang-format 4` +**ReflowComments** (``Boolean``) :versionbadge:`clang-format 3.8` If ``true``, clang-format will attempt to re-flow comments. .. code-block:: c++ @@ -3910,7 +3910,7 @@ the configuration (without a prefix: ``Auto``). int bar; int bar; } // namespace b } // namespace b -**SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 4` +**SortIncludes** (``SortIncludesOptions``) :versionbadge:`clang-format 3.8` Controls if and how clang-format will sort ``#includes``. If ``Never``, includes are never sorted. If ``CaseInsensitive``, includes are sorted in an ASCIIbetical or case diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 77ff9a8634295..e057632cc1b02 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -2980,7 +2980,7 @@ struct FormatStyle { ////* second veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongComment with plenty of /// * information */ /// \endcode - /// \version 4 + /// \version 3.8 bool ReflowComments; // clang-format on @@ -3236,7 +3236,7 @@ struct FormatStyle { /// insensitive fashion. /// If ``CaseSensitive``, includes are sorted in an alphabetical or case /// sensitive fashion. - /// \version 4 + /// \version 3.8 SortIncludesOptions SortIncludes; /// Position for Java Static imports. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c6e7752 - [clang-format] Allow `throw` to be a keyword in front of casts
Author: Emilia Dreamer Date: 2022-09-05T12:35:39+02:00 New Revision: c6e7752f8e144ad78aee2e56a7c901c56be360de URL: https://github.com/llvm/llvm-project/commit/c6e7752f8e144ad78aee2e56a7c901c56be360de DIFF: https://github.com/llvm/llvm-project/commit/c6e7752f8e144ad78aee2e56a7c901c56be360de.diff LOG: [clang-format] Allow `throw` to be a keyword in front of casts This makes throw more similar to return. However, unlike return, it has to more strict as to not remove spaces after usages of throw as a (deprecated) exception specifier. Fixes https://github.com/llvm/llvm-project/issues/57391 Differential Revision: https://reviews.llvm.org/D132762 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 663e8ae6a898..d7c2e66ca488 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2153,7 +2153,7 @@ class AnnotatingParser { // before the parentheses, this is unlikely to be a cast. if (LeftOfParens->Tok.getIdentifierInfo() && !LeftOfParens->isOneOf(Keywords.kw_in, tok::kw_return, tok::kw_case, - tok::kw_delete)) { + tok::kw_delete, tok::kw_throw)) { return false; } @@ -3315,6 +3315,10 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, !Right.isOneOf(tok::semi, tok::r_paren, tok::hashhash)) { return true; } + if (Left.is(tok::kw_throw) && Right.is(tok::l_paren) && Right.MatchingParen && + Right.MatchingParen->is(TT_CastRParen)) { +return true; + } if (Style.isJson() && Left.is(tok::string_literal) && Right.is(tok::colon)) return false; if (Left.is(Keywords.kw_assert) && Style.Language == FormatStyle::LK_Java) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index ce56570697cd..4383a903b2f6 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -11038,6 +11038,7 @@ TEST_F(FormatTest, FormatsCasts) { verifyFormat("my_int a = (my_int)2.0f;"); verifyFormat("my_int a = (my_int)sizeof(int);"); verifyFormat("return (my_int)aaa;"); + verifyFormat("throw (my_int)aaa;"); verifyFormat("#define x ((int)-1)"); verifyFormat("#define LENGTH(x, y) (x) - (y) + 1"); verifyFormat("#define p(q) ((int *)&q)"); @@ -15730,6 +15731,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) { verifyFormat("Type *A = ( Type * )P;", Spaces); verifyFormat("Type *A = ( vector )P;", Spaces); verifyFormat("x = ( int32 )y;", Spaces); + verifyFormat("throw ( int32 )x;", Spaces); verifyFormat("int a = ( int )(2.0f);", Spaces); verifyFormat("#define AA(X) sizeof((( X * )NULL)->a)", Spaces); verifyFormat("my_int a = ( my_int )sizeof(int);", Spaces); @@ -15793,6 +15795,7 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) { verifyFormat("#define CONF_BOOL(x) ( bool ) (x)", Spaces); verifyFormat("bool *y = ( bool * ) ( void * ) (x);", Spaces); verifyFormat("bool *y = ( bool * ) (x);", Spaces); + verifyFormat("throw ( int32 ) x;", Spaces); // Run subset of tests again with: Spaces.SpacesInCStyleCastParentheses = false; @@ -15817,6 +15820,8 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) { verifyFormat("bool *y = (bool *) (void *) (x);", Spaces); verifyFormat("bool *y = (bool *) (void *) (int) (x);", Spaces); verifyFormat("bool *y = (bool *) (void *) (int) foo(x);", Spaces); + verifyFormat("throw (int32) x;", Spaces); + Spaces.ColumnLimit = 80; Spaces.IndentWidth = 4; Spaces.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 21ef5c382a90..60684d72605e 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -319,6 +319,34 @@ TEST_F(TokenAnnotatorTest, UnderstandsDelete) { EXPECT_TOKEN(Tokens[7], tok::r_paren, TT_CastRParen); } +TEST_F(TokenAnnotatorTest, UnderstandsCasts) { + auto Tokens = annotate("(void)p;"); + EXPECT_EQ(Tokens.size(), 6u) << Tokens; + EXPECT_TOKEN(Tokens[2], tok::r_paren, TT_CastRParen); + + Tokens = annotate("auto x = (Foo)p;"); + EXPECT_EQ(Tokens.size(), 9u) << Tokens; + EXPECT_TOKEN(Tokens[5], tok::r_paren, TT_CastRParen); + + Tokens = annotate("(std::vector)p;"); + EXPECT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_TOKEN(Tokens[7], tok::r_paren, TT_CastRParen); + + Tokens = annotate("return (Foo)p;"); + EXPECT_EQ(Tokens.size(), 7u) << Tokens; + EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_CastRParen); + + Tokens = annotate("throw (Foo)p;"); + EXPECT_EQ(Tokens.size(), 7u) <<
[clang] f54d42a - [clang-format] Don't put `noexcept` on empty line following constructor
Author: Emilia Dreamer Date: 2022-09-05T12:35:39+02:00 New Revision: f54d42abcf82e122ed0ac4688f01c1f4da5599f2 URL: https://github.com/llvm/llvm-project/commit/f54d42abcf82e122ed0ac4688f01c1f4da5599f2 DIFF: https://github.com/llvm/llvm-project/commit/f54d42abcf82e122ed0ac4688f01c1f4da5599f2.diff LOG: [clang-format] Don't put `noexcept` on empty line following constructor With the AlwaysBreakTemplateDeclarations option, having a constructor template for a type consisting of all-uppercase letters with a noexcept specifier would put said noexcept specifier on its own blank line. This is because the all-uppercase type is understood as a macro-like attribute (such as DEPRECATED()), and noexcept is seen as the declaration. However, noexcept is a keyword and cannot be an identifier on its own. Fixes https://github.com/llvm/llvm-project/issues/56216 Differential Revision: https://reviews.llvm.org/D132189 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 2a64a3bb9c413..663e8ae6a8986 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1924,7 +1924,7 @@ class AnnotatingParser { !Current.Next->isBinaryOperator() && !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace, tok::comma, tok::period, tok::arrow, - tok::coloncolon)) { + tok::coloncolon, tok::kw_noexcept)) { if (FormatToken *AfterParen = Current.MatchingParen->Next) { // Make sure this isn't the return type of an Obj-C block declaration if (AfterParen->isNot(tok::caret)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d330c65470f0d..ce56570697cd1 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -9607,6 +9607,15 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) { verifyFormat("template // T can be A, B or C.\n" "struct C {};", AlwaysBreak); + verifyFormat("template \n" + "C(T) noexcept;", + AlwaysBreak); + verifyFormat("template \n" + "ClassName(T) noexcept;", + AlwaysBreak); + verifyFormat("template \n" + "POOR_NAME(T) noexcept;", + AlwaysBreak); verifyFormat("template class A {\n" "public:\n" " E *f();\n" @@ -9617,6 +9626,9 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) { verifyFormat("template class C {};", NeverBreak); verifyFormat("template void f();", NeverBreak); verifyFormat("template void f() {}", NeverBreak); + verifyFormat("template C(T) noexcept;", NeverBreak); + verifyFormat("template ClassName(T) noexcept;", NeverBreak); + verifyFormat("template POOR_NAME(T) noexcept;", NeverBreak); verifyFormat("template \nvoid foo(aa " ") {}", NeverBreak); diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 6a10d679fbc72..21ef5c382a900 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -788,6 +788,19 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) { EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace); } +TEST_F(TokenAnnotatorTest, UnderstandsFunctionAnnotations) { + auto Tokens = annotate("template \n" + "DEPRECATED(\"Use NewClass::NewFunction instead.\")\n" + "string OldFunction(const string ¶meter) {}"); + ASSERT_EQ(Tokens.size(), 20u) << Tokens; + EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_FunctionAnnotationRParen); + + Tokens = annotate("template \n" +"A(T) noexcept;"); + ASSERT_EQ(Tokens.size(), 12u) << Tokens; + EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown); +} + TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) { auto Annotate = [this](llvm::StringRef Code) { return annotate(Code, getLLVMStyle(FormatStyle::LK_Verilog)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bd3dd10 - [clang-format] Concepts: allow identifiers after negation
Author: Emilia Dreamer Date: 2022-09-05T12:35:40+02:00 New Revision: bd3dd10a8b489ce50823b4cc0049f16610adeee2 URL: https://github.com/llvm/llvm-project/commit/bd3dd10a8b489ce50823b4cc0049f16610adeee2 DIFF: https://github.com/llvm/llvm-project/commit/bd3dd10a8b489ce50823b4cc0049f16610adeee2.diff LOG: [clang-format] Concepts: allow identifiers after negation Previously, the formatter would refuse to treat identifiers within a compound concept definition as actually part of the definition, if they were after the negation operator !. It is now made consistent with the likes of && and ||. Fixes https://github.com/llvm/llvm-project/issues/55898 Differential Revision: https://reviews.llvm.org/D131978 Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 1e775f70a24a..02b13be0d92e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3544,7 +3544,8 @@ void UnwrappedLineParser::parseConstraintExpression() { switch (FormatTok->Previous->Tok.getKind()) { case tok::coloncolon: // Nested identifier. case tok::ampamp: // Start of a function or variable for the - case tok::pipepipe:// constraint expression. + case tok::pipepipe:// constraint expression. (binary) + case tok::exclaim: // The same as above, but unary. case tok::kw_requires: // Initial identifier of a requires clause. case tok::equal: // Initial identifier of a concept declaration. break; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 4383a903b2f6..88c16884d0d8 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24217,6 +24217,15 @@ TEST_F(FormatTest, Concepts) { "concept DelayedCheck = false || requires(T t) { t.bar(); } && " "sizeof(T) <= 8;"); + verifyFormat("template \n" + "concept DelayedCheck = Unit && !DerivedUnit;"); + + verifyFormat("template \n" + "concept DelayedCheck = Unit && !(DerivedUnit);"); + + verifyFormat("template \n" + "concept DelayedCheck = Unit && !!DerivedUnit;"); + verifyFormat("template \n" "concept DelayedCheck = !!false || requires(T t) { t.bar(); } " "&& sizeof(T) <= 8;"); diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 60684d72605e..a839fb29115f 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -374,6 +374,13 @@ TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) { EXPECT_TOKEN(Tokens[13], tok::ampamp, TT_BinaryOperator); EXPECT_TOKEN(Tokens[16], tok::ampamp, TT_BinaryOperator); + Tokens = annotate("template \n" +"concept C = Foo && !Bar;"); + + ASSERT_EQ(Tokens.size(), 14u) << Tokens; + EXPECT_TOKEN(Tokens[9], tok::ampamp, TT_BinaryOperator); + EXPECT_TOKEN(Tokens[10], tok::exclaim, TT_UnaryOperator); + Tokens = annotate("template \n" "concept C = requires(T t) {\n" " { t.foo() };\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2adf241 - [clang-format] [doc] Fix example of wrapping class definitions
Author: Passw Date: 2022-09-06T12:24:18+02:00 New Revision: 2adf241592b38189994c6c9d2dfbfa391ecbe9fa URL: https://github.com/llvm/llvm-project/commit/2adf241592b38189994c6c9d2dfbfa391ecbe9fa DIFF: https://github.com/llvm/llvm-project/commit/2adf241592b38189994c6c9d2dfbfa391ecbe9fa.diff LOG: [clang-format] [doc] Fix example of wrapping class definitions Example of BraceWrapping AfterClass is wrong Differential Revision: https://reviews.llvm.org/D133087 Added: Modified: clang/docs/ClangFormatStyleOptions.rst clang/include/clang/Format/Format.h Removed: diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index 8bc24c81c9ec2..01ebbd72aae44 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -1439,12 +1439,12 @@ the configuration (without a prefix: ``Auto``). .. code-block:: c++ true: - class foo {}; - - false: class foo {}; + false: + class foo {}; + * ``BraceWrappingAfterControlStatementStyle AfterControlStatement`` Wrap control statements (``if``/``for``/``while``/``switch``/..). diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index e057632cc1b02..c1e2fd54cd67d 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -1423,11 +1423,11 @@ struct FormatStyle { /// Wrap class definitions. /// \code /// true: -/// class foo {}; -/// -/// false: /// class foo /// {}; +/// +/// false: +/// class foo {}; /// \endcode bool AfterClass; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2476135 - [clang-format] Change heuristic for locating lambda template arguments
Author: Emilia Dreamer Date: 2022-09-06T12:24:19+02:00 New Revision: 247613548bac55b47eed88e83d5c8640fd4b200a URL: https://github.com/llvm/llvm-project/commit/247613548bac55b47eed88e83d5c8640fd4b200a DIFF: https://github.com/llvm/llvm-project/commit/247613548bac55b47eed88e83d5c8640fd4b200a.diff LOG: [clang-format] Change heuristic for locating lambda template arguments Previously, the heuristic was simply to look for template argument- specific keywords, such as typename, class, template and auto that are preceded by a left angle bracket <. This changes the heuristic to instead look for a left angle bracket < preceded by a right square bracket ], since according to the C++ grammar, the template arguments must *directly* follow the introducer. (This sort of check might just end up being *too* aggressive) This patch also adds a bunch more token annotator tests for lambdas, specifically for some of the stranger forms of lambdas now allowed as of C++20 or soon-to-be-allowed as part of C++23. Fixes https://github.com/llvm/llvm-project/issues/57093 This does NOT resolve the FIXME regarding explicit template lists, but perhaps it gets closer Differential Revision: https://reviews.llvm.org/D132295 Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 02b13be0d92e4..7ef1e82d754fe 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2210,21 +2210,21 @@ bool UnwrappedLineParser::tryToParseLambda() { case tok::l_square: parseSquare(); break; -case tok::kw_auto: -case tok::kw_class: -case tok::kw_template: -case tok::kw_typename: +case tok::less: assert(FormatTok->Previous); - if (FormatTok->Previous->is(tok::less)) + if (FormatTok->Previous->is(tok::r_square)) InTemplateParameterList = true; nextToken(); break; +case tok::kw_auto: +case tok::kw_class: +case tok::kw_template: +case tok::kw_typename: case tok::amp: case tok::star: case tok::kw_const: case tok::kw_constexpr: case tok::comma: -case tok::less: case tok::greater: case tok::identifier: case tok::numeric_constant: diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 88c16884d0d89..d3e657b018b77 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -21730,6 +21730,18 @@ TEST_F(FormatTest, FormatsLambdas) { "g();\n" " }\n" "};\n"); + verifyFormat("auto L = [](T...) {\n" + " {\n" + "f();\n" + "g();\n" + " }\n" + "};"); + verifyFormat("auto L = [](T...) {\n" + " {\n" + "f();\n" + "g();\n" + " }\n" + "};"); // Multiple lambdas in the same parentheses change indentation rules. These // lambdas are forced to start on new lines. diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index a839fb29115f9..a92d44be34f02 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -809,18 +809,85 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) { Tokens = annotate("[]() -> auto {}"); ASSERT_EQ(Tokens.size(), 9u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare); EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow); EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_LambdaLBrace); Tokens = annotate("[]() -> auto & {}"); ASSERT_EQ(Tokens.size(), 10u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare); EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow); EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace); Tokens = annotate("[]() -> auto * {}"); ASSERT_EQ(Tokens.size(), 10u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare); EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow); EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace); + + Tokens = annotate("[] {}"); + ASSERT_EQ(Tokens.size(), 5u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare); + EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_LambdaLBrace); + + Tokens = annotate("[] noexcept {}"); + ASSERT_EQ(Tokens.size(), 6u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare); + EXPECT_TOKEN(Tokens[3], tok::l_brace, TT_LambdaLBrace); + + Tokens = annotate("[] -> auto {}"); + ASSERT_EQ(Tokens.size(), 7u) << Tokens; + EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLS
[clang] [clang-format] Add spaces around the Verilog implication operator (PR #71352)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/71352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add spaces around the Verilog implication operator (PR #71352)
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/71352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add spaces around the Verilog implication operator (PR #71352)
@@ -1980,17 +1980,18 @@ TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) { // joined operators, we don't have a separate type, so we only test for their // precedence. std::pair JoinedBinary[] = { - {prec::Comma, "<->"}, {prec::Assignment, "+="}, - {prec::Assignment, "-="}, {prec::Assignment, "*="}, - {prec::Assignment, "/="}, {prec::Assignment, "%="}, - {prec::Assignment, "&="}, {prec::Assignment, "^="}, - {prec::Assignment, "<<="}, {prec::Assignment, ">>="}, - {prec::Assignment, "<<<="}, {prec::Assignment, ">>>="}, - {prec::LogicalOr, "||"},{prec::LogicalAnd, "&&"}, - {prec::Equality, "=="}, {prec::Equality, "!="}, - {prec::Equality, "==="},{prec::Equality, "!=="}, - {prec::Equality, "==?"},{prec::Equality, "!=?"}, - {prec::ExclusiveOr, "~^"}, {prec::ExclusiveOr, "^~"}, + {prec::Comma, "->"},{prec::Comma, "<->"}, HazardyKnusperkeks wrote: Why adding it at front and generating a huge diff? https://github.com/llvm/llvm-project/pull/71352 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Indent Verilog case statements with comments (PR #71353)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/71353 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add space in Verilog tagged unions (PR #71354)
@@ -4694,8 +4694,15 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Left.isOneOf(TT_VerilogDimensionedTypeName, Keywords.kw_function)) { return true; } +// In a tagged union expression, there should be a space after the tag. +if (Right.isOneOf(tok::period, Keywords.kw_apostrophe) && +Keywords.isVerilogIdentifier(Left) && Left.getPreviousNonComment() && +Left.getPreviousNonComment()->is(Keywords.kw_tagged)) { + return true; +} // Don't add spaces between a casting type and the quote or repetition count -// and the brace. +// and the brace. The case of tagged union expressions is handled by the HazardyKnusperkeks wrote: ```suggestion // and the brace. The case of tagged union expressions is handled by the ``` https://github.com/llvm/llvm-project/pull/71354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add space in Verilog tagged unions (PR #71354)
@@ -4694,8 +4694,15 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Left.isOneOf(TT_VerilogDimensionedTypeName, Keywords.kw_function)) { return true; } +// In a tagged union expression, there should be a space after the tag. +if (Right.isOneOf(tok::period, Keywords.kw_apostrophe) && HazardyKnusperkeks wrote: You are missing a test with the `period` as `Right`, right? https://github.com/llvm/llvm-project/pull/71354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Remove special handling of comments after brace/paren (PR #71672)
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/71672 Fixes http://llvm.org/PR55487 The code did not match the documentation about Cpp11BracedListStyle. Changed handling of comments after opening braces, which are supposedly function call like to behave exactly like their parenthesis counter part. From 4548aa1186531fb93a623144278fe72896d47e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Wed, 8 Nov 2023 13:31:32 +0100 Subject: [PATCH] [clang-format] Remove special handling of comments after brace/paren Fixes http://llvm.org/PR55487 The code did not match the documentation about Cpp11BracedListStyle. Changed handling of comments after opening braces, which are supposedly function call like to behave exactly like their parenthesis counter part. --- clang/lib/Format/ContinuationIndenter.cpp | 4 ++- clang/lib/Format/TokenAnnotator.cpp | 8 ++--- clang/unittests/Format/FormatTest.cpp | 24 +++ clang/unittests/Format/FormatTestComments.cpp | 29 +++ 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 3a829cdedb77fc7..1d76dbe39b00eae 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -802,7 +802,9 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) && !(Current.MacroParent && Previous.MacroParent) && (Current.isNot(TT_LineComment) || - Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen))) { + (Previous.is(BK_BracedInit) && +(!Previous.Previous || Previous.Previous->isNot(tok::identifier))) || + Previous.is(TT_VerilogMultiLineListLParen))) { CurrentState.Indent = State.Column + Spaces; CurrentState.IsAligned = true; } diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 729e7e370bf62ea..9691d879735d3aa 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -3510,12 +3510,10 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const { while (Current) { const FormatToken *Prev = Current->Previous; if (Current->is(TT_LineComment)) { - if (Prev->is(BK_BracedInit) && Prev->opensScope()) { + /*if (Prev->is(BK_BracedInit) && Prev->opensScope()) { Current->SpacesRequiredBefore = -(Style.Cpp11BracedListStyle && !Style.SpacesInParensOptions.Other) -? 0 -: 1; - } else if (Prev->is(TT_VerilogMultiLineListLParen)) { +Style.SpacesInParensOptions.Other ? 1 : 0; + } else */if (Prev->is(TT_VerilogMultiLineListLParen)) { Current->SpacesRequiredBefore = 0; } else { Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 80903e7630c8073..e47c27c6b728c80 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -13500,20 +13500,18 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { "CDDDP83848_RBR_REGISTER};", NoBinPacking); - // FIXME: The alignment of these trailing comments might be bad. Then again, - // this might be utterly useless in real code. verifyFormat("Constructor::Constructor()\n" - ": some_value{ //\n" - " aaa, //\n" - " bbb} {}"); + ": some_value{ //\n" + " aaa, //\n" + " bbb} {}"); // In braced lists, the first comment is always assumed to belong to the // first element. Thus, it can be moved to the next or previous line as // appropriate. - verifyFormat("function({// First element:\n" - " 1,\n" - " // Second element:\n" - " 2});", + verifyFormat("function({ // First element:\n" + " 1,\n" + " // Second element:\n" + " 2});", "function({\n" "// First element:\n" "1,\n" @@ -13582,9 +13580,9 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { verifyFormat( "someFunction(OtherParam,\n" " BracedList{ // comment 1 (Forcing interesting break)\n" - " param1, param2,\n" - " // comment 2\n" - " param3, param4 });", + " param1, param2,\n" + " // comment 2\n" + " param3, param4 });
[clang] [clang-format] Handle variable declarations in BreakAfterAttributes (PR #71755)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/71755 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Remove special handling of comments after brace/paren (PR #71672)
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/71672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Remove special handling of comments after brace/paren (PR #71672)
https://github.com/HazardyKnusperkeks updated https://github.com/llvm/llvm-project/pull/71672 From aeec6f1e767bc2bb11823cb694bf6ccc267b060d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Wed, 8 Nov 2023 13:31:32 +0100 Subject: [PATCH] [clang-format] Remove special handling of comments after brace/paren Fixes http://llvm.org/PR55487 (#55487) The code did not match the documentation about Cpp11BracedListStyle. Changed handling of comments after opening braces, which are supposedly function call like to behave exactly like their parenthesis counter part. --- clang/lib/Format/ContinuationIndenter.cpp | 5 +- clang/lib/Format/TokenAnnotator.cpp | 13 +--- clang/unittests/Format/FormatTest.cpp | 18 +++--- clang/unittests/Format/FormatTestComments.cpp | 61 +-- 4 files changed, 70 insertions(+), 27 deletions(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 3a829cdedb77fc7..04b799a0ea275e1 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -802,7 +802,10 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) && !(Current.MacroParent && Previous.MacroParent) && (Current.isNot(TT_LineComment) || - Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen))) { + (Previous.is(BK_BracedInit) && +(!Style.Cpp11BracedListStyle || !Previous.Previous || + Previous.Previous->isNot(tok::identifier))) || + Previous.is(TT_VerilogMultiLineListLParen))) { CurrentState.Indent = State.Column + Spaces; CurrentState.IsAligned = true; } diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index d648e441f23fe9e..25c9666b0b726ca 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -3507,16 +3507,9 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const { while (Current) { const FormatToken *Prev = Current->Previous; if (Current->is(TT_LineComment)) { - if (Prev->is(BK_BracedInit) && Prev->opensScope()) { -Current->SpacesRequiredBefore = -(Style.Cpp11BracedListStyle && !Style.SpacesInParensOptions.Other) -? 0 -: 1; - } else if (Prev->is(TT_VerilogMultiLineListLParen)) { -Current->SpacesRequiredBefore = 0; - } else { -Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments; - } + Current->SpacesRequiredBefore = Prev->is(TT_VerilogMultiLineListLParen) + ? 0 + : Style.SpacesBeforeTrailingComments; // If we find a trailing comment, iterate backwards to determine whether // it seems to relate to a specific parameter. If so, break before that diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 80903e7630c8073..81a98c3158a425e 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -13500,20 +13500,18 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { "CDDDP83848_RBR_REGISTER};", NoBinPacking); - // FIXME: The alignment of these trailing comments might be bad. Then again, - // this might be utterly useless in real code. verifyFormat("Constructor::Constructor()\n" - ": some_value{ //\n" - " aaa, //\n" - " bbb} {}"); + ": some_value{ //\n" + " aaa, //\n" + " bbb} {}"); // In braced lists, the first comment is always assumed to belong to the // first element. Thus, it can be moved to the next or previous line as // appropriate. - verifyFormat("function({// First element:\n" - " 1,\n" - " // Second element:\n" - " 2});", + verifyFormat("function({ // First element:\n" + " 1,\n" + " // Second element:\n" + " 2});", "function({\n" "// First element:\n" "1,\n" @@ -13635,7 +13633,7 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { verifyFormat("vector< int > x{ 1, 2, 3, 4 };", SpaceBetweenBraces); verifyFormat("f( {}, { {}, {} }, MyMap[ { k, v } ] );", SpaceBetweenBraces); verifyFormat("vector< int > x{ // comment 1\n" - " 1, 2, 3, 4 };", + "1, 2, 3, 4 };", SpaceBetweenBraces); SpaceBetweenBraces.ColumnLimit = 20; verifyFormat("vector< int > x{\n" diff --git a/clang/unitte
[clang] [clang-format] Remove special handling of comments after brace/paren (PR #71672)
HazardyKnusperkeks wrote: Updated implementation and tests for `Cpp1BracedListSyle` set to `false`. https://github.com/llvm/llvm-project/pull/71672 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [llvm] [clang-format] Handle variable declarations in BreakAfterAttributes (PR #71935)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/71935 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle control statements in BreakAfterAttributes (PR #71995)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/71995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24153,6 +24153,23 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { HazardyKnusperkeks wrote: Can you also add some nested `#if` and `#define` to show the (lacking?) indentation? https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24153,6 +24153,53 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { + FormatStyle Style = getLLVMStyle(); + Style.IgnorePPDefinitions = true; + + verifyNoChange("#define A", Style); + verifyNoChange("#define A b", Style); + verifyNoChange("#define A ( args )", Style); + verifyNoChange("#define A ( args ) = func ( args )", Style); + + verifyNoChange("#define A x:", Style); + verifyNoChange("#define A a. b", Style); + + // Surrounded with formatted code + verifyFormat("int a;\n" + "#define A a\n" + "int a;", + "int a ;\n" + "#define A a\n" + "int a ;", + Style); + + // Columns are not broken when a limit is set + Style.ColumnLimit = 10; + verifyNoChange("#define A a a a a", Style); + Style.ColumnLimit = 0; + + // Multiline definition + verifyNoChange("#define A \\\n" + "Line one with spaces . \\\n" + " Line two.", + Style); + verifyNoChange("#define A \\\n" + "a a \\\n" + "a\\\na", HazardyKnusperkeks wrote: ```suggestion "a\\\n" "a", ``` For easier reading. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -1134,6 +1134,14 @@ void UnwrappedLineParser::parsePPDefine() { return; } + if (Style.IgnorePPDefinitions) { +do { + nextToken(); +} while (!eof()); HazardyKnusperkeks wrote: I assume you have tested this on real code. Can you explain why it is okay to check for `eof()`? I really don't know this code, and am a bit surprised. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24153,6 +24153,53 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { + FormatStyle Style = getLLVMStyle(); + Style.IgnorePPDefinitions = true; + + verifyNoChange("#define A", Style); + verifyNoChange("#define A b", Style); + verifyNoChange("#define A ( args )", Style); + verifyNoChange("#define A ( args ) = func ( args )", Style); + + verifyNoChange("#define A x:", Style); + verifyNoChange("#define A a. b", Style); + + // Surrounded with formatted code HazardyKnusperkeks wrote: ```suggestion // Surrounded with formatted code. ``` Always end comments on full stop. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -4719,6 +4723,7 @@ struct FormatStyle { R.IncludeStyle.IncludeIsMainRegex && IncludeStyle.IncludeIsMainSourceRegex == R.IncludeStyle.IncludeIsMainSourceRegex && + IgnorePPDefinitions == R.IgnorePPDefinitions && HazardyKnusperkeks wrote: A few lines up. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -1355,6 +1355,8 @@ unsigned UnwrappedLineFormatter::format( bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; bool ShouldFormat = TheLine.Affected || FixIndentation; +if (Style.IgnorePPDefinitions && TheLine.Type == LT_PreprocessorDirective) HazardyKnusperkeks wrote: Wouldn't this take all preprocessor directives from the formatting? This is at least not what the documentation states. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -4648,6 +4648,10 @@ struct FormatStyle { /// \version 11 std::vector WhitespaceSensitiveMacros; + /// Ignore formatting in preprocessor definitions. HazardyKnusperkeks wrote: Run `clang/docs/tools/dump_format_style.py`. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24153,6 +24153,53 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { + FormatStyle Style = getLLVMStyle(); + Style.IgnorePPDefinitions = true; + + verifyNoChange("#define A", Style); + verifyNoChange("#define A b", Style); + verifyNoChange("#define A ( args )", Style); + verifyNoChange("#define A ( args ) = func ( args )", Style); + + verifyNoChange("#define A x:", Style); + verifyNoChange("#define A a. b", Style); + + // Surrounded with formatted code + verifyFormat("int a;\n" + "#define A a\n" + "int a;", + "int a ;\n" + "#define A a\n" + "int a ;", + Style); + + // Columns are not broken when a limit is set + Style.ColumnLimit = 10; + verifyNoChange("#define A a a a a", Style); + Style.ColumnLimit = 0; + + // Multiline definition + verifyNoChange("#define A \\\n" + "Line one with spaces . \\\n" + " Line two.", + Style); + verifyNoChange("#define A \\\n" + "a a \\\n" + "a\\\na", + Style); HazardyKnusperkeks wrote: This doesn't look formatted. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24153,6 +24153,53 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { + FormatStyle Style = getLLVMStyle(); + Style.IgnorePPDefinitions = true; + + verifyNoChange("#define A", Style); + verifyNoChange("#define A b", Style); + verifyNoChange("#define A ( args )", Style); + verifyNoChange("#define A ( args ) = func ( args )", Style); + + verifyNoChange("#define A x:", Style); + verifyNoChange("#define A a. b", Style); + + // Surrounded with formatted code + verifyFormat("int a;\n" + "#define A a\n" + "int a;", + "int a ;\n" + "#define A a\n" + "int a ;", + Style); + + // Columns are not broken when a limit is set + Style.ColumnLimit = 10; + verifyNoChange("#define A a a a a", Style); + Style.ColumnLimit = 0; + + // Multiline definition + verifyNoChange("#define A \\\n" + "Line one with spaces . \\\n" + " Line two.", + Style); + verifyNoChange("#define A \\\n" + "a a \\\n" + "a\\\na", + Style); HazardyKnusperkeks wrote: ```suggestion Style); ``` https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24153,6 +24153,23 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { + FormatStyle Style = getLLVMStyle(); + Style.IgnorePPDefinitions = true; + + verifyNoChange("#define A", Style); + verifyNoChange("#define A b", Style); + verifyNoChange("#define A ( args )", Style); + verifyNoChange("#define A ( args ) = func ( args )", Style); + verifyNoChange("#define TEXT \\\nLine number one . \\\nNumber two .", + Style); + verifyNoChange("#define A x:", Style); + verifyNoChange("#define A a. b", Style); + + // TODO HazardyKnusperkeks wrote: Actually tests with a (line and block) comment after the `#define` would be interesting too, should they be wrapped? Or the space after `//` added? https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24153,6 +24153,23 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { + FormatStyle Style = getLLVMStyle(); + Style.IgnorePPDefinitions = true; + + verifyNoChange("#define A", Style); + verifyNoChange("#define A b", Style); + verifyNoChange("#define A ( args )", Style); + verifyNoChange("#define A ( args ) = func ( args )", Style); + verifyNoChange("#define TEXT \\\nLine number one . \\\nNumber two .", + Style); + verifyNoChange("#define A x:", Style); + verifyNoChange("#define A a. b", Style); + + // TODO HazardyKnusperkeks wrote: I always comment every other check out, and run only this test case in a debugger to look where the change is needed. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Simplify parseBracedList() (PR #72010)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72010 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in aligning comments in vector of structs (PR #72099)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in `git-clang-format --binary` (PR #74293)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/74293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Refactor getting first/last non-comment of line (PR #74570)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/74570 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle merging functions containing only a block comment (PR #74651)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/74651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle merging functions containing only a block comment (PR #74651)
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/74651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle merging functions containing only a block comment (PR #74651)
@@ -411,9 +411,16 @@ class LineJoiner { } } +const auto *LastNonComment = TheLine->getLastNonComment(); +assert(LastNonComment); +// FIXME: There are probably cases where we should use LastNonComment HazardyKnusperkeks wrote: Is this a left over? https://github.com/llvm/llvm-project/pull/74651 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Clean up the driver and getStyle() in Format.cpp (PR #74794)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/74794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) { "void g() {}", CtorDtorCode, Style); + Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left; HazardyKnusperkeks wrote: You are changing the style for all following tests. (Although it may not have an effect on them.) I don't think you should do that. Put your test at the bottom, or restore the value. https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { // name. !Style.isJavaScript()) || (Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) && - Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) { + Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter && + (Style.isCpp() && Current.Tok.isNot(tok::kw_operator))) { HazardyKnusperkeks wrote: Two things, you don't need the parenthesis, you are already in a conjunction. Does it affect the other languages, that you now add a check for `isCpp()`? https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) { "void g() {}", CtorDtorCode, Style); + Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left; + constexpr StringRef OperatorOverloadCode( HazardyKnusperkeks wrote: Don't put the code into a variable, you are only using it once. https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { // name. !Style.isJavaScript()) || (Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) && - Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) { + Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter && HazardyKnusperkeks wrote: Not your fault, but I'm not trying to read this condition. Can you make it more readable? We typically use a lambda and early `return false`. https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -583,20 +583,31 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return true; } - // If the return type spans multiple lines, wrap before the function name. - if (((Current.is(TT_FunctionDeclarationName) && -!State.Line->ReturnTypeWrapped && -// Don't break before a C# function when no break after return type. -(!Style.isCSharp() || - Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None) && -// Don't always break between a JavaScript `function` and the function -// name. -!Style.isJavaScript()) || - (Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) && - Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) { + const auto WrapBeforeName = [&]() { HazardyKnusperkeks wrote: Okay as far as I can see the conditions are transformed correctly, thanks for that. But there is no addition from you, or am I missing something? Is the problem already fixed? https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -26465,6 +26451,21 @@ TEST_F(FormatTest, BreakAfterAttributes) { "{\n" "}", CtorDtorCode, Style); + + Style.BreakBeforeBraces = FormatStyle::BS_Attach; + Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left; + verifyFormat("struct Foo {\n" + " [[maybe_unused]]\n" + " void operator+();\n" + "};\n" + "[[nodiscard]]\n" + "Foo& operator-(Foo&);", + HazardyKnusperkeks wrote: Remove the blank line. https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -583,20 +583,31 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return true; } - // If the return type spans multiple lines, wrap before the function name. - if (((Current.is(TT_FunctionDeclarationName) && -!State.Line->ReturnTypeWrapped && -// Don't break before a C# function when no break after return type. -(!Style.isCSharp() || - Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None) && -// Don't always break between a JavaScript `function` and the function -// name. -!Style.isJavaScript()) || - (Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) && - Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) { + const auto WrapBeforeName = [&]() { HazardyKnusperkeks wrote: ```suggestion const auto WrapBeforeName = [&] { ``` I think LLVM style is to omit the empty parenthesis. https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
@@ -583,21 +583,31 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return true; } - // If the return type spans multiple lines, wrap before the function name. - if (((Current.is(TT_FunctionDeclarationName) && -!State.Line->ReturnTypeWrapped && -// Don't break before a C# function when no break after return type. -(!Style.isCSharp() || - Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None) && -// Don't always break between a JavaScript `function` and the function -// name. -!Style.isJavaScript()) || - (Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) && - Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter && - (Style.isCpp() && Current.Tok.isNot(tok::kw_operator))) { + const auto WrapBeforeName = [&]() { +// If the return type spans multiple lines, wrap before the function name. +if (Current.isNot(TT_FunctionDeclarationName) || +State.Line->ReturnTypeWrapped) { + return false; +} +if (Previous.is(tok::kw_template) || Current.is(tok::kw_operator)) + return false; +if (!CurrentState.BreakBeforeParameter) + return false; +return true; HazardyKnusperkeks wrote: ```suggestion // Don't break before a C# function when no break after return type. return (!Style.isCSharp() || Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None) && // Don't always break between a JavaScript `function` and the function // name. !Style.isJavaScript(); ``` Don't call the lambda twice. https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix operator overload inconsistency in `BreakAfterAttributes: Always` (PR #74943)
HazardyKnusperkeks wrote: I got a mail, but it seems you have deleted the comment? Is it a regression? Could you bisect it? And you don't need (for me) to comment, when you addressed a comment, just click on resolved. Would reduce the amount of mails in my inbox. ;) https://github.com/llvm/llvm-project/pull/74943 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle constrained auto in QualifierAlignment (PR #72251)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72251 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -1355,8 +1355,11 @@ unsigned UnwrappedLineFormatter::format( bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; bool ShouldFormat = TheLine.Affected || FixIndentation; -if (Style.IgnorePPDefinitions && TheLine.Type == LT_PreprocessorDirective) +if (Style.IgnorePPDefinitions && TheLine.Type == LT_PreprocessorDirective && +TheLine.getFirstNonComment()->Next->is(tok::pp_define)) { HazardyKnusperkeks wrote: Does `Next` always exist? Is just `#` marked as `LT_PreprocessorDirective`? https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore PP directives (PR #70338)
@@ -24206,10 +24206,11 @@ TEST_F(FormatTest, IgnorePPDefinitions) { Style.IndentPPDirectives = FormatStyle::PPDIS_None; verifyNoChange("#if A\n" "#define A a\n" - "#endif", + "#endif\n", HazardyKnusperkeks wrote: We normally don't have a trailing line break in the tests. Why did you add it? https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Skip alignArrayInitializers() for 1-row matrices (PR #72166)
@@ -20875,13 +20875,15 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) { "};", Style); // TODO: Fix the indentations below when this option is fully functional. +#if 0 HazardyKnusperkeks wrote: Why did you remove this? https://github.com/llvm/llvm-project/pull/72166 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix more bugs in isStartOfName() (PR #72336)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Handle lambdas in QualifierAlignment (PR #72456)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72456 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/72520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)
@@ -1316,6 +1316,8 @@ void WhitespaceManager::alignArrayInitializersRightJustified( auto Offset = std::distance(Cells.begin(), CellIter); for (const auto *Next = CellIter->NextColumnElement; Next; Next = Next->NextColumnElement) { + if (RowCount >= CellDescs.CellCounts.size()) +break; HazardyKnusperkeks wrote: ```suggestion for (const auto *Next = CellIter->NextColumnElement; Next && RowCount < CellDescs.CellCounts.size(); Next = Next->NextColumnElement, ++RowCount) { ``` Maybe? Then the `++RowCount` below must be removed. https://github.com/llvm/llvm-project/pull/72520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix crashes in AlignArrayOfStructures (PR #72520)
@@ -1316,6 +1316,8 @@ void WhitespaceManager::alignArrayInitializersRightJustified( auto Offset = std::distance(Cells.begin(), CellIter); for (const auto *Next = CellIter->NextColumnElement; Next; Next = Next->NextColumnElement) { + if (RowCount >= CellDescs.CellCounts.size()) +break; HazardyKnusperkeks wrote: I would change the other lines too. I think it's better to see the condition in the `for`, but it's your call. https://github.com/llvm/llvm-project/pull/72520 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Correctly annotate braces of empty functions (PR #72733)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in isStartOfName() on macro definitions (PR #72768)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in aligning comments above PPDirective (PR #72791)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/72791 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore macro definitions (PR #70338)
@@ -1355,6 +1362,10 @@ unsigned UnwrappedLineFormatter::format( bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; bool ShouldFormat = TheLine.Affected || FixIndentation; + +if (Style.IgnorePPDefinitions && lineContainsPPDefinition(TheLine)) + ShouldFormat = false; HazardyKnusperkeks wrote: ```suggestion bool ShouldFormat = (TheLine.Affected || FixIndentation) && (!Style.IgnorePPDefinitions || lineContainsPPDefinition(TheLine)); ``` Maybe? Don't know which is better. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore macro definitions (PR #70338)
@@ -24153,6 +24153,113 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) { verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style); } +TEST_F(FormatTest, IgnorePPDefinitions) { + FormatStyle Style = getLLVMStyle(); + Style.IgnorePPDefinitions = true; + + verifyNoChange("#define A", Style); + verifyNoChange("#define A b", Style); + verifyNoChange("#define A ( args )", Style); + verifyNoChange("#define A ( args ) = func ( args )", Style); + + verifyNoChange("#define A x:", Style); + verifyNoChange("#define A a. b", Style); + + // Surrounded with formatted code. + verifyFormat("int a;\n" + "#define A a\n" + "int a;", + "int a ;\n" HazardyKnusperkeks wrote: It's often hard to see that comma. That's what probably happened here. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore macro definitions (PR #70338)
@@ -1308,6 +1308,13 @@ class OptimizingLineFormatter : public LineFormatter { } // anonymous namespace +static bool lineContainsPPDefinition(const AnnotatedLine &Line) { HazardyKnusperkeks wrote: ```suggestion static bool LineContainsPPDefinition(const AnnotatedLine &Line) { ``` Code style. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore macro definitions (PR #70338)
@@ -1355,6 +1362,10 @@ unsigned UnwrappedLineFormatter::format( bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; bool ShouldFormat = TheLine.Affected || FixIndentation; + +if (Style.IgnorePPDefinitions && lineContainsPPDefinition(TheLine)) + ShouldFormat = false; HazardyKnusperkeks wrote: I will not request the change. :) I'm fine with either way. https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Option to ignore macro definitions (PR #70338)
https://github.com/HazardyKnusperkeks approved this pull request. LGTM, but wait for either of @owenca or @mydeveloperday . https://github.com/llvm/llvm-project/pull/70338 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Delete TT_LambdaArrow (PR #70519)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/70519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Reduce indent (PR #70583)
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/70583 By using if init statement. From b1af9c060cc5dca1f3bbc551d6a77e73451ffa06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 29 Oct 2023 07:18:06 +0100 Subject: [PATCH] [clang-format][NFC] Reduce indent By using if init statement. --- clang/lib/Format/TokenAnnotator.cpp | 22 ++ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9ec8b93e39fd23a..eda312689f3ce4a 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2093,18 +2093,16 @@ class AnnotatingParser { !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace, tok::comma, tok::period, tok::arrow, tok::coloncolon, tok::kw_noexcept)) { -if (FormatToken *AfterParen = Current.MatchingParen->Next) { - // Make sure this isn't the return type of an Obj-C block declaration - if (AfterParen->isNot(tok::caret)) { -if (FormatToken *BeforeParen = Current.MatchingParen->Previous) { - if (BeforeParen->is(tok::identifier) && - BeforeParen->isNot(TT_TypenameMacro) && - BeforeParen->TokenText == BeforeParen->TokenText.upper() && - (!BeforeParen->Previous || - BeforeParen->Previous->ClosesTemplateDeclaration)) { -Current.setType(TT_FunctionAnnotationRParen); - } -} +if (FormatToken *AfterParen = Current.MatchingParen->Next; +AfterParen->isNot(tok::caret)) { + // Make sure this isn't the return type of an Obj-C block declaration. + if (FormatToken *BeforeParen = Current.MatchingParen->Previous; + BeforeParen->is(tok::identifier) && + BeforeParen->isNot(TT_TypenameMacro) && + BeforeParen->TokenText == BeforeParen->TokenText.upper() && + (!BeforeParen->Previous || + BeforeParen->Previous->ClosesTemplateDeclaration)) { +Current.setType(TT_FunctionAnnotationRParen); } } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Reduce indent (PR #70583)
https://github.com/HazardyKnusperkeks updated https://github.com/llvm/llvm-project/pull/70583 From ad595c32b08bb4d9ddbe2361da86491dbe3c09e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 29 Oct 2023 07:18:06 +0100 Subject: [PATCH] [clang-format][NFC] Reduce indent By using if init statement. --- clang/lib/Format/TokenAnnotator.cpp | 22 ++ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9ec8b93e39fd23a..aee966145b8e518 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2093,18 +2093,16 @@ class AnnotatingParser { !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace, tok::comma, tok::period, tok::arrow, tok::coloncolon, tok::kw_noexcept)) { -if (FormatToken *AfterParen = Current.MatchingParen->Next) { - // Make sure this isn't the return type of an Obj-C block declaration - if (AfterParen->isNot(tok::caret)) { -if (FormatToken *BeforeParen = Current.MatchingParen->Previous) { - if (BeforeParen->is(tok::identifier) && - BeforeParen->isNot(TT_TypenameMacro) && - BeforeParen->TokenText == BeforeParen->TokenText.upper() && - (!BeforeParen->Previous || - BeforeParen->Previous->ClosesTemplateDeclaration)) { -Current.setType(TT_FunctionAnnotationRParen); - } -} +if (FormatToken *AfterParen = Current.MatchingParen->Next; +AfterParen && AfterParen->isNot(tok::caret)) { + // Make sure this isn't the return type of an Obj-C block declaration. + if (FormatToken *BeforeParen = Current.MatchingParen->Previous; + BeforeParen && BeforeParen->is(tok::identifier) && + BeforeParen->isNot(TT_TypenameMacro) && + BeforeParen->TokenText == BeforeParen->TokenText.upper() && + (!BeforeParen->Previous || + BeforeParen->Previous->ClosesTemplateDeclaration)) { +Current.setType(TT_FunctionAnnotationRParen); } } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Reduce indent (PR #70583)
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/70583 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix annotating annotations after requires clause (PR #70602)
https://github.com/HazardyKnusperkeks created https://github.com/llvm/llvm-project/pull/70602 Fixes #69325. From 9d3169cbd756f6c3ba9ac2a7e334677c330da3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= Date: Sun, 29 Oct 2023 20:55:31 +0100 Subject: [PATCH] [clang-format] Fix annotating annotations after requires clause Fixes #69325. --- clang/lib/Format/TokenAnnotator.cpp | 3 ++- clang/unittests/Format/TokenAnnotatorTest.cpp | 14 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index aee966145b8e518..729e7e370bf62ea 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2101,7 +2101,8 @@ class AnnotatingParser { BeforeParen->isNot(TT_TypenameMacro) && BeforeParen->TokenText == BeforeParen->TokenText.upper() && (!BeforeParen->Previous || - BeforeParen->Previous->ClosesTemplateDeclaration)) { + BeforeParen->Previous->ClosesTemplateDeclaration || + BeforeParen->Previous->ClosesRequiresClause)) { Current.setType(TT_FunctionAnnotationRParen); } } diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index c16c7d64752458a..c9f1439e212b0ff 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -1376,6 +1376,20 @@ TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) { "}"; RequiresTokenCount = 9; TestRequires(__LINE__); + + BaseCode = "template\n" + "ANNOTATE(\"S\"\n" + " \"S\")\n" + "void foo();"; + ConstrainedCode = "template\n" +" requires(true)\n" +"ANNOTATE(\"S\"\n" +" \"S\")\n" +"void foo();"; + BaseTokenCount = 16; + RequiresTokenCount = 4; + PrefixTokenCount = 5; + TestRequires(__LINE__); } TEST_F(TokenAnnotatorTest, UnderstandsAsm) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix annotating annotations after requires clause (PR #70602)
https://github.com/HazardyKnusperkeks closed https://github.com/llvm/llvm-project/pull/70602 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Treat empty for/while loops as short loops (PR #70768)
https://github.com/HazardyKnusperkeks commented: The code is okay, but I do not share the intention. https://github.com/llvm/llvm-project/pull/70768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Treat empty for/while loops as short loops (PR #70768)
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/70768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Treat empty for/while loops as short loops (PR #70768)
@@ -3117,9 +3117,16 @@ void UnwrappedLineParser::parseForOrWhileLoop(bool HasParens) { FormatTok->setFinalizedType(TT_ConditionLParen); parseParens(); } - // Event control. - if (Style.isVerilog()) + + if (Style.isVerilog()) { +// Event control. parseVerilogSensitivityList(); + } else if (Style.AllowShortLoopsOnASingleLine && FormatTok->is(tok::semi) && HazardyKnusperkeks wrote: Is `while (true) /*comment*/;` also short? https://github.com/llvm/llvm-project/pull/70768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add ability for clang-format-diff to exit with non-0 status (PR #70883)
@@ -185,6 +191,8 @@ def main(): diff_string = "".join(diff) if len(diff_string) > 0: sys.stdout.write(diff_string) +if args.non_zero_exit_code: +sys.exit(1) HazardyKnusperkeks wrote: But it may be a breaking change for others if it suddenly does not return 0. https://github.com/llvm/llvm-project/pull/70883 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Treat empty for/while loops as short loops (PR #70768)
@@ -3117,9 +3117,16 @@ void UnwrappedLineParser::parseForOrWhileLoop(bool HasParens) { FormatTok->setFinalizedType(TT_ConditionLParen); parseParens(); } - // Event control. - if (Style.isVerilog()) + + if (Style.isVerilog()) { +// Event control. parseVerilogSensitivityList(); + } else if (Style.AllowShortLoopsOnASingleLine && FormatTok->is(tok::semi) && HazardyKnusperkeks wrote: Just asking. But I believe if you use `getPreviousNonComment()` it would be formatted as that. https://github.com/llvm/llvm-project/pull/70768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Treat empty for/while loops as short loops (PR #70768)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/70768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in git-clang-format.bat (PR #75268)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/75268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in `IndentExternBlock: NoIndent` (PR #75731)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/75731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in formating `#define A x:` (PR #73220)
@@ -1171,6 +1171,13 @@ void UnwrappedLineParser::parsePPDefine() { assert((int)Line->PPLevel >= 0); Line->InMacroBody = true; + if (FormatTok->is(tok::identifier) && + Tokens->peekNextToken()->is(tok::colon)) { +nextToken(); +nextToken(); +addUnwrappedLine(); HazardyKnusperkeks wrote: Why that new line? https://github.com/llvm/llvm-project/pull/73220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in formating `#define A x:` (PR #73220)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/73220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add BreakConcatenatedStrings option (PR #73432)
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/73432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add BreakConcatenatedStrings option (PR #73432)
@@ -2088,6 +2088,19 @@ struct FormatStyle { /// \version 3.7 bool BreakBeforeTernaryOperators; + /// Break between concatenated string literals in C, C++, and Objective-C. HazardyKnusperkeks wrote: Why limited to that languages? https://github.com/llvm/llvm-project/pull/73432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add BreakConcatenatedStrings option (PR #73432)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/73432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add BreakAdjacentStringLiterals option (PR #73432)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/73432 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Extend isProto() to also cover LK_TextProto (PR #73582)
https://github.com/HazardyKnusperkeks commented: I can not say if TextProto should be handled equally to Proto. https://github.com/llvm/llvm-project/pull/73582 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add space in Verilog tagged unions (PR #71354)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/71354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Finalize children after formatting them (PR #73753)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/73753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format][NFC] Extend isProto() to also cover LK_TextProto (PR #73582)
https://github.com/HazardyKnusperkeks approved this pull request. I must've read some of the diff backwards. I thought you replaced `Language == LK_Proto` with `isProto()`. https://github.com/llvm/llvm-project/pull/73582 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't skip stringizing when determining brace kind (PR #73886)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/73886 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in `git-clang-format --binary` (PR #74176)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/74176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add an fnmatch-like function for .clang-format-ignore (PR #76021)
@@ -0,0 +1,169 @@ +//===- unittest/Format/MatchFilePathTest.cpp --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "../../lib/Format/MatchFilePath.h" +#include "gtest/gtest.h" + +namespace clang { +namespace format { +namespace { + +class MatchFilePathTest : public ::testing::Test { +protected: + bool match(llvm::StringRef FilePath, llvm::StringRef Pattern) { +return matchFilePath(Pattern, FilePath); + } +}; + +// Most of the test cases below are from: +// https://github.com/python/cpython/blob/main/Lib/test/test_fnmatch.py + +TEST_F(MatchFilePathTest, Wildcard) { + EXPECT_TRUE(match("abc", "?*?")); + EXPECT_TRUE(match("abc", "???*")); + EXPECT_TRUE(match("abc", "*???")); + EXPECT_TRUE(match("abc", "???")); + EXPECT_TRUE(match("abc", "*")); + EXPECT_TRUE(match("abc", "ab[cd]")); + EXPECT_TRUE(match("abc", "ab[!de]")); + EXPECT_TRUE(!match("abc", "ab[de]")); HazardyKnusperkeks wrote: ```suggestion EXPECT_FALSE(match("abc", "ab[de]")); ``` Way better to read. https://github.com/llvm/llvm-project/pull/76021 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in annotating function declaration names (PR #76206)
https://github.com/HazardyKnusperkeks approved this pull request. https://github.com/llvm/llvm-project/pull/76206 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix a bug in annotating function declaration names (PR #76206)
HazardyKnusperkeks wrote: > Thanks for doing this. Does it mean we would have to add every type we use to > our config? It would be much more convenient if clang-format treated the > argument list the same way that it treats in definitions. For example > > ```shell > printf "int\niso_time(time_t) { return 1; }\n" | clang-format -style='{ > AlwaysBreakAfterReturnType: All }' > ``` > > gives > > ```c > int > iso_time(time_t) { > return 1; > } > ``` > > whereas > > ```shell > printf "int\niso_time(time_t);\n" | clang-format -style='{ > AlwaysBreakAfterReturnType: All }' > ``` > > will need a config edit to work. > `clang-format` doesn't know what are types, except for the keywords. So there is no way to decide if this is a function declaration without naming the parameters, or a variable declaration with a constructor call. https://github.com/llvm/llvm-project/pull/76206 ___ 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 formatting. (PR #76059)
https://github.com/HazardyKnusperkeks edited https://github.com/llvm/llvm-project/pull/76059 ___ 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 formatting. (PR #76059)
@@ -4656,6 +4687,15 @@ struct FormatStyle { /// \version 8 std::vector StatementMacros; + /// Tablegen HazardyKnusperkeks wrote: We need a bit more documentation here. https://github.com/llvm/llvm-project/pull/76059 ___ 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 formatting. (PR #76059)
https://github.com/HazardyKnusperkeks requested changes to this pull request. I think we all would gain a lot, if you could split this into multiple pull requests. The discussion can be more focused and you have a greater chance to get something merged. Similar to the Verilog changes. https://github.com/llvm/llvm-project/pull/76059 ___ 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 formatting. (PR #76059)
@@ -4656,6 +4687,15 @@ struct FormatStyle { /// \version 8 std::vector StatementMacros; + /// Tablegen + bool TableGenAllowBreakBeforeInheritColon; + bool TableGenAllowBreakAfterInheritColon; HazardyKnusperkeks wrote: Do you need both options to be enabled at the same time? Otherwise `BreakInheritanceList` should already be the option to check. https://github.com/llvm/llvm-project/pull/76059 ___ 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 formatting. (PR #76059)
@@ -396,6 +396,36 @@ struct FormatStyle { /// \version 17 ShortCaseStatementsAlignmentStyle AlignConsecutiveShortCaseStatements; + /// Style of aligning consecutive TableGen cond operator colons. + /// \code + /// !cond(!eq(size, 1) : 1, + /// !eq(size, 16): 1, + /// true : 0) + /// \endcode + /// \version 18 + AlignConsecutiveStyle AlignConsecutiveTableGenCondOperatorColons; + + /// Style of aligning consecutive TableGen DAGArg operator colons. + /// Intended to be used with TableGenBreakInsideDAGArgList + /// \code + /// let dagarg = (ins + /// a :$src1, + /// aa :$src2, + /// aaa:$src3 + /// ) + /// \endcode + /// \version 18 + AlignConsecutiveStyle AlignConsecutiveTableGenBreakingDAGArgColons; + + /// Style of aligning consecutive TableGen def colons. + /// \code + /// def Def : Parent {} + /// def DefDef: Parent {} + /// def DefDefDef : Parent {} + /// \endcode + /// \version 18 + AlignConsecutiveStyle AlignConsecutiveTableGenDefinitions; HazardyKnusperkeks wrote: Couldn't you reuse `AlignConsecutiveDeclarations` and handle table gen there? https://github.com/llvm/llvm-project/pull/76059 ___ 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 formatting. (PR #76059)
@@ -396,6 +396,36 @@ struct FormatStyle { /// \version 17 ShortCaseStatementsAlignmentStyle AlignConsecutiveShortCaseStatements; + /// Style of aligning consecutive TableGen cond operator colons. + /// \code + /// !cond(!eq(size, 1) : 1, + /// !eq(size, 16): 1, + /// true : 0) + /// \endcode + /// \version 18 + AlignConsecutiveStyle AlignConsecutiveTableGenCondOperatorColons; + + /// Style of aligning consecutive TableGen DAGArg operator colons. + /// Intended to be used with TableGenBreakInsideDAGArgList + /// \code + /// let dagarg = (ins + /// a :$src1, + /// aa :$src2, + /// aaa:$src3 + /// ) + /// \endcode + /// \version 18 + AlignConsecutiveStyle AlignConsecutiveTableGenBreakingDAGArgColons; HazardyKnusperkeks wrote: Please sort alphabetically. https://github.com/llvm/llvm-project/pull/76059 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits