llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: kadir çetinkaya (kadircet) <details> <summary>Changes</summary> ccae7b461be339e717d02f99ac857cf0bc7d17f improved handling for nested calls, but this resulted in a lot of changes near `new` expressions. This patch tries to restore previous behavior around new expressions, by treating them as simple functions, which seem to align with the concept. Fixes https://github.com/llvm/llvm-project/issues/105133. --- Full diff: https://github.com/llvm/llvm-project/pull/105168.diff 2 Files Affected: - (modified) clang/lib/Format/ContinuationIndenter.cpp (+2) - (modified) clang/unittests/Format/FormatTest.cpp (+4) ``````````diff diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 46dafad65863dc..8f65a1445dc3a5 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -848,6 +848,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, const auto IsSimpleFunction = [&](const FormatToken &Tok) { if (!Tok.FakeLParens.empty() && Tok.FakeLParens.back() > prec::Unknown) return false; + if (Tok.is(tok::kw_new)) + return true; const auto *Previous = Tok.Previous; if (!Previous || (!Previous->isOneOf(TT_FunctionDeclarationLParen, TT_LambdaDefinitionLParen) && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 794ccab3704534..bdaacd065a45d1 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -9292,6 +9292,10 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) { " aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa)) &&\n" " aaaaaaaaaaaaaaaa);", Style); + verifyFormat( + "fooooooooooo(new BARRRRRRRRR(\n" + " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZZZZZZZZZZZZZZZZZZZZZZZZZ()));", + Style); Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent; Style.BinPackArguments = false; `````````` </details> https://github.com/llvm/llvm-project/pull/105168 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits