[clang] [clang-format] Fix template parsing regression for unspaced user-defi… (PR #210630)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 28 12:46:08 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results

* 3233 tests passed
* 34 tests skipped

All executed tests passed, but another part of the build **failed**. Click on a failure below to see the details.

<details>
<summary>[code=1] tools/clang/lib/Format/check_format_depend_14 C:/_work/llvm-project/llvm-project/build/tools/clang/lib/Format/check_format_depend_14</summary>

```
FAILED: [code=1] tools/clang/lib/Format/check_format_depend_14 C:/_work/llvm-project/llvm-project/build/tools/clang/lib/Format/check_format_depend_14
C:\Windows\system32\cmd.exe /C "cd /D C:\_work\llvm-project\llvm-project\build\tools\clang\lib\Format && C:\_work\llvm-project\llvm-project\build\bin\clang-format.exe C:/_work/llvm-project/llvm-project/clang/lib/Format/FormatTokenLexer.cpp | "C:\Program Files\Git\usr\bin\diff.exe" -u C:/_work/llvm-project/llvm-project/clang/lib/Format/FormatTokenLexer.cpp - && "C:\Program Files\Git\usr\bin\touch.exe" check_format_depend_14"
--- C:/_work/llvm-project/llvm-project/clang/lib/Format/FormatTokenLexer.cpp	2026-07-28 19:32:23.287531800 +0000
+++ -	2026-07-28 19:43:58.817253800 +0000
@@ -595,16 +595,18 @@
if (Tokens.size() < 2)
return false;

-         // --- INTERCEPT STRING/CHARACTER UDLs ALREADY MERGED BY THE RAW LEXER ---
// --- INTERCEPT STRING/CHARACTER UDLs ALREADY MERGED BY THE RAW LEXER ---
// --- INTERCEPT STRING/CHARACTER UDLs ALREADY MERGED BY THE RAW LEXER ---
-  if (Tokens.back()->isOneOf(tok::string_literal, tok::char_constant, tok::numeric_constant) &&
+  // --- INTERCEPT STRING/CHARACTER UDLs ALREADY MERGED BY THE RAW LEXER ---
+  if (Tokens.back()->isOneOf(tok::string_literal, tok::char_constant,
+                             tok::numeric_constant) &&
Tokens.end()[-2]->is(tok::kw_operator)) {

FormatToken *OpToken = Tokens[Tokens.size() - 2];
FormatToken *LiteralToken = Tokens.back();

-           // Strict guard: Do not merge if this is a member access call (e.g., x.operator""_a())
+    // Strict guard: Do not merge if this is a member access call (e.g.,
+    // x.operator""_a())
if (Tokens.size() >= 3) {
FormatToken *PrevToken = Tokens[Tokens.size() - 3];
if (PrevToken->isOneOf(tok::period, tok::arrow) ||
@@ -613,10 +615,11 @@
}
}

-           // Ensure they are touching in the source text
+    // Ensure they are touching in the source text
if (!LiteralToken->hasWhitespaceBefore()) {
-      OpToken->TokenText = StringRef(OpToken->TokenText.data(),
-                                     OpToken->TokenText.size() + LiteralToken->TokenText.size());
+      OpToken->TokenText =
+          StringRef(OpToken->TokenText.data(),
+                    OpToken->TokenText.size() + LiteralToken->TokenText.size());
OpToken->ColumnWidth += LiteralToken->ColumnWidth;

OpToken->Tok.setKind(tok::identifier);
@@ -626,7 +629,7 @@
}
}

-         // --- ORIGINAL NUMERIC LITERAL LOGIC KICKS IN HERE ---
+  // --- ORIGINAL NUMERIC LITERAL LOGIC KICKS IN HERE ---
auto *First = Tokens.end() - 2;
auto &Suffix = First[1];
if (Suffix->hasWhitespaceBefore() || Suffix->TokenText != "$")
```
</details>
<details>
<summary>[code=1] tools/clang/lib/Format/check_format_depend_58 C:/_work/llvm-project/llvm-project/build/tools/clang/lib/Format/check_format_depend_58</summary>

```
FAILED: [code=1] tools/clang/lib/Format/check_format_depend_58 C:/_work/llvm-project/llvm-project/build/tools/clang/lib/Format/check_format_depend_58
C:\Windows\system32\cmd.exe /C "cd /D C:\_work\llvm-project\llvm-project\build\tools\clang\lib\Format && C:\_work\llvm-project\llvm-project\build\bin\clang-format.exe C:/_work/llvm-project/llvm-project/clang/unittests/Format/FormatTest.cpp | "C:\Program Files\Git\usr\bin\diff.exe" -u C:/_work/llvm-project/llvm-project/clang/unittests/Format/FormatTest.cpp - && "C:\Program Files\Git\usr\bin\touch.exe" check_format_depend_58"
--- C:/_work/llvm-project/llvm-project/clang/unittests/Format/FormatTest.cpp	2026-07-28 19:32:41.964435300 +0000
+++ -	2026-07-28 19:44:01.012509600 +0000
@@ -17,8 +17,10 @@

class FormatTest : public test::FormatTestBase {};
TEST_F(FormatTest, FormatsUserDefinedLiteralTemplates) {
-    verifyFormat("template <char... Cs> auto f() { return operator\"\"_mag<Cs...>(); }");
-    verifyFormat("template <char... Cs> auto f() { return operator \"\"_mag<Cs...>(); }");
+  verifyFormat(
+      "template <char... Cs> auto f() { return operator\"\"_mag<Cs...>(); }");
+  verifyFormat(
+      "template <char... Cs> auto f() { return operator \"\"_mag<Cs...>(); }");
}
TEST_F(FormatTest, MessUp) {
EXPECT_EQ("1 2 3", messUp("1 2 3"));
```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

https://github.com/llvm/llvm-project/pull/210630


More information about the cfe-commits mailing list