[clang] [clang] Support DecompositionDecl in -ast-print (PR #221711)

Ran Regev via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 9 12:54:08 PDT 2026


================
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++26 -ast-print %s | FileCheck %s
+
+// The `[a, b]` binding list must survive -ast-print, not just the type.
+
+namespace std {
+using size_t = decltype(sizeof(0));
+template <typename> struct tuple_size;
+template <size_t, typename> struct tuple_element;
+} // namespace std
+
+namespace Aggregate {
+struct Pair { int a, b; };
+Pair get();
+Pair &getref();
+
+// CHECK-LABEL: void local() {
+void local() {
+  // CHECK-NEXT: auto [x, y] = get();
+  auto [x, y] = get();
+  // CHECK-NEXT: auto & [rx, ry] = getref();
+  auto &[rx, ry] = getref();
+  // CHECK-NEXT: const auto [cx, cy] = get();
+  const auto [cx, cy] = get();
+  // CHECK-NEXT: static auto [sx, sy] = get();
+  static auto [sx, sy] = get();
+}
+} // namespace Aggregate
+
+namespace Array {
+// CHECK-LABEL: void local() {
+void local() {
+  // CHECK-NEXT: int arr[3] = {1, 2, 3};
+  int arr[3] = {1, 2, 3};
+  // CHECK-NEXT: auto [a, b, c] = {arr[*]};
----------------
regevran wrote:

See [below](https://github.com/llvm/llvm-project/pull/221711#issuecomment-5607833184)

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


More information about the cfe-commits mailing list