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
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
@@ -4213,8 +4226,35 @@ class DecompositionDecl final
static DecompositionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID,
unsigned NumBindings);
- ArrayRef bindings() const {
-return llvm::ArrayRef(getTrailingObject
@@ -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
@@ -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
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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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
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
@@ -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
@@ -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
@@ -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
@@ -757,23 +775,40 @@ bool Sema::CheckParameterPacksForExpansion(
bool HaveFirstPack = false;
std::optional NumPartialExpansions;
SourceLocation PartiallySubstitutedPackLoc;
+ typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
for (UnexpandedParamet
@@ -15991,6 +15998,24 @@
TreeTransform::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
return E;
}
+template
+ExprResult TreeTransform::TransformResolvedUnexpandedPackExpr(
+ResolvedUnexpandedPackExpr *E) {
+ bool ArgumentChanged = false;
+ SmallVector NewE
@@ -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
@@ -1166,26 +1166,54 @@
TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) {
auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(),
-
@@ -1166,26 +1166,54 @@
TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) {
auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(),
-
@@ -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
@@ -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
@@ -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
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
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
@@ -1965,3 +1965,52 @@ CXXFoldExpr::CXXFoldExpr(QualType T,
UnresolvedLookupExpr *Callee,
SubExprs[SubExpr::RHS] = RHS;
setDependence(computeDependence(this));
}
+
+ResolvedUnexpandedPackExpr::ResolvedUnexpandedPackExpr(SourceLocation BL,
+
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
@@ -12726,11 +12726,15 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
// Likewise, variables with tuple-like bindings are required if their
// bindings have side-effects.
- if (const auto *DD = dyn_cast(VD))
-for (const auto *BD : DD->bindings())
- if (co
@@ -2202,6 +2202,17 @@ void
ASTStmtWriter::VisitPackIndexingExpr(PackIndexingExpr *E) {
Code = serialization::EXPR_PACK_INDEXING;
}
+void ASTStmtWriter::VisitResolvedUnexpandedPackExpr(
ricejasonf wrote:
Yes, and thank you for the heads up. I did add a tes
@@ -12726,11 +12726,15 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
// Likewise, variables with tuple-like bindings are required if their
// bindings have side-effects.
- if (const auto *DD = dyn_cast(VD))
-for (const auto *BD : DD->bindings())
- if (co
@@ -951,28 +959,130 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator
&D,
return New;
}
+namespace {
+// CheckBindingsCount
+// - Checks the arity of the structured bindings
+// - Creates the resolved pack expr if there is
+//one
+bool CheckBindingsCount(Sema
https://github.com/ricejasonf updated
https://github.com/llvm/llvm-project/pull/121417
>From 3c81c5bd989f26331917f1401becc1cfa7f4a454 Mon Sep 17 00:00:00 2001
From: Jason Rice
Date: Thu, 22 Jul 2021 16:46:33 -0700
Subject: [PATCH 1/6] [Clang][P1061] stuctured binding packs
---
clang/include/c
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
@@ -951,28 +959,130 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator
&D,
return New;
}
+namespace {
+// CheckBindingsCount
+// - Checks the arity of the structured bindings
+// - Creates the resolved pack expr if there is
+//one
+bool CheckBindingsCount(Sema
https://github.com/ricejasonf updated
https://github.com/llvm/llvm-project/pull/121417
>From 3c81c5bd989f26331917f1401becc1cfa7f4a454 Mon Sep 17 00:00:00 2001
From: Jason Rice
Date: Thu, 22 Jul 2021 16:46:33 -0700
Subject: [PATCH 1/5] [Clang][P1061] stuctured binding packs
---
clang/include/c
@@ -15991,6 +15991,13 @@
TreeTransform::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
return E;
}
+template
+ExprResult TreeTransform::TransformResolvedUnexpandedPackExpr(
+ResolvedUnexpandedPackExpr *E) {
+ // Default behavior is to do nothing with this tr
https://github.com/ricejasonf updated
https://github.com/llvm/llvm-project/pull/121417
>From 3c81c5bd989f26331917f1401becc1cfa7f4a454 Mon Sep 17 00:00:00 2001
From: Jason Rice
Date: Thu, 22 Jul 2021 16:46:33 -0700
Subject: [PATCH 1/4] [Clang][P1061] stuctured binding packs
---
clang/include/c
@@ -805,7 +805,6 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
SemaRef, CodeSynthesisContext::BuildingDeductionGuides,
PointOfInstantiation, InstantiationRange, Entity) {}
-
ricejasonf wrote:
Sorry, `git clang-format` keeps modify
@@ -422,8 +445,8 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
if (const TemplateTypeParmType *TTP
= Unexpanded[I].first.dyn_cast())
Name = TTP->getIdentifier();
-else
- Name = cast(Unexpanded[I].first)->getIdentifier();
+else if
@@ -422,8 +445,8 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
if (const TemplateTypeParmType *TTP
= Unexpanded[I].first.dyn_cast())
Name = TTP->getIdentifier();
-else
- Name = cast(Unexpanded[I].first)->getIdentifier();
+else if
@@ -50,16 +51,28 @@ class CollectUnexpandedParameterPacksVisitor
auto *FTD = FD ? FD->getDescribedFunctionTemplate() : nullptr;
if (FTD && FTD->getTemplateParameters()->getDepth() >= DepthLimit)
return;
- } else if (getDepthAndIndex(ND).first >= D
@@ -951,28 +959,130 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator
&D,
return New;
}
+namespace {
+// CheckBindingsCount
+// - Checks the arity of the structured bindings
+// - Creates the resolved pack expr if there is
+//one
+bool CheckBindingsCount(Sema
ricejasonf wrote:
That crash looks like a result of my call to setDecomposedDecl(nullptr) in
the BindingsInitWalker stuff. I don't remember why I don't set that. I will
check it out when I try to clean that up.
> But that also makes it confusing as to this implementation - I suggest
avoiding unr
https://github.com/ricejasonf updated
https://github.com/llvm/llvm-project/pull/121417
>From 3c81c5bd989f26331917f1401becc1cfa7f4a454 Mon Sep 17 00:00:00 2001
From: Jason Rice
Date: Thu, 22 Jul 2021 16:46:33 -0700
Subject: [PATCH 1/3] [Clang][P1061] stuctured binding packs
---
clang/include/c
@@ -928,9 +928,10 @@ static TemplateArgumentLoc translateTemplateArgument(Sema
&SemaRef,
void Sema::translateTemplateArguments(const ASTTemplateArgsPtr &TemplateArgsIn,
TemplateArgumentListInfo &TemplateArgs) {
- for (unsigned I = 0, Last
@@ -755,7 +755,7 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr
&MTA) {
return true;
};
- const auto *CallerDecl = dyn_cast(CurContext);
+ const auto *CallerDecl = getCurFunctionDecl();
ricejasonf wrote:
Stuff like this is from the implic
@@ -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
@@ -951,28 +959,130 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarator
&D,
return New;
}
+namespace {
+// CheckBindingsCount
+// - Checks the arity of the structured bindings
+// - Creates the resolved pack expr if there is
+//one
+bool CheckBindingsCount(Sema
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++2b %s -verify
+// expected-no-diagnostics
+
+template
+struct type_ { };
+
+template
+auto sum(T... t) { return (t + ...); }
+
+struct my_struct {
+ int a;
+ int b;
+ int c;
+ int d;
+};
+
+struct fake
@@ -422,8 +445,8 @@ Sema::DiagnoseUnexpandedParameterPacks(SourceLocation Loc,
if (const TemplateTypeParmType *TTP
= Unexpanded[I].first.dyn_cast())
Name = TTP->getIdentifier();
-else
- Name = cast(Unexpanded[I].first)->getIdentifier();
+else if
@@ -5397,6 +5393,13 @@ bool ValueDecl::isInitCapture() const {
return false;
}
+bool ValueDecl::isParameterPack() const {
+ if (const auto *NTTP = dyn_cast(this))
+return NTTP->isParameterPack();
+
+ return isa_and_nonnull(getType().getTypePtrOrNull());
---
@@ -4219,6 +4220,13 @@ class DecompositionDecl final
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
+ /// Visit the variables (if any) that hold the values of evaluating the
+ /// binding. Only present for user-defined bindings for tuple-lik
@@ -3395,26 +3395,37 @@ VarDecl *ValueDecl::getPotentiallyDecomposedVarDecl() {
if (auto *Var = llvm::dyn_cast(this))
return Var;
if (auto *BD = llvm::dyn_cast(this))
-return llvm::dyn_cast(BD->getDecomposedDecl());
+return llvm::dyn_cast_or_null(BD->getDecompos
https://github.com/ricejasonf created
https://github.com/llvm/llvm-project/pull/121417
This is an implementation of P1061 Structure Bindings Introduce a Pack without
the ability to use packs outside of templates. There is a couple of ways the
AST could have been sliced so let me know what you
https://github.com/ricejasonf created
https://github.com/llvm/llvm-project/pull/121225
In the development of P1061 (Structured Bindings Introduce a Patch), I found
this bug in the template instantiation of a
local class. The issue is caused by the instantiation of the original template
and not
61 matches
Mail list logo