Author: Gedare Bloom Date: 2024-09-18T19:44:09-07:00 New Revision: c9aa9d53b6f92d9780430ab8239ea9117574c95d
URL: https://github.com/llvm/llvm-project/commit/c9aa9d53b6f92d9780430ab8239ea9117574c95d DIFF: https://github.com/llvm/llvm-project/commit/c9aa9d53b6f92d9780430ab8239ea9117574c95d.diff LOG: [clang-format] Fix regression in BAS_AlwaysBreak for-await (#108634) Fixes #108589. Added: Modified: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTestJS.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index f29f8796ea9290..4e9ae41b566f49 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -809,7 +809,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, if (Tok.Previous->isIf()) return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak; return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, - tok::kw_switch); + tok::kw_switch) && + !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await)); }; auto IsFunctionCallParen = [](const FormatToken &Tok) { return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous && diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 57c021c76867f7..4b15e7b7da3393 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -2870,6 +2870,11 @@ TEST_F(FormatTestJS, BreakAfterOpenBracket) { verifyFormat("failedUserIds.push(await subscriptioxxxxxxxxxxxxnSubset.map(\n" " subscxxxxxxxxxxxxription => subscription.getUserId()));", Style); + verifyFormat("for await (const packageId of ops.api.iterateEmbeddedFiles(\n" + " this.getFileId().getDriveFile(),\n" + " )) {\n" + "}", + Style); } } // namespace format _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits