[clang] [Clang] Fix a regression introduced by #216729. (PR #219998)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 08:13:39 PDT 2026


https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/219998

We have a very confusing NNS interface:

```cpp
NestedNameSpecifier() : NestedNameSpecifier(FlagKind::Invalid) {}
NestedNameSpecifier(std::nullopt_t) : StoredOrFlag(0) {}
```

That tripped me up (and that we probably should clean up)

On top of that we were lacking mangling tests for
concept template parameters.

We could use more but the goal of the PR is to address the regression.

Fixes #218820

>From c3d2a9361652b67973ec50966bc47ce2bfe8aa6b Mon Sep 17 00:00:00 2001
From: Corentin Jabot <corentinjabot at gmail.com>
Date: Mon, 31 Aug 2026 17:08:54 +0200
Subject: [PATCH] [Clang] Fix a regression introduced by #216729.

We have a very confusing NNS interface:

```cpp
NestedNameSpecifier() : NestedNameSpecifier(FlagKind::Invalid) {}
NestedNameSpecifier(std::nullopt_t) : StoredOrFlag(0) {}
```

That tripped me up (and that we probably should clean up)

On top of that we were lacking mangling tests for
concept template parameters.

We could use more but the goal of the PR is to address the regression.

Fixes #218820
---
 clang/lib/AST/ItaniumMangle.cpp               |  2 +-
 .../mangle-concept-template-param.cpp         | 28 +++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGenCXX/mangle-concept-template-param.cpp

diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 2c38dbfac0cb2..3a3cde3448f44 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -5351,7 +5351,7 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity,
       DiagnoseUnsupportedPackIndexTemplateName();
       break;
     }
-    mangleUnresolvedName(NestedNameSpecifier(), DTI->getName(),
+    mangleUnresolvedName(/*NestedNameSpecifier=*/std::nullopt, DTI->getName(),
                          DTI->template_arguments().data(),
                          DTI->getNumTemplateArgs(), Arity);
     break;
diff --git a/clang/test/CodeGenCXX/mangle-concept-template-param.cpp b/clang/test/CodeGenCXX/mangle-concept-template-param.cpp
new file mode 100644
index 0000000000000..31ed49804b8e8
--- /dev/null
+++ b/clang/test/CodeGenCXX/mangle-concept-template-param.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -verify -std=c++2c -emit-llvm -triple %itanium_abi_triple -o - %s -fclang-abi-compat=latest | FileCheck %s
+// expected-no-diagnostics
+
+// FIXME: Is the empty case case correct? These are not defined by the itanium ABI yet.
+namespace GH218820 {
+// CHECK: define {{.*}}@_ZN8GH2188201fITpTtTyEJEEEvvQfraa1CIiE(
+// CHECK: define {{.*}}@_ZN8GH2188201fIJNS_1CEEEEvvQfraa1CIiE(
+template <template <typename> concept... C>
+void f() requires (C<int> && ...) {}
+
+// CHECK: define {{.*}}@_ZN8GH2188201gITpTtTyEJEEEvvQfraa1VIiE(
+// CHECK: define {{.*}}@_ZN8GH2188201gIJNS_1VEEEEvvQfraa1VIiE(
+template <template <typename> auto... V>
+void g() requires (V<int> && ...) {}
+
+template <typename T>
+concept C = true;
+
+template <typename T>
+constexpr auto V = true;
+
+void h() {
+    f<>();
+    f<C>();
+    g<>();
+    g<V>();
+}
+}



More information about the cfe-commits mailing list