Skip to content

[clang-format] Fix regression in BAS_AlwaysBreak for-await #108634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

gedare
Copy link
Contributor

@gedare gedare commented Sep 13, 2024

Fixes #108589.

@llvmbot
Copy link
Member

llvmbot commented Sep 13, 2024

@llvm/pr-subscribers-clang-format

Author: Gedare Bloom (gedare)

Changes

Fixes #108589.


Full diff: https://github.com/llvm/llvm-project/pull/108634.diff

2 Files Affected:

  • (modified) clang/lib/Format/ContinuationIndenter.cpp (+1-1)
  • (modified) clang/unittests/Format/FormatTestJS.cpp (+5)
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index f29f8796ea9290..6ed33475882a8e 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -809,7 +809,7 @@ 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, 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 c25228a69a748f..b129dcd14d9e14 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2865,6 +2865,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

@owenca owenca changed the title [clang-format] Fix regression in AlwaysBreak for-await [clang-format] Fix regression in BAS_AlwaysBreak for-await Sep 15, 2024
@owenca owenca merged commit c9aa9d5 into llvm:main Sep 19, 2024
8 checks passed
tmsri pushed a commit to tmsri/llvm-project that referenced this pull request Sep 19, 2024
@gedare gedare deleted the 108589 branch April 30, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression when formatting around for condition
4 participants