[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-02-05 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > However, we should target to have it landed before rc2 or something like that > We'd make a lot of folks happy having that in 20, I think. And while the PR > is not tiny, it's seems also fairly low risk (famous last words!) I'm not comfortable pushing large, new features

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-02-05 Thread Erich Keane via cfe-commits
erichkeane wrote: > The code and test coverage looks good. There are a couple of comments that > have not been addressed. > > And there is @zygoloid suggestion to generalize > `SubstNonTypeTemplateParmPackExpr` - do we want to do that now or address it > after the fact? > > Maybe trying to l

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-29 Thread LLVM Continuous Integration via cfe-commits
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `openmp-offload-amdgpu-runtime` running on `omp-vega20-0` while building `clang` at step 7 "Add check check-offload". Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/14879 Here is the releva

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-29 Thread via cfe-commits
https://github.com/cor3ntin closed https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-29 Thread via cfe-commits
cor3ntin wrote: > > Does this mean we should adjust the cxx_status page to not say Clang 20? I > > also see there is a conflict with the ReleaseNotes.md where it appears all > > of the C++2c items no longer exist. (I guess that is because it is for the > > next release.) > > Meh, let's assume

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-29 Thread Jason Rice via cfe-commits
ricejasonf wrote: >@ricejasonf let us know if you want us to merge on your behalf @cor3ntin When you think its ready, yes please. I think it requires write access. I fixed the conflict in the ReleaseNotes through Github's UI so that only my feature is under the C++2c features added. I assume o

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-29 Thread via cfe-commits
cor3ntin wrote: > Does this mean we should adjust the cxx_status page to not say Clang 20? I > also see there is a conflict with the ReleaseNotes.md where it appears all of > the C++2c items no longer exist. (I guess that is because it is for the next > release.) Meh, let's assume 20 and we c

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-29 Thread Jason Rice via cfe-commits
ricejasonf wrote: @cor3ntin > Now that the Clang 20 branch has happened, I think we should go ahead with > that PR Does this mean we should adjust the cxx_status page to not say Clang 20? I also see there is a conflict with the ReleaseNotes.md where it appears all of the C++2c items no long

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
cor3ntin wrote: @ricejasonf let us know if you want us to merge on your behalf https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
https://github.com/cor3ntin approved this pull request. Now that the Clang 20 branch has happened, I think we should go ahead with that PR - It would be great to explore merging ResolvedUnexpandedPackExpr and FunctionParmPackExpr in a separate PR. Is that something you would be interested in

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread Jason Rice via cfe-commits
@@ -4213,8 +4226,35 @@ class DecompositionDecl final static DecompositionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumBindings); - ArrayRef bindings() const { -return llvm::ArrayRef(getTrailingObject

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
https://github.com/cor3ntin commented: The code and test coverage looks good. There are a couple of comments that have not been addressed. And there is @zygoloid suggestion to generalize `SubstNonTypeTemplateParmPackExpr`. Maybe trying to land that today is not the brightest idea. However, we

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
@@ -5321,6 +5321,59 @@ class BuiltinBitCastExpr final } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final cor3ntin wrote: Shoul

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
@@ -1099,6 +1099,13 @@ def err_lambda_capture_misplaced_ellipsis : Error< "the name of the capture">; def err_lambda_capture_multiple_ellipses : Error< "multiple ellipses in pack capture">; +def err_binding_multiple_ellipses : Error< + "multiple packs in structured binding

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-28 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-27 Thread Jason Rice via cfe-commits
@@ -1523,9 +1570,25 @@ void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) { // If the type of the decomposition is dependent, then so is the type of // each binding. if (DecompType->isDependentType()) { -for (auto *B : DD->bindings()) - B->s

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-27 Thread Jason Rice via cfe-commits
@@ -3423,6 +3425,13 @@ VarDecl *BindingDecl::getHoldingVar() const { return VD; } +llvm::ArrayRef BindingDecl::getBindingPackExprs() const { + if (!Binding) +return {}; ricejasonf wrote: Added. The assert was being triggered in one spot that I realized

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread Jason Rice via cfe-commits
https://github.com/ricejasonf edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread Jason Rice via cfe-commits
@@ -1523,9 +1570,25 @@ void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) { // If the type of the decomposition is dependent, then so is the type of // each binding. if (DecompType->isDependentType()) { -for (auto *B : DD->bindings()) - B->s

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread via cfe-commits
@@ -1523,9 +1570,25 @@ void Sema::CheckCompleteDecompositionDeclaration(DecompositionDecl *DD) { // If the type of the decomposition is dependent, then so is the type of // each binding. if (DecompType->isDependentType()) { -for (auto *B : DD->bindings()) - B->s

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread via cfe-commits
@@ -3423,6 +3425,13 @@ VarDecl *BindingDecl::getHoldingVar() const { return VD; } +llvm::ArrayRef BindingDecl::getBindingPackExprs() const { + if (!Binding) +return {}; cor3ntin wrote: Looking at how this is used, i think we can assert here instead ht

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread via cfe-commits
@@ -2484,6 +2489,16 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) { if (PD->isParameterPack()) return TransformFunctionParmPackRefExpr(E, PD); + if (BindingDecl *BD = dyn_cast(D); BD && BD->isParameterPack()) { +BD = cast_or_null(TransformDecl(

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread via cfe-commits
@@ -2670,8 +2670,11 @@ StmtResult Sema::BuildCXXForRangeStmt( // them in properly when we instantiate the loop. if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) { if (auto *DD = dyn_cast(LoopVar)) -for (auto *Binding : DD->bindings()) - Bindin

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-26 Thread via cfe-commits
https://github.com/cor3ntin commented: Some nitpicks. Getting close :) https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-25 Thread Jason Rice via cfe-commits
@@ -0,0 +1,117 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++26 %s -verify ricejasonf wrote: I added these to the bottom of this file. https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-co

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Thank you for the PR, small comments. https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++2c -verify -fsyntax-only %s + +template +void decompose_array() { + int arr[4] = {1, 2, 3, 5}; + auto [x, ... // #1 +rest, ...more_rest] = arr; // expected-error{{multiple packs in structured binding declaration}} +

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,117 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++26 %s -verify shafik wrote: +1 we should always cover all the examples from the proposal. https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mai

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Richard Smith via cfe-commits
@@ -4213,8 +4226,35 @@ class DecompositionDecl final static DecompositionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumBindings); - ArrayRef bindings() const { -return llvm::ArrayRef(getTrailingObject

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Richard Smith via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Richard Smith via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount zygoloid wrote: We [don't start function comments with the function name](https://llvm.org/docs/CodingStandards.html#commenting:~:text=

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread via cfe-commits
cor3ntin wrote: > I do not have a strong preference, but I kept `bindings()` the same since it > represents the structure of the AST and that is how it is used in most > places. (like 2x time more than `flat_bindings()`) Lets not then I'm inclined to say we should merge that once @zygoloid an

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-23 Thread Jason Rice via cfe-commits
ricejasonf wrote: > I wonder if we should rename flat_bindings() to bindings() and bindings() to > bindings_as_written() (or similar), as I expect that to be the function we > ~always want to use. I do not have a strong preference, but I kept `bindings()` the same since it represents the stru

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-22 Thread Jason Rice via cfe-commits
@@ -5321,6 +5321,59 @@ class BuiltinBitCastExpr final } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final +: public Expr, + private llvm

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-21 Thread Yanzuo Liu via cfe-commits
@@ -5321,6 +5321,59 @@ class BuiltinBitCastExpr final } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final +: public Expr, + private llvm

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-21 Thread Jason Rice via cfe-commits
@@ -5321,6 +5321,59 @@ class BuiltinBitCastExpr final } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final +: public Expr, + private llvm

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-21 Thread Yanzuo Liu via cfe-commits
@@ -5321,6 +5321,59 @@ class BuiltinBitCastExpr final } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final +: public Expr, + private llvm

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-20 Thread via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-20 Thread Jason Rice via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread Jason Rice via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
@@ -1099,6 +1099,13 @@ def err_lambda_capture_misplaced_ellipsis : Error< "the name of the capture">; def err_lambda_capture_multiple_ellipses : Error< "multiple ellipses in pack capture">; +def err_binding_multiple_ellipses : Error< + "multiple packs in structured binding

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread Jason Rice via cfe-commits
@@ -1099,6 +1099,13 @@ def err_lambda_capture_misplaced_ellipsis : Error< "the name of the capture">; def err_lambda_capture_multiple_ellipses : Error< "multiple ellipses in pack capture">; +def err_binding_multiple_ellipses : Error< + "multiple packs in structured binding

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread Jason Rice via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
@@ -1099,6 +1099,13 @@ def err_lambda_capture_misplaced_ellipsis : Error< "the name of the capture">; def err_lambda_capture_multiple_ellipses : Error< "multiple ellipses in pack capture">; +def err_binding_multiple_ellipses : Error< + "multiple packs in structured binding

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
https://github.com/cor3ntin edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
@@ -0,0 +1,117 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++26 %s -verify cor3ntin wrote: Can we - Test that `sizeof` (in the case where it's empty, of size 1, n, etc_) works fine - Test that `auto [a, b...]` works for an array of size 1 - Test that `auto [

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
https://github.com/cor3ntin commented: A few more comments on top of Richard's https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-18 Thread via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Younan Zhang via cfe-commits
@@ -757,23 +775,40 @@ bool Sema::CheckParameterPacksForExpansion( bool HaveFirstPack = false; std::optional NumPartialExpansions; SourceLocation PartiallySubstitutedPackLoc; + typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; for (UnexpandedParamet

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Younan Zhang via cfe-commits
@@ -15991,6 +15998,24 @@ TreeTransform::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { return E; } +template +ExprResult TreeTransform::TransformResolvedUnexpandedPackExpr( +ResolvedUnexpandedPackExpr *E) { + bool ArgumentChanged = false; + SmallVector NewE

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Younan Zhang via cfe-commits
@@ -15991,6 +15998,24 @@ TreeTransform::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { return E; } +template +ExprResult TreeTransform::TransformResolvedUnexpandedPackExpr( +ResolvedUnexpandedPackExpr *E) { + bool ArgumentChanged = false; + SmallVector NewE

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
https://github.com/ricejasonf edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
https://github.com/ricejasonf edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
https://github.com/ricejasonf edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -5321,6 +5321,59 @@ class BuiltinBitCastExpr final } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final ricejasonf wrote: I d

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Richard Smith via cfe-commits
@@ -951,28 +959,124 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one +static bool CheckBindingsCount(Sema &S, D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Richard Smith via cfe-commits
@@ -1099,6 +1099,13 @@ def err_lambda_capture_misplaced_ellipsis : Error< "the name of the capture">; def err_lambda_capture_multiple_ellipses : Error< "multiple ellipses in pack capture">; +def err_binding_multiple_ellipses : Error< + "multiple ellipses in structured bind

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Richard Smith via cfe-commits
@@ -5321,6 +5321,59 @@ class BuiltinBitCastExpr final } }; +// Represents an unexpanded pack where the list of expressions are +// known. These are used when structured bindings introduce a pack. +class ResolvedUnexpandedPackExpr final zygoloid wrote: This

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 6e8a1a45a783c13e4cd19bfd20b7a56cab6f7d81 e0cb7487cec4d9eb3aac4806d99cea2120f6974a --e

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -757,23 +775,40 @@ bool Sema::CheckParameterPacksForExpansion( bool HaveFirstPack = false; std::optional NumPartialExpansions; SourceLocation PartiallySubstitutedPackLoc; + typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; for (UnexpandedParamet

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -15991,6 +15998,24 @@ TreeTransform::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { return E; } +template +ExprResult TreeTransform::TransformResolvedUnexpandedPackExpr( +ResolvedUnexpandedPackExpr *E) { + bool ArgumentChanged = false; + SmallVector NewE

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -50,17 +50,29 @@ class CollectUnexpandedParameterPacksVisitor auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr; if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit) return; - } else if (getDepthAndIndex(ND).first >= D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -1166,26 +1166,54 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) { auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(), -

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-17 Thread Jason Rice via cfe-commits
@@ -1166,26 +1166,54 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) { auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(), -

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -757,23 +775,40 @@ bool Sema::CheckParameterPacksForExpansion( bool HaveFirstPack = false; std::optional NumPartialExpansions; SourceLocation PartiallySubstitutedPackLoc; + typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; for (UnexpandedParamet

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -1508,23 +1612,52 @@ static bool checkMemberDecomposition(Sema &S, ArrayRef Bindings, Qualifiers Q = DecompType.getQualifiers(); if (FD->isMutable()) Q.removeConst(); -B->setBinding(S.BuildQualifiedType(FD->getType(), Loc, Q), E.get()); +Walker.commitA

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -1166,26 +1166,54 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) { auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(), -

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 commented: Thanks, this looks much better now. I went through another pass, focusing mostly on the pack expansion part. https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -50,17 +50,29 @@ class CollectUnexpandedParameterPacksVisitor auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr; if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit) return; - } else if (getDepthAndIndex(ND).first >= D

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -1166,26 +1166,54 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) { auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(), -

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -15991,6 +15998,24 @@ TreeTransform::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { return E; } +template +ExprResult TreeTransform::TransformResolvedUnexpandedPackExpr( +ResolvedUnexpandedPackExpr *E) { + bool ArgumentChanged = false; + SmallVector NewE

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -757,23 +775,40 @@ bool Sema::CheckParameterPacksForExpansion( bool HaveFirstPack = false; std::optional NumPartialExpansions; SourceLocation PartiallySubstitutedPackLoc; + typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; zyn0217 wr

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -951,28 +959,125 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator &D, return New; } +// CheckBindingsCount +// - Checks the arity of the structured bindings +// - Creates the resolved pack expr if there is +//one + zyn0217 wrote: ```sugg

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -1166,26 +1166,54 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) { auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(), -

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Jason Rice via cfe-commits
@@ -1508,23 +1612,52 @@ static bool checkMemberDecomposition(Sema &S, ArrayRef Bindings, Qualifiers Q = DecompType.getQualifiers(); if (FD->isMutable()) Q.removeConst(); -B->setBinding(S.BuildQualifiedType(FD->getType(), Loc, Q), E.get()); +Walker.commitA

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Jason Rice via cfe-commits
@@ -104,7 +104,6 @@ void CodeGenFunction::EmitDecl(const Decl &D) { case Decl::Binding: case Decl::UnresolvedUsingIfExists: case Decl::HLSLBuffer: -llvm_unreachable("Declaration should not be in declstmts!"); ricejasonf wrote: I will just put this ba

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Jason Rice via cfe-commits
@@ -237,7 +237,7 @@ bool Decl::isTemplateParameterPack() const { } bool Decl::isParameterPack() const { - if (const auto *Var = dyn_cast(this)) + if (const auto *Var = dyn_cast(this)) ricejasonf wrote: They would still both just look for a PackExpansionType

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread via cfe-commits
cor3ntin wrote: I plan to do another pass in the next couple of days, sorry for the delay https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Yanzuo Liu via cfe-commits
@@ -237,7 +237,7 @@ bool Decl::isTemplateParameterPack() const { } bool Decl::isParameterPack() const { - if (const auto *Var = dyn_cast(this)) + if (const auto *Var = dyn_cast(this)) zwuis wrote: My idea about this part of changes is adding `BindingDecl::i

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis commented: FYI Clang Static Analyzer (I built this branch locally) crashes when running with 'clang/test/SemaCXX/cxx2c-binding-pack.cpp'. My test command is `path/to/build/bin/clang-tidy --checks=clang-static-analyzer-core.BitwiseShift another/path/to/SemaCXX/cxx2c-bin

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Yanzuo Liu via cfe-commits
@@ -104,7 +104,6 @@ void CodeGenFunction::EmitDecl(const Decl &D) { case Decl::Binding: case Decl::UnresolvedUsingIfExists: case Decl::HLSLBuffer: -llvm_unreachable("Declaration should not be in declstmts!"); zwuis wrote: Can we move some `case`s aft

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-15 Thread Yanzuo Liu via cfe-commits
https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-14 Thread Jason Rice via cfe-commits
ricejasonf wrote: @erichkeane, thanks for the approval. Does that mean I should stop making changes to this PR? I was messing with a more rangey interface for `flat_bindings`, but for some reason the `llvm::concat` range was referring to uninitialized memory when used as a temporary in a for l

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-14 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. I'm good here. Please let others make sure they are as well though. https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.o

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-10 Thread Erich Keane via cfe-commits
@@ -1965,3 +1965,52 @@ CXXFoldExpr::CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SubExprs[SubExpr::RHS] = RHS; setDependence(computeDependence(this)); } + +ResolvedUnexpandedPackExpr::ResolvedUnexpandedPackExpr(SourceLocation BL, +

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-10 Thread Jason Rice via cfe-commits
https://github.com/ricejasonf edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-10 Thread Jason Rice via cfe-commits
@@ -1965,3 +1965,52 @@ CXXFoldExpr::CXXFoldExpr(QualType T, UnresolvedLookupExpr *Callee, SubExprs[SubExpr::RHS] = RHS; setDependence(computeDependence(this)); } + +ResolvedUnexpandedPackExpr::ResolvedUnexpandedPackExpr(SourceLocation BL, +

[clang] [Clang][P1061] Add stuctured binding packs (PR #121417)

2025-01-10 Thread Jason Rice via cfe-commits
https://github.com/ricejasonf edited https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

  1   2   >