[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-tools-extra] [clang][Sema] Upstream HeuristicResolver from clangd (PR #121314)

2025-01-17 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Thanks https://github.com/llvm/llvm-project/pull/121314 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Sema] Migrate away from PointerUnion::dyn_cast (NFC) (PR #123284)

2025-01-16 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. https://github.com/llvm/llvm-project/pull/123284 ___ 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
@@ -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] Correctly propagate type aliases' unexpanded flags up to lambda (PR #122875)

2025-01-16 Thread Younan Zhang via cfe-commits
@@ -47,6 +49,10 @@ template void f() { }(), ...); }(1, 2); + [](Is...) { +([] { using T = ElementType; }(), ...); zyn0217 wrote: Yes, that's exactly why the issue arises. https://github.com/llvm/llvm-project/pull/122875 __

[clang] [Clang] Fix canonicalization of pack indexing types (PR #123209)

2025-01-16 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/123209 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Correct the order of substituted arguments in CTAD alias guides (PR #123022)

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

[clang] [Clang] Correct the order of substituted arguments in CTAD alias guides (PR #123022)

2025-01-15 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/123022 >From 549216ee8a58c8b60fcbc757e1b7041b5ef2da54 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Wed, 15 Jan 2025 15:25:20 +0800 Subject: [PATCH 1/2] [Clang] Correct the order of substituted arguments in CTAD a

[clang] [Clang] Correct the order of substituted arguments in CTAD alias guides (PR #123022)

2025-01-15 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/123022 >From 549216ee8a58c8b60fcbc757e1b7041b5ef2da54 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Wed, 15 Jan 2025 15:25:20 +0800 Subject: [PATCH 1/2] [Clang] Correct the order of substituted arguments in CTAD a

[clang] [Clang] Correct the order of substituted arguments in CTAD alias guides (PR #123022)

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

[clang] [Clang] Correct the order of substituted arguments in CTAD alias guides (PR #123022)

2025-01-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/123022 We missed a case of type constraints referencing deduced template parameters when constructing a deduction guide for the type alias. This patch fixes the issue by swapping the order of constructing 'template ar

[clang] [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (PR #122875)

2025-01-14 Thread Younan Zhang via cfe-commits
@@ -810,7 +810,7 @@ Bug Fixes to C++ Support module imports in those situations. (#GH60336) - Fix init-capture packs having a size of one before being instantiated. (#GH63677) - Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852

[clang] [Clang] Correctly propagate type aliases' unexpanded flags up to lambda (PR #122875)

2025-01-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/122875 We should have been checking desugar() for the type of the right-hand side of a typedef declaration, instead of using getCanonicalType(), which points to the end of the type alias chain. Fixes https://github.c

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

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

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-11 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @mysterymath @zmodem Can you both test this patch on Windows to confirm if it resolves issues you've reported? We'd greatly appreciate it! https://github.com/llvm/llvm-project/pull/122423 ___ cfe-commits mailing list cfe-commits@lists.

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-11 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/7] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

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

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-11 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/6] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

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

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-11 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/5] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-11 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/4] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang][NFC] Fix a test failure with mold linker (PR #122587)

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

[clang] [Clang][NFC] Fix a test failure with mold linker (PR #122587)

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

[clang] [Clang][NFC] Fix a test failure with mold linker (PR #122587)

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

[clang] [Clang][NFC] Fix a test failure with mold linker (PR #122587)

2025-01-11 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/122587 Mold prefers the suffix '$' for symbols like PLT and GOT entries, so exclude these symbols as well. Otherwise, this test will fail for developers using mold-linked Clang. >From 19467fe0e48abfe85003ebf80e29a37

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

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

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

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

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-11 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/3] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-10 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/2] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-10 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/3] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-10 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/5] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-10 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/5] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-10 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/5] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-10 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122423 >From d40a80859eafe96bdc99957db2aebb70db407e67 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 10 Jan 2025 09:46:24 +0800 Subject: [PATCH 1/3] Reapply "[Clang] Implement CWG2369 "Ordering between constra

[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

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

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-08 Thread Younan Zhang via cfe-commits
zyn0217 wrote: > Is kinda wrong, it should be in the instantiation of that function... @erichkeane I don’t quite understand: the CWG issue itself requires us to check the constraint before substituting into the function during template argument deduction. So it shouldn’t live in a specializati

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-08 Thread Younan Zhang via cfe-commits
zyn0217 wrote: Reverted in https://github.com/llvm/llvm-project/pull/122130 https://github.com/llvm/llvm-project/pull/102857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[Clang] Implement CWG2369 "Ordering between constraints and substitution"" (PR #122130)

2025-01-08 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/122130 Unfortunately that breaks some code on Windows when lambdas come into play, as reported in https://github.com/llvm/llvm-project/pull/102857#issuecomment-2577861178 This reverts commit 96eced624e0f120155256033f

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-08 Thread Younan Zhang via cfe-commits
zyn0217 wrote: I see the problem here: When substituting into the constraint __is_derived_from_optional with [_Tp = __sfinae_assign_base] prior to substituting the three-way operator, we must also substitute into the lambda call expression. This requires instantiating the lambda body to deduc

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-08 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @cor3ntin Do we need to revert it for now? https://github.com/llvm/llvm-project/pull/102857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Don't form a type constraint if the concept is invalid (PR #122065)

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

[clang] [Clang] Don't form a type constraint if the concept is invalid (PR #122065)

2025-01-08 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122065 >From 312776183068b84ddfea38ea7158c44c1926160a Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Wed, 8 Jan 2025 15:40:23 +0800 Subject: [PATCH 1/3] [Clang] Don't form a type constraint if the concept is invali

[clang] [Clang] Don't form a type constraint if the concept is invalid (PR #122065)

2025-01-08 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/122065 >From 312776183068b84ddfea38ea7158c44c1926160a Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Wed, 8 Jan 2025 15:40:23 +0800 Subject: [PATCH 1/2] [Clang] Don't form a type constraint if the concept is invali

[clang] [clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (PR #121768)

2025-01-08 Thread Younan Zhang via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -1228,35 +1228,45 @@ bool Sema::AttachTypeConstraint(AutoTypeLoc TL, NonTypeTemplateParmDecl *NewConstrainedParm,

[clang] [Clang] Don't form a type constraint if the concept is invalid (PR #122065)

2025-01-07 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/122065 After 0dedd6fe1 and 03229e7c0, invalid concept declarations might lack expressions for evaluation and normalization. This could make it crash in certain scenarios, apart from the one of evaluation concepts show

[clang] Fix extra parenthesis in diagnostic (PR #122055)

2025-01-07 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Good catch, thanks! https://github.com/llvm/llvm-project/pull/122055 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[Clang] Improve diagnostics for expansion length mismatch" (PR #121044)

2025-01-07 Thread Younan Zhang via cfe-commits
zyn0217 wrote: (I plan to merge this after the branch 20 cut to avoid any potential revert churn. So it will stay in draft for now) https://github.com/llvm/llvm-project/pull/121044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.

[clang] [clang] Improve `make_cxx_dr_status` behavior when error occurs (PR #121785)

2025-01-06 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Thanks, the patch looks great https://github.com/llvm/llvm-project/pull/121785 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-06 Thread Younan Zhang via cfe-commits
@@ -174,6 +174,26 @@ static_assert(!__is_layout_compatible(StructWithAnonUnion, StructWithAnonUnion3) #endif } // namespace cwg2759 +#if __cplusplus >= 202002L +namespace cwg2770 { // cwg2770: 20 zyn0217 wrote: Thanks for the post cleanup! Just learned how t

[clang] [clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (PR #121768)

2025-01-06 Thread Younan Zhang via cfe-commits
@@ -0,0 +1,54 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: cd %t + +// RUN: %clang_cc1 -std=c++20 mod.cppm -emit-module-interface -o mod.pcm -fallow-pcm-with-compiler-errors -verify +// RUN: %clang_cc1 -std=c++20 main.cpp -fmodule-file=mod=mod.pcm -verify -fallow-pcm

[clang] [clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (PR #121768)

2025-01-06 Thread Younan Zhang via cfe-commits
@@ -1235,15 +1235,24 @@ bool Sema::AttachTypeConstraint(AutoTypeLoc TL, << NewConstrainedParm->getTypeSourceInfo() ->getTypeLoc() .getSourceRange(); +NewConstrainedParm->setPlaceholderTypeConstraint( +RecoveryExpr::Create(Contex

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-06 Thread Younan Zhang via cfe-commits
@@ -174,6 +174,26 @@ static_assert(!__is_layout_compatible(StructWithAnonUnion, StructWithAnonUnion3) #endif } // namespace cwg2759 +#if __cplusplus >= 202002L +namespace cwg2770 { // cwg2770: 20 zyn0217 wrote: Yes, I implemented what that issue proposed. I

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

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

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-04 Thread Younan Zhang via cfe-commits
zyn0217 wrote: Thanks so much for the review! I'll keep an eye on that PR, and there’s some post-work to do: 1. Cleanup 2. Adaptation for lambdas https://github.com/llvm/llvm-project/pull/102857 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

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

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

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

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -,12 +,55 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -,12 +,55 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -,12 +,55 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -13044,6 +13045,17 @@ class Sema final : public SemaBase { bool SkipForSpecialization = false, bool ForDefaultArgumentSubstitution = false); + /// Apart from storing the result to \p Result, this behaves the same as + /// another overload. + void getTemplateI

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -13044,6 +13045,17 @@ class Sema final : public SemaBase { bool SkipForSpecialization = false, bool ForDefaultArgumentSubstitution = false); + /// Apart from storing the result to \p Result, this behaves the same as + /// another overload. + void getTemplateI

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -,12 +,57 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -,12 +,57 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -,12 +,57 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -6089,16 +6090,16 @@ bool TreeTransform::TransformFunctionTypeParams( const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl &OutParamTypes, SmallVectorImpl *PVars, -Sema::ExtParameterInfoBuilder &PInfos, -unsigned *LastParamTransformed)

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -6089,16 +6090,16 @@ bool TreeTransform::TransformFunctionTypeParams( const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl &OutParamTypes, SmallVectorImpl *PVars, -Sema::ExtParameterInfoBuilder &PInfos, -unsigned *LastParamTransformed)

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-03 Thread Younan Zhang via cfe-commits
@@ -,12 +,57 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [Clang] Fix unexpanded packs in NTTP type constraints (PR #121296)

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

[clang] [Clang] Fix unexpanded packs in NTTP type constraints (PR #121296)

2025-01-03 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/121296 >From 102e031cae56c130f48f08bcb316b6f451facf49 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 29 Dec 2024 23:13:52 +0800 Subject: [PATCH 1/6] [Clang] Diagnose unexpanded packs for NTTP type constraints

[clang] [Clang] Fix unexpanded packs in NTTP type constraints (PR #121296)

2025-01-03 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/121296 >From 102e031cae56c130f48f08bcb316b6f451facf49 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 29 Dec 2024 23:13:52 +0800 Subject: [PATCH 1/5] [Clang] Diagnose unexpanded packs for NTTP type constraints

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

2025-01-02 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 commented: Here is an interesting case involving lambda captures: https://godbolt.org/z/Y7EhE7Gvq (Everything would become scary when lambda comes into play) https://github.com/llvm/llvm-project/pull/121417 ___ cfe-commits

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -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

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -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

[clang] [Clang] Fix unexpanded packs in NTTP type constraints (PR #121296)

2025-01-02 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/121296 >From 102e031cae56c130f48f08bcb316b6f451facf49 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 29 Dec 2024 23:13:52 +0800 Subject: [PATCH 1/5] [Clang] Diagnose unexpanded packs for NTTP type constraints

[clang] [Clang] Fix unexpanded packs in NTTP type constraints (PR #121296)

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

[clang] [Clang] Fix unexpanded packs in NTTP type constraints (PR #121296)

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

[clang] [Clang] Diagnose unexpanded packs for NTTP type constraints (PR #121296)

2025-01-02 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/121296 >From 102e031cae56c130f48f08bcb316b6f451facf49 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 29 Dec 2024 23:13:52 +0800 Subject: [PATCH 1/5] [Clang] Diagnose unexpanded packs for NTTP type constraints

[clang] [Clang] Diagnose unexpanded packs for NTTP type constraints (PR #121296)

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -857,7 +857,8 @@ class PackDeductionScope { if (auto *NTTP = dyn_cast( TemplateParams->getParam(Index))) { if (!NTTP->isExpandedParameterPack()) - if (auto *Expansion = dyn_cast(NTTP->getType())) + if (auto *Expansion = dyn_cast(

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2025-01-02 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @cor3ntin Do we still want to block on the getTemplateInstantiationArgs() stuff or move forward anyway so we can (hopefully) have this in the upcoming clang 20? FWIW, this patch currently doesn't rely on the refactoring, using only a ternary operand as a workaround for which it

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -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

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -7331,18 +7332,33 @@ void Parser::ParseDecompositionDeclarator(Declarator &D) { Diag(Tok, diag::err_expected_comma_or_rsquare); } -SkipUntil(tok::r_square, tok::comma, tok::identifier, - StopAtSemi | StopBeforeMatch); +//

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -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

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -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

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -210,6 +229,10 @@ class CollectUnexpandedParameterPacksVisitor bool TraversePackIndexingTypeLoc(PackIndexingTypeLoc TL) override { return DynamicRecursiveASTVisitor::TraverseStmt(TL.getIndexExpr()); } +bool +TraverseResolvedUnexpandedPackExpr(ResolvedUn

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -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

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

2025-01-02 Thread Younan Zhang via cfe-commits
@@ -757,23 +780,42 @@ 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-02 Thread Younan Zhang via 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

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

2025-01-02 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

  1   2   3   4   5   6   7   8   9   10   >