[clang] [AST] Iterate redecls starting from the canonical one in getRawCommentsForAnyRedecl() (PR #108475)

2024-09-16 Thread Younan Zhang via cfe-commits
zyn0217 wrote: > This is in turn because the [code that sets > this](https://searchfox.org/llvm/rev/3ae71d154e5dfb5e5a5d27b3699b27ce2b55f44d/clang/lib/AST/Comment.cpp#238-243) > is conditioned on FunctionDecl::getNumTemplateParameterLists() != 0. I was curious why it is relying on `getNumTempl

[clang] [AST] Iterate redecls starting from the canonical one in getRawCommentsForAnyRedecl() (PR #108475)

2024-09-16 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @HighCommander4 I extended your test case a little to validate the `TemplateDeclKind` we would have. ```cpp struct FoundComment { std::string DeclName; bool IsDefinition; std::string Comment; comments::DeclInfo::TemplateDeclKind TDK; // ... comparators are snipped ... }

[clang] [AST] Iterate redecls starting from the canonical one in getRawCommentsForAnyRedecl() (PR #108475)

2024-09-16 Thread Younan Zhang via cfe-commits
zyn0217 wrote: So the problem is that we would have another implicitly-created explicit template specialization `foo` in the process of the DeduceTemplateArguments, and that specialization would share the same `FunctionTemplateSpecializationInfo` with the eventual template specialization that

[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

2024-10-07 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/79 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Parser] Don't evaluate concept when its definition is invalid (PR #111179)

2024-10-07 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/79 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

2024-10-07 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/79 >From fc3e60d2c1d038ae3f3ef2e4ec3e86605cfb0f69 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 4 Oct 2024 23:42:30 +0800 Subject: [PATCH 1/3] [Clang][Parser] Remove the concept from the DeclContext if th

[clang] [clang] Track function template instantiation from definition (PR #110387)

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -1008,6 +1008,15 @@ class FunctionTemplateDecl : public RedeclarableTemplateDecl { return getTemplatedDecl()->isThisDeclarationADefinition(); } + bool isCompatibleWithDefinition() const { +return getTemplatedDecl()->isInstantiatedFromMemberTemplate() || +

[clang] [Clang][Sema] Fix exception specification comparison for functions with different template depths (PR #111561)

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -501,6 +519,89 @@ bool Sema::CheckEquivalentExceptionSpec( return Result; } +static const Expr *SubstituteExceptionSpecWithoutEvaluation( +Sema &S, const Sema::TemplateCompareNewDeclInfo &DeclInfo, +const Expr *ExceptionSpec) { + MultiLevelTemplateArgumentList ML

[clang] [Clang][Sema] Fix exception specification comparison for functions with different template depths (PR #111561)

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -501,6 +519,89 @@ bool Sema::CheckEquivalentExceptionSpec( return Result; } +static const Expr *SubstituteExceptionSpecWithoutEvaluation( +Sema &S, const Sema::TemplateCompareNewDeclInfo &DeclInfo, +const Expr *ExceptionSpec) { + MultiLevelTemplateArgumentList ML

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-11 Thread Younan Zhang via cfe-commits
@@ -478,3 +478,166 @@ A a{.f1 = {1}}; // CHECK-NEXT: `-DeclRefExpr {{.+}} 'int' NonTypeTemplateParm {{.+}} 'N' 'int' } // namespace GH83368 + +namespace GH60777 { + +template constexpr bool True() { return true; } + +template + requires(sizeof(T) == 4) +struct A { +

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

2024-10-11 Thread Younan Zhang via cfe-commits
@@ -1109,12 +1109,50 @@ 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)

2024-10-11 Thread Younan Zhang via cfe-commits
@@ -1109,12 +1109,50 @@ bool Sema::EnsureTemplateArgumentListConstraints( return false; } -bool Sema::CheckInstantiatedFunctionTemplateConstraints( +static bool CheckFunctionConstraintsWithoutInstantiation( +Sema &SemaRef, SourceLocation PointOfInstantiation, +Functi

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/112177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Check null TypeSourceInfo in CreateUnaryExprOrTypeTraitExpr (PR #112111)

2024-10-15 Thread Younan Zhang via cfe-commits
@@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +a() {struct b c (sizeof(b * [({ {tree->d* next)} 0 + +// expected-error@3 {{a type specifier is required for all declarations}} +// expected-error@3 {{use of undeclared identifier 'tree'; did you mean 'true'?}} +//

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/112177 >From 78657277495bbd1f82faef655c49320a4315272f Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 14 Oct 2024 17:42:17 +0800 Subject: [PATCH 1/4] [Clang] Fix a DeclContext mismatch when parsing nested lambd

[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 milestoned https://github.com/llvm/llvm-project/pull/111804 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

2024-10-14 Thread Younan Zhang via cfe-commits
zyn0217 wrote: I'll go ahead and backport it - this bug was first introduced by sugar preservation on CTAD guides included in the 19.x cycle. /backport 0bc02b999a https://github.com/llvm/llvm-project/pull/111804 ___ cfe-commits mailing list cfe-commi

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/112177 >From 78657277495bbd1f82faef655c49320a4315272f Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 14 Oct 2024 17:42:17 +0800 Subject: [PATCH] [Clang] Fix a DeclContext mismatch when parsing nested lambda pa

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-13 Thread Younan Zhang via cfe-commits
@@ -478,3 +478,166 @@ A a{.f1 = {1}}; // CHECK-NEXT: `-DeclRefExpr {{.+}} 'int' NonTypeTemplateParm {{.+}} 'N' 'int' } // namespace GH83368 + +namespace GH60777 { + +template constexpr bool True() { return true; } + +template + requires(sizeof(T) == 4) +struct A { +

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/112177 >From 78657277495bbd1f82faef655c49320a4315272f Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 14 Oct 2024 17:42:17 +0800 Subject: [PATCH 1/2] [Clang] Fix a DeclContext mismatch when parsing nested lambd

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/112177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/112177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/112177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/112177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/112177 Fixes #47400 Fixes #90896 >From f63455781f40986c247221de35bb9e35780d Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 14 Oct 2024 17:42:17 +0800 Subject: [PATCH] [Clang] Fix a DeclContext mismatch whe

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/112177 >From 78657277495bbd1f82faef655c49320a4315272f Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 14 Oct 2024 17:42:17 +0800 Subject: [PATCH 1/3] [Clang] Fix a DeclContext mismatch when parsing nested lambd

[clang] [Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (PR #112177)

2024-10-14 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 ready_for_review https://github.com/llvm/llvm-project/pull/112177 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [llvm] [clang] WIP: Improved Context Declaration tracking (PR #107942)

2024-10-15 Thread Younan Zhang via cfe-commits
@@ -17257,8 +17258,11 @@ void Sema::PushExpressionEvaluationContext( ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t, ExpressionEvaluationContextRecord::ExpressionKind ExprContext) { - Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextD

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

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -5585,11 +5585,12 @@ bool Sema::CheckTemplateArgumentList( ContextRAII Context(*this, NewContext); CXXThisScopeRAII(*this, RD, ThisQuals, RD != nullptr); -MultiLevelTemplateArgumentList MLTAL = getTemplateInstantiationArgs( -Template, NewContext, /*Final

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

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -1144,6 +1164,46 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints( PointOfInstantiation, Satisfaction); } +bool Sema::CheckFunctionConstraintsWithoutInstantiation( zyn0217 wrote: I moved it into CheckFunctionT

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

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -1397,12 +1415,25 @@ namespace { ArrayRef Unexpanded, bool &ShouldExpand, bool &RetainExpansion, std::optional &NumExpansions) { - return getSema().CheckParameterPacksForE

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

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -13051,11 +13051,14 @@ class Sema final : public SemaBase { /// instantiation arguments. /// /// \param DC In the event we don't HAVE a declaration yet, we instead provide - /// the decl context where it will be created. In this case, the `Innermost` - /// shoul

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

2024-10-08 Thread Younan Zhang via cfe-commits
zyn0217 wrote: (Sorry for picking up this late, and this is ready for the second round of review - apart from the `getTemplateInstantiationArgs()` pieces, which can be ditched after the MLTAL refactoring patch lands) https://github.com/llvm/llvm-project/pull/102857

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

2024-10-08 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)

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -1144,6 +1164,46 @@ bool Sema::CheckInstantiatedFunctionTemplateConstraints( PointOfInstantiation, Satisfaction); } +bool Sema::CheckFunctionConstraintsWithoutInstantiation( +SourceLocation PointOfInstantiation, FunctionTemplateDecl

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

2024-10-09 Thread Younan Zhang via cfe-commits
@@ -4008,6 +3996,38 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( Owner = FunctionTemplate->getLexicalDeclContext(); FunctionDecl *FD = FunctionTemplate->getTemplatedDecl(); + // C++20 [temp.deduct.general]p5: (CWG2369) + // If the function templat

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

2024-10-09 Thread Younan Zhang via cfe-commits
@@ -4042,8 +4062,8 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( // ([temp.constr.decl]), those constraints are checked for satisfaction // ([temp.constr.constr]). If the constraints are not satisfied, type // deduction fails. - if (!IsIncomple

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

2024-10-09 Thread Younan Zhang via cfe-commits
@@ -1517,7 +1555,7 @@ substituteParameterMappings(Sema &S, NormalizedConstraint &N, static bool substituteParameterMappings(Sema &S, NormalizedConstraint &N, const ConceptSpecializationExpr *CSE) { MultiLevelTemplateArgumentList MLTAL

[clang] [Clang] Avoid a crash when parsing an invalid pseudo-destructor (PR #111666)

2024-10-09 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. https://github.com/llvm/llvm-project/pull/111666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Avoid a crash when parsing an invalid pseudo-destructor (PR #111666)

2024-10-09 Thread Younan Zhang via cfe-commits
zyn0217 wrote: FYI it's https://github.com/llvm/llvm-project/issues/111460 https://github.com/llvm/llvm-project/pull/111666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (PR #111173)

2024-10-09 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @mstorsjo I think you can revert both -- @mizvekov's patch could get rid of this reliance in some other way. https://github.com/llvm/llvm-project/pull/73 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org

[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

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

[clang] [clang-tools-extra] Add code completion for C++20 keywords. (PR #107982)

2024-10-11 Thread Younan Zhang via cfe-commits
@@ -2265,6 +2318,12 @@ AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC, Results.AddResult(Result("template", CodeCompletionResult::RK_Keyword)); } +if (SemaRef.getLangOpts().CPlusPlus20 && +(CCC == SemaCodeCompletion::PCC_Template

[clang] [Clang][Parser] Don't evaluate concept when its definition is invalid (PR #111179)

2024-10-09 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/79 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

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

[clang] [clang] Track function template instantiation from definition (PR #110387)

2024-10-08 Thread Younan Zhang via cfe-commits
@@ -1008,6 +1008,15 @@ class FunctionTemplateDecl : public RedeclarableTemplateDecl { return getTemplatedDecl()->isThisDeclarationADefinition(); } + bool isCompatibleWithDefinition() const { +return getTemplatedDecl()->isInstantiatedFromMemberTemplate() || +

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-06 Thread Younan Zhang via cfe-commits
zyn0217 wrote: That's https://github.com/llvm/llvm-project/pull/85198. Which was merged prior to the generic solution fd87d765c0 by @sdkrystian https://github.com/llvm/llvm-project/pull/111277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org h

[clang] [clang] Don't lose track of explicit specializations of member functi… (PR #111267)

2024-10-05 Thread Younan Zhang via cfe-commits
@@ -4206,18 +4206,14 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation, if (Function->hasAttr()) continue; -MemberSpecializationInfo *MSInfo = -Function->getMemberSpecializationInfo(); -assert(MSInfo && "No memb

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-05 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 ready_for_review https://github.com/llvm/llvm-project/pull/111277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Track function template instantiation from definition (PR #110387)

2024-10-05 Thread Younan Zhang via cfe-commits
@@ -1994,8 +1995,10 @@ TemplateDeclInstantiator::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { // Link the instantiation back to the pattern *unless* this is a // non-definition friend declaration. if (!InstTemplate->getInstantiatedFromMemberTemplate() && - !

[clang] [clang] Track function template instantiation from definition (PR #110387)

2024-10-05 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/110387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)" (PR #111173)

2024-10-04 Thread Younan Zhang via cfe-commits
zyn0217 wrote: Can you also add the previous regressing case to the test? Thanks https://github.com/llvm/llvm-project/pull/106585#issuecomment-2368947247 https://github.com/llvm/llvm-project/pull/73 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

2024-10-04 Thread Younan Zhang via cfe-commits
@@ -1151,3 +1151,17 @@ int test() { } } + +namespace GH109780 { + +template +concept Concept; // expected-error {{expected '='}} + +bool val = Concept; // expected-error {{use of undeclared identifier 'Concept'}} zyn0217 wrote: It could be improved as to th

[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

2024-10-04 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/79 Since #103867, the nullness of the concept declaration has been turned to represent a state in which the concept definition is being parsed and used for self-reference checking. However, that PR missed a case

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-04 Thread Younan Zhang via cfe-commits
@@ -446,10 +450,46 @@ struct ConvertConstructorToDeductionGuideTransform { return nullptr; TypeSourceInfo *NewTInfo = TLB.getTypeSourceInfo(SemaRef.Context, NewType); +// At this point, the function parameters are already 'instantiated' in the +// current sco

[clang] [Clang][Sema] fix noexecpt mismatch of friend declaration (PR #102267)

2024-10-04 Thread Younan Zhang via cfe-commits
@@ -4698,7 +4698,22 @@ void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, // Enter the scope of this instantiation. We don't use // PushDeclContext because we don't have a scope. Sema::ContextRAII savedContext(*this, Decl); + + FunctionDecl *Source

[clang] [Clang][Sema] fix noexecpt mismatch of friend declaration (PR #102267)

2024-10-04 Thread Younan Zhang via cfe-commits
@@ -4698,7 +4698,22 @@ void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, // Enter the scope of this instantiation. We don't use // PushDeclContext because we don't have a scope. Sema::ContextRAII savedContext(*this, Decl); + + FunctionDecl *Source

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-04 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/43 Closes https://github.com/llvm/llvm-project/issues/98592 >From 567177e658ede96a59a22af14c9472e232391487 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 4 Oct 2024 20:22:59 +0800 Subject: [PATCH] [Clang]

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-04 Thread Younan Zhang via cfe-commits
@@ -478,3 +478,166 @@ A a{.f1 = {1}}; // CHECK-NEXT: `-DeclRefExpr {{.+}} 'int' NonTypeTemplateParm {{.+}} 'N' 'int' } // namespace GH83368 + +namespace GH60777 { + +template constexpr bool True() { return true; } + +template + requires(sizeof(T) == 4) +struct A { +

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-04 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/43 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

2024-10-04 Thread Younan Zhang via cfe-commits
@@ -337,6 +343,8 @@ Parser::ParseConceptDefinition(const ParsedTemplateInfo &TemplateInfo, ExprResult ConstraintExprResult = Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression()); if (ConstraintExprResult.isInvalid()) { +if (AddedToScope) ---

[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

2024-10-04 Thread Younan Zhang via cfe-commits
@@ -337,6 +343,8 @@ Parser::ParseConceptDefinition(const ParsedTemplateInfo &TemplateInfo, ExprResult ConstraintExprResult = Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression()); if (ConstraintExprResult.isInvalid()) { +if (AddedToScope) ---

[clang] [Clang][Sema] Refactor collection of multi-level template argument lists (PR #106585)

2024-09-29 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @sdkrystian do you plan to reland this patch in some other form these days? I'm going to restart my cwg 2369 work on top of it. https://github.com/llvm/llvm-project/pull/106585 ___ cfe-commits mailing list cfe-commits@lists.llvm.org htt

[clang] fix access checking about function overloading (PR #107768)

2024-09-30 Thread Younan Zhang via cfe-commits
zyn0217 wrote: What's the status here? https://github.com/llvm/llvm-project/pull/107768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[clang] Reland: Instantiate concepts with sugared template arguments (#101782)" (PR #102551)

2024-09-30 Thread Younan Zhang via cfe-commits
zyn0217 wrote: Looks like the regression is due to the sugar preservation caused declaration referenced by VLAs to make their way into the constraint evaluation, whereas they don't appear in the instantiation scope. Do you have any thoughts? https://github.com/llvm/llvm-project/pull/102551 __

[clang] [Clang] Implement CWG 2707 "Deduction guides cannot have a trailing requires-clause" (PR #110473)

2024-09-30 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/110473 >From f0692e16f08fc40865cc83aa6c3eb73f5d11144a Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 30 Sep 2024 16:57:14 +0800 Subject: [PATCH] [Clang] Implement CWG 2707 "Deduction guides cannot have a trail

[clang] [clang] Redeclare function templates instances per primary template (PR #110387)

2024-09-29 Thread Younan Zhang via cfe-commits
@@ -3949,28 +3949,15 @@ TemplateDeductionResult Sema::FinishTemplateArgumentDeduction( TemplateArgumentList::CreateCopy(Context, CanonicalBuilder); Info.reset(SugaredDeducedArgumentList, CanonicalDeducedArgumentList); + FunctionTemplate = FunctionTemplate->getMostRec

[clang] [clang] Redeclare function templates instances per primary template (PR #110387)

2024-09-29 Thread Younan Zhang via cfe-commits
@@ -2146,9 +2147,15 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl( FunctionDecl *SpecFunc = FunctionTemplate->findSpecialization(Innermost, InsertPos); -// If we already have a function template specialization, return it. -if (SpecFunc) - return S

[clang] [clang] Redeclare function templates instances per primary template (PR #110387)

2024-09-29 Thread Younan Zhang via cfe-commits
@@ -2146,9 +2147,15 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl( FunctionDecl *SpecFunc = FunctionTemplate->findSpecialization(Innermost, InsertPos); -// If we already have a function template specialization, return it. zyn0217 wrote: n

[clang] [clang] Redeclare function templates instances per primary template (PR #110387)

2024-09-29 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 commented: Thanks! https://github.com/llvm/llvm-project/pull/110387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Redeclare function templates instances per primary template (PR #110387)

2024-09-29 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/110387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Redeclare function templates instances per primary template (PR #110387)

2024-09-29 Thread Younan Zhang via cfe-commits
@@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++26 %s zyn0217 wrote: nit: we might want to move it to an existing file (so we don't have tests scattered around), but it's up to you if you feel the test is long enough to have a new file. http

[clang] [clang] Fix the local parameter of void type inside the `Requires` expression. (PR #109831)

2024-09-29 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. Makes sense to me. Thanks Please wait for other folks a day or two in case they have different opinions. https://github.com/llvm/llvm-project/pull/109831 ___ cfe-commits mailing list cfe-commits@l

[clang] [Clang] Implement CWG 2707 "Deduction guides cannot have a trailing requires-clause" (PR #110473)

2024-09-30 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/110473 Closes https://github.com/llvm/llvm-project/issues/98595 >From 0a0654909088b11eb360835999d67cc9d633ef91 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Mon, 30 Sep 2024 16:57:14 +0800 Subject: [PATCH] [Clang]

[clang] Add code completion for C++20 keywords. (PR #107982)

2024-09-29 Thread Younan Zhang via cfe-commits
zyn0217 wrote: > I am not sure which section I should add in clang/docs/ReleaseNotes.rst? > There isn't a section related to code completion. @16bit-ykiko There is an individual file for clang-tools-extras `clang-tools-extra/docs/ReleaseNotes.rst` which covers changes in clangd. See also http

[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-29 Thread Younan Zhang via cfe-commits
zyn0217 wrote: Slightly ping https://github.com/llvm/llvm-project/pull/109518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-05 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/111277 >From 995603864598bcb826db8477406ee5f17bbe0548 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 6 Oct 2024 12:46:21 +0800 Subject: [PATCH] [Clang] Remove the special-casing for RequiresExprBodyDecl in Bui

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-05 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/111277 The special-casing for RequiresExprBodyDecl caused a regression, as reported in #110785. This also merged the test for #84020 together with that of #110785 into clang/test/SemaTemplate/instantiate-requires-exp

[clang] [clang] Track function template instantiation from definition (PR #110387)

2024-10-05 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/110387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-06 Thread Younan Zhang via cfe-commits
zyn0217 wrote: > Can you make the description reflect that more clearly? Thanks! Done. https://github.com/llvm/llvm-project/pull/111277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-06 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/111277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-06 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 closed https://github.com/llvm/llvm-project/pull/111277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-06 Thread Younan Zhang via cfe-commits
zyn0217 wrote: /cherry-pick 8c1547055eaf65003f3e6fd024195f4926ff2356 https://github.com/llvm/llvm-project/pull/111277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (PR #111277)

2024-10-06 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 milestoned https://github.com/llvm/llvm-project/pull/111277 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][Parser] Remove the concept from the DeclContext if the definition is invalid (PR #111179)

2024-10-07 Thread Younan Zhang via cfe-commits
@@ -337,6 +343,8 @@ Parser::ParseConceptDefinition(const ParsedTemplateInfo &TemplateInfo, ExprResult ConstraintExprResult = Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression()); if (ConstraintExprResult.isInvalid()) { +if (AddedToScope) ---

[clang] [Serialization] Handle uninitialized type constraints (PR #110496)

2024-10-07 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @falbrechtskirchinger Ooops, yes, it's true that the bug is gone w/ #79. But I'd say if we're going to cherry-pick #79, we have to backport its precedent #103867 as well, so I think we can probably go ahead with this one and backport it to 19, and then we can revert this

[clang] [Serialization] Handle uninitialized type constraints (PR #110496)

2024-10-07 Thread Younan Zhang via cfe-commits
zyn0217 wrote: > To summarize: Land this PR and backport it. Revert on trunk. Submit new PR > for the regression test? (We want to keep that, right?) That's just my idea, and I'd like Corentin to say something about it :) https://github.com/llvm/llvm-project/pull/110496 ___

[clang] [Serialization] Handle uninitialized type constraints (PR #110496)

2024-10-07 Thread Younan Zhang via cfe-commits
zyn0217 wrote: @vient I think we can, yes https://github.com/llvm/llvm-project/pull/110496 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Serialization] Handle uninitialized type constraints (PR #110496)

2024-10-07 Thread Younan Zhang via cfe-commits
zyn0217 wrote: #79 aims for a different case (and that is a follow-up for @cor3ntin's recursive concept patch, which is not yet merged into 19, I think), while this one is related to a serialization bug that has persisted for some time. https://github.com/llvm/llvm-project/pull/110496

[clang] [Clang] Implement CWG 2628 "Implicit deduction guides should propagate constraints" (PR #111143)

2024-10-07 Thread Younan Zhang via cfe-commits
@@ -478,3 +478,166 @@ A a{.f1 = {1}}; // CHECK-NEXT: `-DeclRefExpr {{.+}} 'int' NonTypeTemplateParm {{.+}} 'N' 'int' } // namespace GH83368 + +namespace GH60777 { + +template constexpr bool True() { return true; } + +template + requires(sizeof(T) == 4) +struct A { +

[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

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

[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

2024-10-01 Thread Younan Zhang via cfe-commits
@@ -9519,15 +9519,28 @@ Sema::ActOnStartRequiresExpr(SourceLocation RequiresKWLoc, } else if (Param->getType().hasQualifiers()) { Diag(Param->getBeginLoc(), diag::err_void_param_qualified); } -} - -if (Param->hasDefaultArg()) +} else if (Param->

[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)

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

[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)

2024-10-18 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/112896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)

2024-10-18 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/112896 Nested lambdas could refer to outer packs that would be expanded by a larger CXXFoldExpr, in which case that reference could happen to be a full expression containing intermediate types/expressions, e.g. Subst

[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)

2024-10-18 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/112896 >From 6caf16d6ce8eb939c91ed87493c2ccab82d38411 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 18 Oct 2024 20:22:08 +0800 Subject: [PATCH 1/2] [Clang] Don't assert on substituted-but-yet-expanded packs f

[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)

2024-10-20 Thread Younan Zhang via cfe-commits
@@ -94,3 +94,45 @@ template void g2(Ts... p1s) { void f1() { g(); } } // namespace GH61460 + +namespace GH112352 { + +template +constexpr bool foo = false; + +template +constexpr bool bar = false; + +template class> +constexpr bool baz = false; + +struct S { + template v

[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)

2024-10-20 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/112896 >From 6caf16d6ce8eb939c91ed87493c2ccab82d38411 Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Fri, 18 Oct 2024 20:22:08 +0800 Subject: [PATCH 1/3] [Clang] Don't assert on substituted-but-yet-expanded packs f

[clang] [Concepts] Add regression test for #99036 (PR #113137)

2024-10-21 Thread Younan Zhang via cfe-commits
https://github.com/zyn0217 approved this pull request. LGTM, thanks (I still would like to see @cor3ntin confirm if it is feasible to backport #103867 to 19 so the issue you're suffering from can be resolved without adding much churn) https://github.com/llvm/llvm-project/pull/113137 _

[clang] [Clang] Don't assert on substituted-but-yet-expanded packs for nested lambdas (PR #112896)

2024-10-20 Thread Younan Zhang via cfe-commits
@@ -8385,14 +8385,19 @@ TreeTransform::TransformDeclStmt(DeclStmt *S) { if (Transformed != D) DeclChanged = true; -if (LSI && isa(Transformed)) - LSI->ContainsUnexpandedParameterPack |= - getSema() - .getASTContext() - .get

<    6   7   8   9   10   11   12   13   14   15   >