[all-commits] [llvm/llvm-project] d23678: [clang] Support DecompositionDecl in -ast-print (#...

Ran Regev via All-commits all-commits at lists.llvm.org
Thu Sep 10 10:11:17 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d23678bd45b149107e43eed3d56a02571bafef7f
      https://github.com/llvm/llvm-project/commit/d23678bd45b149107e43eed3d56a02571bafef7f
  Author: Ran Regev <regev.ran at gmail.com>
  Date:   2026-09-10 (Thu, 10 Sep 2026)

  Changed paths:
    M clang/lib/AST/DeclPrinter.cpp
    A clang/test/AST/ast-print-decomposition.cpp
    M clang/test/Analysis/anonymous-decls.cpp
    M clang/test/Analysis/cfg.cpp

  Log Message:
  -----------
  [clang] Support DecompositionDecl in -ast-print (#221711)

`DeclPrinter` had no `VisitDecompositionDecl`, so `auto [a, b] = get();`
printed as `auto = get();`, silently dropping the binding list (worse
at namespace scope, where it also produced a stray empty statement per
binding).

Add `DeclPrinter::VisitDecompositionDecl`, printing the full
`type [bindings] = init;` form for all three decomposition kinds
(aggregate/member, array, tuple-like), matching what `VisitVarDecl` does
for an ordinary declaration. Specifier and initializer printing is
shared between the two via two helpers (`printVarDeclSpecifiers`,
`printVarInitializer`) so they can't drift apart.

Each binding prints correctly, including a pack's leading `...` and
per-binding attributes. `BindingDecls` are skipped when walking a
`DeclContext` directly, since each is already printed as part of its
`DecompositionDecl;` a decomposition declaration is likewise kept out of
the tag-declaration grouping in `VisitDeclContext`, which would
otherwise merge it into a preceding `struct S { ... } obj;`.

Assisted-by: AI



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list