[clang] [Clang] use constant evaluation context for constexpr if conditions (PR #123667)

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

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

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

[clang] [Clang] use constant evaluation context for constexpr if conditions (PR #123667)

2025-01-24 Thread Younan Zhang via cfe-commits
@@ -977,6 +977,7 @@ Bug Fixes to C++ Support - Fix immediate escalation not propagating through inherited constructors. (#GH112677) - Fixed assertions or false compiler diagnostics in the case of C++ modules for lambda functions or inline friend functions defined inside tem

[clang] [Clang][Sema] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

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

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-20 Thread Younan Zhang via cfe-commits
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, AccessSpecifier AS, } TemplateParameterList *TemplateParams = TemplateParamLists[0]; +// Check shadowing of a template parameter name +for (NamedDecl *TP : TemplateParams->asArray()) { +

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-20 Thread Younan Zhang via cfe-commits
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, AccessSpecifier AS, } TemplateParameterList *TemplateParams = TemplateParamLists[0]; +// Check shadowing of a template parameter name +for (NamedDecl *TP : TemplateParams->asArray()) { +

[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
@@ -757,23 +775,40 @@ bool Sema::CheckParameterPacksForExpansion( bool HaveFirstPack = false; std::optional NumPartialExpansions; SourceLocation PartiallySubstitutedPackLoc; + typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack; for (UnexpandedParamet

[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

2025-01-19 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Just a thought from my side, but not required at the moment because this aims to be as simple as possible. Otherwise LGTM https://github.com/llvm/llvm-project/pull/123551 ___ cfe-commits mailing l

[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

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

[clang] [clang-tools-extra] [clang][Sema] Respect const-qualification of methods in heuristic results (PR #123551)

2025-01-19 Thread Younan Zhang via cfe-commits
@@ -422,7 +425,15 @@ std::vector HeuristicResolverImpl::resolveDependentMember( if (!RD->hasDefinition()) return {}; RD = RD->getDefinition(); -return lookupDependentName(RD, Name, Filter); +return lookupDependentName(RD, Name, [&](const NamedDecl *ND) {

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Younan Zhang via cfe-commits
@@ -191,4 +192,4 @@ int g = sfinae_me(); // expected-error{{no matching function for call to 's namespace NullExceptionDecl { template auto get = []() { try { } catch(...) {}; return I; }; // expected-error{{initializer contains unexpanded parameter pack 'I'}} -} +}

[clang] [Clang] Reject declaring an alias template with the same name as its template parameter. (PR #123533)

2025-01-19 Thread Younan Zhang via cfe-commits
@@ -13464,6 +13464,14 @@ Decl *Sema::ActOnAliasDeclaration(Scope *S, AccessSpecifier AS, } TemplateParameterList *TemplateParams = TemplateParamLists[0]; +// Check shadowing of a template parameter name +for (NamedDecl *TP : TemplateParams->asArray()) { +

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

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

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

2025-01-20 Thread Younan Zhang via cfe-commits
zyn0217 wrote: > There is something generally wrong with type aliases which don't use all of > their parameters, and this needs more thought. The current approach - bubbling up the containsUnexpanded flag within a transform - is admittedly not ideal. However, it's the only way to make Clang c

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

2025-01-20 Thread Younan Zhang via cfe-commits
Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?=, Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID: In-Reply-To: @@ -1983,15 +1983,17 @@ void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {

[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] Correctly determine constexprness of dependent lambdas. (PR #124468)

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

[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)

2025-01-27 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/124533 We used to always transform the pattern declaration for SizeOfPackExpr to ensure the constraint expression's profile produced the desired result. However, this approach failed to handle pack expansions when the

[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)

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

[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)

2025-01-27 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/124533 >From b195bfb253df84ea315eb92a59bbae2401b0248f Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 27 Jan 2025 19:48:43 +0800 Subject: [PATCH 1/2] [Clang] Remove unnecessary Decl transform & profiles for Siz

[clang] [libcxxabi] [llvm] [Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

2025-01-26 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 commented: Hmm, I'm unfamiliar with the libcxx/LLVM demangler part, but it does look like we're duplicating something. Can anyone explain why we have to do that? https://github.com/llvm/llvm-project/pull/123513 ___ cfe-commi

[clang] [libcxxabi] [llvm] [Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

2025-01-26 Thread Younan Zhang via cfe-commits
@@ -1003,6 +1003,7 @@ Bug Fixes to C++ Support lambda functions or inline friend functions defined inside templates (#GH122493). - Clang now rejects declaring an alias template with the same name as its template parameter. (#GH123423) - Correctly determine the implicit cons

[clang] [libcxxabi] [llvm] [Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

2025-01-26 Thread Younan Zhang via cfe-commits
@@ -4787,6 +4788,7 @@ void CXXNameMangler::mangleRequirement(SourceLocation RequiresExprLoc, void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity, bool AsTemplateArg) { + // clang-format off zyn0217 wrote:

[clang] [libcxxabi] [llvm] [Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

2025-01-26 Thread Younan Zhang via cfe-commits
@@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-linux-gnu -std=c++2a | FileCheck %s + +namespace spaceship { + struct X {}; + struct Y {}; + int operator<=>(X, Y); + + // CHECK-LABEL: define {{.*}} @_ZN9spaceship1fIiEEvDTcmltcvNS_1YE_EcvNS_1XE_EcvT__EE

[clang] [libcxxabi] [llvm] [Clang] Mangling of pack indexing type and expression for itanium (PR #123513)

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

[clang] [clang][Sema] Unwrap reference types in HeuristicResolverImpl::resolveTypeToRecordDecl() (PR #124451)

2025-01-26 Thread Younan Zhang via cfe-commits
@@ -133,8 +133,8 @@ TemplateName getReferencedTemplateName(const Type *T) { CXXRecordDecl *HeuristicResolverImpl::resolveTypeToRecordDecl(const Type *T) { assert(T); - // Unwrap type sugar such as type aliases. - T = T->getCanonicalTypeInternal().getTypePtr(); + // Unwrap

[clang] [Sema] Fix __array_rank queried type at template instantiation (PR #124491)

2025-01-26 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Thanks, the changes LGTM. I'll help you merge it if there are no other comments within today. https://github.com/llvm/llvm-project/pull/124491 ___ cfe-commits mailing list cfe-commits@lists.llvm.o

[clang] [clang][Sema] Handle dependent qualifier in HeuristicResolver::resolveDeclRefExpr() (PR #124515)

2025-01-26 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/124515 ___ 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-27 Thread Younan Zhang via cfe-commits
@@ -5284,8 +5284,22 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, savedContext.pop(); } - DeclGroupRef DG(Function); - Consumer.HandleTopLevelDecl(DG); + // With CWG2369, we substitute constraints before instantiating the associate

[clang] [Clang] Skip past code generation for unevaluated lambdas (PR #124572)

2025-01-27 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/124572 This is taken from https://github.com/llvm/llvm-project/pull/122423#discussion_r1930102632 as suggested by Corentin. Fixes #82926 >From f515e670d35365f14f063e02eb10cd41e3751937 Mon Sep 17 00:00:00 2001 From:

[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)

2025-01-27 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/124533 ___ 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 #124675)

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

[clang] [clang][Sema] Generalize HeuristicResolver::resolveTypeToRecordDecl() to resolveTypeToTagDecl() (PR #124699)

2025-01-27 Thread Younan Zhang via cfe-commits
@@ -389,11 +390,11 @@ bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath &Path, bool HeuristicResolverImpl::findOrdinaryMemberInDependentClasses( const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name) { - CXXRecordDecl *RD = - resol

[clang] [clang][Sema] Generalize HeuristicResolver::resolveTypeToRecordDecl() to resolveTypeToTagDecl() (PR #124699)

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

[clang] [clang][Sema] Generalize HeuristicResolver::resolveTypeToRecordDecl() to resolveTypeToTagDecl() (PR #124699)

2025-01-27 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. One nit, else LGTM https://github.com/llvm/llvm-project/pull/124699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Remove unnecessary Decl transform & profiles for SizeOfPackExpr (PR #124533)

2025-01-27 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @shafik @AaronBallman Here is the complete backstory: We were not performing well in out-of-line concept comparison, especially for expressions involving packs. I tried to address these issues around commit 04d20b170, but it quickly became evident that the fix was insufficient f

[clang] [Clang] SubstituteConstraintExpressionWithoutSatisfaction needs an unevaluated context (PR #123883)

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

[clang] [clang][CodeComplete] Use HeuristicResolver to resolve pointee types (PR #121315)

2025-01-21 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Looks great, thanks https://github.com/llvm/llvm-project/pull/121315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] SubstituteConstraintExpressionWithoutSatisfaction needs an unevaluated context (PR #123883)

2025-01-21 Thread Younan Zhang via cfe-commits
@@ -248,6 +248,25 @@ ExprResult Parser::ParseArrayBoundExpression() { // If we parse the bound of a VLA... we parse a non-constant // constant-expression! Actions.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true; + // For a VLA type inside an uneval

[clang] [Clang] SubstituteConstraintExpressionWithoutSatisfaction needs an unevaluated context (PR #123883)

2025-01-21 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/123883 >From 5427c748811041d0878dc4aec8b7b37c4241af37 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Tue, 21 Jan 2025 20:21:20 +0800 Subject: [PATCH 1/3] [Clang] SubstituteConstraintExpressionWithoutSatisfaction ne

[clang] [Clang] SubstituteConstraintExpressionWithoutSatisfaction needs an unevaluated context (PR #123883)

2025-01-21 Thread Younan Zhang via cfe-commits
@@ -248,6 +248,25 @@ ExprResult Parser::ParseArrayBoundExpression() { // If we parse the bound of a VLA... we parse a non-constant // constant-expression! Actions.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true; + // For a VLA type inside an uneval

[clang] [clang][CodeComplete] Use HeuristicResolver to resolve CXXDependentScopeMemberExpr (PR #124888)

2025-01-29 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Neat! https://github.com/llvm/llvm-project/pull/124888 ___ 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-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] 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] 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][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] [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-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] [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 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] [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
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 +,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
@@ -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 +,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 +,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] [Clang] Resolved type of expression indexing into pack of values of a non-dependent type (PR #121405)

2024-12-31 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/121405 ___ 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)

2024-12-31 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 ready_for_review 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)

2024-12-31 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/4] [Clang] Diagnose unexpanded packs for NTTP type constraints

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

2024-12-31 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 converted_to_draft 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] 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] 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-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] 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] 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] [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] 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][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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 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
@@ -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
@@ -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
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-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] [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 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] Diagnose unexpanded packs for NTTP type constraints (PR #121296)

2024-12-30 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 ready_for_review 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][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
@@ -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
@@ -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
@@ -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
@@ -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
https://github.com/zyn0217 commented: Thanks for working on this. I left some comments, and I think we need more tests for contexts e.g. templated member functions/nested dependent lambdas to test the state machine in TreeTransform, apart from @cor3ntin's request. Moreover, you may need to bui

[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

[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

<    10   11   12   13   14   15   16   17   18   19   >