[llvm-branch-commits] [clang] [libcxx] [llvm] [clang-tools-extra] [compiler-rt] [openmp] [lld] PR for llvm/llvm-project#79568 (PR #80120)

2024-02-05 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/80120

>From 16a8c31d342abed9c02493445c14c1bc7fd1519e Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 27 Jan 2024 15:42:52 +0800
Subject: [PATCH] [Concepts] Traverse the instantiation chain for parameter
 injection inside a constraint scope (#79568)

We preserve the trailing requires-expression during the lambda
expression transformation. In order to get those referenced parameters
inside a requires-expression properly resolved to the instantiated
decls, we intended to inject these 'original' `ParmVarDecls` to the
current instantiaion scope, at `Sema::SetupConstraintScope`.

The previous approach seems to overlook nested instantiation chains,
leading to the crash within a nested lambda followed by a requires
clause.

This fixes https://github.com/llvm/llvm-project/issues/73418.
---
 clang/docs/ReleaseNotes.rst |  4 
 clang/lib/Sema/SemaConcept.cpp  |  8 ++--
 clang/test/SemaTemplate/concepts-lambda.cpp | 18 ++
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 060bc7669b72a..da52d5ac4d3c6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1054,6 +1054,10 @@ Bug Fixes to C++ Support
   Fixes (`#78830 `_)
   Fixes (`#60085 `_)
 
+- Fixed a bug where variables referenced by requires-clauses inside
+  nested generic lambdas were not properly injected into the constraint scope.
+  (`#73418 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index acfc00f412540..88fc846c89e42 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -612,8 +612,12 @@ bool Sema::SetupConstraintScope(
 
 // If this is a member function, make sure we get the parameters that
 // reference the original primary template.
-if (const auto *FromMemTempl =
-PrimaryTemplate->getInstantiatedFromMemberTemplate()) {
+// We walk up the instantiated template chain so that nested lambdas get
+// handled properly.
+for (FunctionTemplateDecl *FromMemTempl =
+ PrimaryTemplate->getInstantiatedFromMemberTemplate();
+ FromMemTempl;
+ FromMemTempl = FromMemTempl->getInstantiatedFromMemberTemplate()) {
   if (addInstantiatedParametersToScope(FD, 
FromMemTempl->getTemplatedDecl(),
Scope, MLTAL))
 return true;
diff --git a/clang/test/SemaTemplate/concepts-lambda.cpp 
b/clang/test/SemaTemplate/concepts-lambda.cpp
index 7e431529427df..0b7580f91043c 100644
--- a/clang/test/SemaTemplate/concepts-lambda.cpp
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -149,3 +149,21 @@ void foo() {
   auto caller = make_caller.operator()<&S1::f1>();
 }
 } // namespace ReturnTypeRequirementInLambda
+
+namespace GH73418 {
+void foo() {
+  int x;
+  [&x](auto) {
+return [](auto y) {
+  return [](auto obj, auto... params)
+requires requires {
+  sizeof...(params);
+  [](auto... pack) {
+return sizeof...(pack);
+  }(params...);
+}
+  { return false; }(y);
+}(x);
+  }(x);
+}
+} // namespace GH73418

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [libcxx] [llvm] [clang-tools-extra] [compiler-rt] [openmp] [lld] PR for llvm/llvm-project#79568 (PR #80120)

2024-02-05 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

@tstellar Would you mind merging this PR? Thank you in advance!

https://github.com/llvm/llvm-project/pull/80120
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/18.x: [clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542) (PR #84117)

2024-03-15 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

I think this merits a backport as we don't actually want this crash on some std 
libraries delays to 19.0.

> (Does the backport need to be reviewed separately? Not sure what is the 
> process these days.)

@HighCommander4 : Yes. And we shall ping our release manager @tstellar and 
hopefully we can make it in 18.2.



https://github.com/llvm/llvm-project/pull/84117
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/18.x: [clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542) (PR #84117)

2024-03-15 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

Oh, I saw PR https://github.com/llvm/llvm-project/pull/84436 just now. Do you 
think this needs a release note?
(I don't know if you (or we, the members) have access to the backport branch; 
if not, you probably need a separate PR (close this one and open a new manually 
and target that PR to 18.x release branch) for this. )

https://github.com/llvm/llvm-project/pull/84117
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/18.x: [clangd] [HeuristicResolver] Protect against infinite recursion on DependentNameTypes (#83542) (PR #84117)

2024-03-15 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

> There is an umbrella entry in the release notes for "Various stability 
> improvements, e.g. crash fixes".

Ah, although that sounds a bit unclear. :)
Alright, I think it is probably fine for clangd to not to detail what crashes 
we had fixed, as crashes from clangd itself are pretty rare these days.

https://github.com/llvm/llvm-project/pull/84117
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: Backport PR86914 "Fix a CTAD regression after 42239d2e9" (PR #87084)

2024-03-29 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/87084

This fixes a regression that was introduced in 18, which we don't want to carry 
it over to 19 anyways.


>From 997ea41a48a94e92ebe47ac5345428582b32d967 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 29 Mar 2024 23:28:54 +0800
Subject: [PATCH] [clang][Sema] Fix a CTAD regression after 42239d2e9 (#86914)

The most recent declaration of a template as a friend can introduce a
different template parameter depth compared to what we anticipate from a
CTAD guide.

Fixes https://github.com/llvm/llvm-project/issues/86769
---
 clang/docs/ReleaseNotes.rst  |  4 +++
 clang/lib/Sema/SemaTemplate.cpp  | 22 -
 clang/test/SemaTemplate/concepts-friends.cpp | 26 
 clang/test/SemaTemplate/ctad.cpp |  2 +-
 4 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d4401a43c123e7..ebeb47a871e27b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1106,6 +1106,10 @@ Bug Fixes to C++ Support
 - Fix a crash when an unresolved overload set is encountered on the RHS of a 
``.*`` operator.
   (`#53815 `_)
 
+- Fixed a regression in CTAD that a friend declaration that befriends itself 
may cause
+  incorrect constraint substitution.
+  (`#86769 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index a381d876a54c67..b619f5d729e86b 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1830,7 +1830,27 @@ static TemplateParameterList 
*GetTemplateParameterList(TemplateDecl *TD) {
   // Make sure we get the template parameter list from the most
   // recent declaration, since that is the only one that is guaranteed to
   // have all the default template argument information.
-  return cast(TD->getMostRecentDecl())->getTemplateParameters();
+  Decl *D = TD->getMostRecentDecl();
+  // C++11 [temp.param]p12:
+  // A default template argument shall not be specified in a friend class
+  // template declaration.
+  //
+  // Skip past friend *declarations* because they are not supposed to contain
+  // default template arguments. Moreover, these declarations may introduce
+  // template parameters living in different template depths than the
+  // corresponding template parameters in TD, causing unmatched constraint
+  // substitution.
+  //
+  // FIXME: Diagnose such cases within a class template:
+  //  template 
+  //  struct S {
+  //template  friend struct C;
+  //  };
+  //  template struct S;
+  while (D->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None &&
+ D->getPreviousDecl())
+D = D->getPreviousDecl();
+  return cast(D)->getTemplateParameters();
 }
 
 DeclResult Sema::CheckClassTemplate(
diff --git a/clang/test/SemaTemplate/concepts-friends.cpp 
b/clang/test/SemaTemplate/concepts-friends.cpp
index 255b0858917fb6..0b008811f13621 100644
--- a/clang/test/SemaTemplate/concepts-friends.cpp
+++ b/clang/test/SemaTemplate/concepts-friends.cpp
@@ -478,3 +478,29 @@ template  class Foo {
 };
 
 } // namespace FriendOfFriend
+
+namespace GH86769 {
+
+template 
+concept X = true;
+
+template  struct Y {
+  Y(T) {}
+  template  friend struct Y;
+  template  friend struct Y;
+  template  friend struct Y;
+};
+
+template 
+struct Z {
+  // FIXME: This is ill-formed per C++11 [temp.param]p12:
+  // A default template argument shall not be specified in a friend class
+  // template declaration.
+  template  friend struct Y;
+};
+
+template struct Y;
+template struct Z;
+Y y(1);
+
+}
diff --git a/clang/test/SemaTemplate/ctad.cpp b/clang/test/SemaTemplate/ctad.cpp
index 388ed7d4cced18..ec144d4f44ba8c 100644
--- a/clang/test/SemaTemplate/ctad.cpp
+++ b/clang/test/SemaTemplate/ctad.cpp
@@ -53,4 +53,4 @@ X x;
 template struct Y { Y(T); };
 template struct Y ;
 Y y(1);
-};
+}

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: Backport PR86914 "Fix a CTAD regression after 42239d2e9" (PR #87084)

2024-03-29 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 milestoned 
https://github.com/llvm/llvm-project/pull/87084
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: Backport PR86914 "Fix a CTAD regression after 42239d2e9" (PR #87084)

2024-04-01 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

@tstellar thanks!

> Fixed a regression in CTAD of clang 18 that a friend declaration that 
> befriends itself may cause incorrect constraint substitution.

is just fine to me.

https://github.com/llvm/llvm-project/pull/87084
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] CTAD alias: fix the transformation for the require-clause expr (PR #90961)

2024-05-03 Thread Younan Zhang via llvm-branch-commits


@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, 
DeclContext *DC) {
   return false;
 }
 
+unsigned getTemplateDepth(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getDepth();
+  llvm_unreachable("Unhandled template parameter types");
+}
+
 NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC,
   NamedDecl *TemplateParam,
   MultiLevelTemplateArgumentList &Args,
-  unsigned NewIndex) {
+  unsigned NewIndex, unsigned NewDepth) {
   if (auto *TTP = dyn_cast(TemplateParam))
-return transformTemplateTypeParam(SemaRef, DC, TTP, Args, TTP->getDepth(),
+return transformTemplateTypeParam(SemaRef, DC, TTP, Args, NewDepth,
   NewIndex);
   if (auto *TTP = dyn_cast(TemplateParam))
 return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex,
-  TTP->getDepth());
+  NewDepth);
   if (auto *NTTP = dyn_cast(TemplateParam))
 return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex,
-  NTTP->getDepth());
+  NewDepth);
   llvm_unreachable("Unhandled template parameter types");
 }
 
-Expr *transformRequireClause(Sema &SemaRef, FunctionTemplateDecl *FTD,
- llvm::ArrayRef TransformedArgs) 
{
-  Expr *RC = FTD->getTemplateParameters()->getRequiresClause();
+// Transform the require-clause of F if any.
+// The return result is expected to be the require-clause for the synthesized
+// alias deduction guide.
+Expr *transformRequireClause(
+Sema &SemaRef, FunctionTemplateDecl *F,
+TypeAliasTemplateDecl *AliasTemplate,
+ArrayRef DeduceResults) {
+  Expr *RC = F->getTemplateParameters()->getRequiresClause();
   if (!RC)
 return nullptr;
+
+  auto &Context = SemaRef.Context;
+  LocalInstantiationScope Scope(SemaRef);
+
+  // In the clang AST, constraint nodes are not instantiated at all unless they
+  // are being evaluated. This means that occurrences of template parameters
+  // in the require-clause expr have subtle differences compared to occurrences
+  // in other places, such as function parameters. When transforming the
+  // require-clause, we must respect these differences, particularly regarding
+  // the 'depth' information:
+  //   1) In the transformed require-clause, occurrences of template parameters
+  //   must use the "uninstantiated" depth;
+  //   2) When substituting on the require-clause expr of the underlying
+  //   deduction guide, we must use the entire set of template argument lists.
+  //
+  // It's important to note that we're performing this transformation on an
+  // *instantiated* AliasTemplate.
+
+  // For 1), if the alias template is nested within a class template, we
+  // calcualte the 'uninstantiated' depth by adding the substitution level 
back.
+  unsigned AdjustDepth = 0;
+  if (auto *PrimaryTemplate = 
AliasTemplate->getInstantiatedFromMemberTemplate())

zyn0217 wrote:

Should it be a while loop?

https://github.com/llvm/llvm-project/pull/90961
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] CTAD alias: fix the transformation for the require-clause expr (PR #90961)

2024-05-03 Thread Younan Zhang via llvm-branch-commits


@@ -2744,31 +2744,155 @@ bool hasDeclaredDeductionGuides(DeclarationName Name, 
DeclContext *DC) {
   return false;
 }
 
+unsigned getTemplateDepth(NamedDecl *TemplateParam) {
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *TTP = dyn_cast(TemplateParam))
+return TTP->getDepth();
+  if (auto *NTTP = dyn_cast(TemplateParam))
+return NTTP->getDepth();
+  llvm_unreachable("Unhandled template parameter types");
+}
+
 NamedDecl *transformTemplateParameter(Sema &SemaRef, DeclContext *DC,
   NamedDecl *TemplateParam,
   MultiLevelTemplateArgumentList &Args,
-  unsigned NewIndex) {
+  unsigned NewIndex, unsigned NewDepth) {
   if (auto *TTP = dyn_cast(TemplateParam))
-return transformTemplateTypeParam(SemaRef, DC, TTP, Args, TTP->getDepth(),
+return transformTemplateTypeParam(SemaRef, DC, TTP, Args, NewDepth,
   NewIndex);
   if (auto *TTP = dyn_cast(TemplateParam))
 return transformTemplateParam(SemaRef, DC, TTP, Args, NewIndex,
-  TTP->getDepth());
+  NewDepth);
   if (auto *NTTP = dyn_cast(TemplateParam))
 return transformTemplateParam(SemaRef, DC, NTTP, Args, NewIndex,
-  NTTP->getDepth());
+  NewDepth);
   llvm_unreachable("Unhandled template parameter types");
 }
 
-Expr *transformRequireClause(Sema &SemaRef, FunctionTemplateDecl *FTD,
- llvm::ArrayRef TransformedArgs) 
{
-  Expr *RC = FTD->getTemplateParameters()->getRequiresClause();
+// Transform the require-clause of F if any.
+// The return result is expected to be the require-clause for the synthesized
+// alias deduction guide.
+Expr *transformRequireClause(
+Sema &SemaRef, FunctionTemplateDecl *F,
+TypeAliasTemplateDecl *AliasTemplate,
+ArrayRef DeduceResults) {
+  Expr *RC = F->getTemplateParameters()->getRequiresClause();
   if (!RC)
 return nullptr;
+
+  auto &Context = SemaRef.Context;
+  LocalInstantiationScope Scope(SemaRef);
+
+  // In the clang AST, constraint nodes are not instantiated at all unless they
+  // are being evaluated. This means that occurrences of template parameters
+  // in the require-clause expr have subtle differences compared to occurrences
+  // in other places, such as function parameters. When transforming the
+  // require-clause, we must respect these differences, particularly regarding
+  // the 'depth' information:
+  //   1) In the transformed require-clause, occurrences of template parameters
+  //   must use the "uninstantiated" depth;
+  //   2) When substituting on the require-clause expr of the underlying
+  //   deduction guide, we must use the entire set of template argument lists.
+  //
+  // It's important to note that we're performing this transformation on an
+  // *instantiated* AliasTemplate.
+
+  // For 1), if the alias template is nested within a class template, we
+  // calcualte the 'uninstantiated' depth by adding the substitution level 
back.
+  unsigned AdjustDepth = 0;
+  if (auto *PrimaryTemplate = 
AliasTemplate->getInstantiatedFromMemberTemplate())
+AdjustDepth = PrimaryTemplate->getTemplateDepth();
+  
+  // We rebuild all template parameters with the uninstantiated depth, and
+  // build template arguments refer to them.
+  SmallVector AdjustedAliasTemplateArgs;
+
+  for (auto *TP : *AliasTemplate->getTemplateParameters()) {
+// Rebuild any internal references to earlier parameters and reindex
+// as we go.
+MultiLevelTemplateArgumentList Args;
+Args.setKind(TemplateSubstitutionKind::Rewrite);
+Args.addOuterTemplateArguments(AdjustedAliasTemplateArgs);
+NamedDecl *NewParam = transformTemplateParameter(
+SemaRef, AliasTemplate->getDeclContext(), TP, Args,
+/*NewIndex=*/AdjustedAliasTemplateArgs.size(),
+getTemplateDepth(TP) + AdjustDepth);
+
+auto NewTemplateArgument = Context.getCanonicalTemplateArgument(
+Context.getInjectedTemplateArg(NewParam));
+AdjustedAliasTemplateArgs.push_back(NewTemplateArgument);
+  }
+  // Template arguments used to transform the template arguments in
+  // DeducedResults.
+  SmallVector TemplateArgsForBuildingRC(
+  F->getTemplateParameters()->size());
+  // Transform the transformed template args
   MultiLevelTemplateArgumentList Args;
   Args.setKind(TemplateSubstitutionKind::Rewrite);
-  Args.addOuterTemplateArguments(TransformedArgs);
-  ExprResult E = SemaRef.SubstExpr(RC, Args);
+  Args.addOuterTemplateArguments(AdjustedAliasTemplateArgs);
+
+  for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
+const auto &D = DeduceResults[Index];
+if (D.isNull())
+  continue;
+TemplateArgumentLoc Input =
+SemaRef.getTrivialTemplateArgum

[llvm-branch-commits] [clang] PR for llvm/llvm-project#79568 (PR #80120)

2024-01-31 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 milestoned 
https://github.com/llvm/llvm-project/pull/80120
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#79568 (PR #80120)

2024-01-31 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/80120

Backporting https://github.com/llvm/llvm-project/pull/79568 to clang 18.

>From 16a8c31d342abed9c02493445c14c1bc7fd1519e Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 27 Jan 2024 15:42:52 +0800
Subject: [PATCH] [Concepts] Traverse the instantiation chain for parameter
 injection inside a constraint scope (#79568)

We preserve the trailing requires-expression during the lambda
expression transformation. In order to get those referenced parameters
inside a requires-expression properly resolved to the instantiated
decls, we intended to inject these 'original' `ParmVarDecls` to the
current instantiaion scope, at `Sema::SetupConstraintScope`.

The previous approach seems to overlook nested instantiation chains,
leading to the crash within a nested lambda followed by a requires
clause.

This fixes https://github.com/llvm/llvm-project/issues/73418.
---
 clang/docs/ReleaseNotes.rst |  4 
 clang/lib/Sema/SemaConcept.cpp  |  8 ++--
 clang/test/SemaTemplate/concepts-lambda.cpp | 18 ++
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 060bc7669b72a..da52d5ac4d3c6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1054,6 +1054,10 @@ Bug Fixes to C++ Support
   Fixes (`#78830 `_)
   Fixes (`#60085 `_)
 
+- Fixed a bug where variables referenced by requires-clauses inside
+  nested generic lambdas were not properly injected into the constraint scope.
+  (`#73418 `_)
+
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index acfc00f412540..88fc846c89e42 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -612,8 +612,12 @@ bool Sema::SetupConstraintScope(
 
 // If this is a member function, make sure we get the parameters that
 // reference the original primary template.
-if (const auto *FromMemTempl =
-PrimaryTemplate->getInstantiatedFromMemberTemplate()) {
+// We walk up the instantiated template chain so that nested lambdas get
+// handled properly.
+for (FunctionTemplateDecl *FromMemTempl =
+ PrimaryTemplate->getInstantiatedFromMemberTemplate();
+ FromMemTempl;
+ FromMemTempl = FromMemTempl->getInstantiatedFromMemberTemplate()) {
   if (addInstantiatedParametersToScope(FD, 
FromMemTempl->getTemplatedDecl(),
Scope, MLTAL))
 return true;
diff --git a/clang/test/SemaTemplate/concepts-lambda.cpp 
b/clang/test/SemaTemplate/concepts-lambda.cpp
index 7e431529427df..0b7580f91043c 100644
--- a/clang/test/SemaTemplate/concepts-lambda.cpp
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -149,3 +149,21 @@ void foo() {
   auto caller = make_caller.operator()<&S1::f1>();
 }
 } // namespace ReturnTypeRequirementInLambda
+
+namespace GH73418 {
+void foo() {
+  int x;
+  [&x](auto) {
+return [](auto y) {
+  return [](auto obj, auto... params)
+requires requires {
+  sizeof...(params);
+  [](auto... pack) {
+return sizeof...(pack);
+  }(params...);
+}
+  { return false; }(y);
+}(x);
+  }(x);
+}
+} // namespace GH73418

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#79568 (PR #80120)

2024-01-31 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

I think this is a regression from clang 16. https://cpp1.godbolt.org/z/1PnWbvY1r

https://github.com/llvm/llvm-project/pull/80120
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang][Concepts] Fix the constraint equivalence checking involving parameter packs (#102131) (PR #106043)

2024-08-26 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

> Is this a major fix or regression fix?

It is a follow-up fix for the previous bug fix incorporated in 19. 
https://github.com/llvm/llvm-project/commit/04d20b17050203e07394b4f9ee61b5affe2d5347

But this isn't a regression since clang wasn't working properly in such cases, 
nor a major fix as I don't think it would affect much but rather ensure more 
correctness.

We have a report from @yuxuanchen1997 that some production codes rely on this 
to compile, so I think it merits a backport.


https://github.com/llvm/llvm-project/pull/106043
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (#89934) (PR #106166)

2024-08-26 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

This is a short-term regression fix that was unfortunately not merged in time.
It is anticipated that @mizvekov will put up an ultimate fix of lambda context 
declaration in Clang 20, so this will be superseded eventually. However, given 
that it still takes time for Matheus to complete his patch, we backport this 
one to avoid regressing some cases reported in 19.

https://github.com/llvm/llvm-project/pull/106166
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Clang] Fix handling of placeholder variables name in init captures (#107055) (PR #107214)

2024-09-04 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.


https://github.com/llvm/llvm-project/pull/107214
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang] Consider outer instantiation scopes for constraint normalization (PR #114951)

2024-11-05 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/114951
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang] Consider outer instantiation scopes for constraint normalization (PR #114951)

2024-11-05 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 milestoned 
https://github.com/llvm/llvm-project/pull/114951
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [Clang] Consider outer instantiation scopes for constraint normalization (PR #114951)

2024-11-05 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/114951

Backport 227afac3

>From ee31957b09ee5cb03d36b15fcc59cff5754aa553 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 5 Nov 2024 16:25:35 +0800
Subject: [PATCH] release/19.x: [Clang] Consider outer instantiation scopes for
 constraint normalization

Backport 227afac3
---
 clang/lib/Sema/SemaConcept.cpp   |  2 +-
 .../SemaTemplate/concepts-out-of-line-def.cpp| 16 
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 244f6ef2f53faa..c45443d76e6bad 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -967,7 +967,7 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // parameters that the surrounding function hasn't been instantiated yet. 
Note
   // this may happen while we're comparing two templates' constraint
   // equivalence.
-  LocalInstantiationScope ScopeForParameters(S);
+  LocalInstantiationScope ScopeForParameters(S, 
/*CombineWithOuterScope=*/true);
   if (auto *FD = DeclInfo.getDecl()->getAsFunction())
 for (auto *PVD : FD->parameters()) {
   if (!PVD->isParameterPack()) {
diff --git a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp 
b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
index 333187b0d74ad6..c5dd855f0c000b 100644
--- a/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+++ b/clang/test/SemaTemplate/concepts-out-of-line-def.cpp
@@ -622,3 +622,19 @@ void A::method(Ts&... ts)
   } {}
 
 }
+
+namespace GH114685 {
+
+template  struct ptr {
+  template 
+  friend ptr make_item(auto &&args)
+requires(sizeof(args) > 1);
+};
+
+template 
+ptr make_item(auto &&args)
+  requires(sizeof(args) > 1) {}
+
+ptr p;
+
+} // namespace GH114685

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] Implement evaluation context for checking template parameters (PR #126088)

2025-02-06 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

(Did you mean `Implement *instantiation* context for checking template 
parameters`?)

https://github.com/llvm/llvm-project/pull/126088
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Clang][CWG2369] Implement GCC's heuristic for DR 2369 (PR #124231)

2025-01-23 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/124231

>From c36dd4fcac367b206072b36ccc9be4106a22ec3b Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 24 Jan 2025 13:52:37 +0800
Subject: [PATCH 1/2] Implement GCC's CWG 2369 heuristic

---
 clang/include/clang/Sema/Sema.h   |   7 +-
 clang/lib/Sema/SemaOverload.cpp   |  70 +++-
 clang/lib/Sema/SemaTemplateDeduction.cpp  |  13 +-
 .../SemaTemplate/concepts-recursive-inst.cpp  | 169 ++
 4 files changed, 246 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 87d9a335763e31..fd4d1f7e0d8f9c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10236,7 +10236,8 @@ class Sema final : public SemaBase {
   FunctionTemplateDecl *FunctionTemplate, ArrayRef ParamTypes,
   ArrayRef Args, OverloadCandidateSet &CandidateSet,
   ConversionSequenceList &Conversions, bool SuppressUserConversions,
-  CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
+  bool NonInstOnly, CXXRecordDecl *ActingContext = nullptr,
+  QualType ObjectType = QualType(),
   Expr::Classification ObjectClassification = {},
   OverloadCandidateParamOrder PO = {});
 
@@ -12272,7 +12273,7 @@ class Sema final : public SemaBase {
   sema::TemplateDeductionInfo &Info,
   SmallVectorImpl const *OriginalCallArgs = nullptr,
   bool PartialOverloading = false,
-  llvm::function_ref CheckNonDependent = [] { return false; });
+  llvm::function_ref CheckNonDependent = [](bool) { return 
false; });
 
   /// Perform template argument deduction from a function call
   /// (C++ [temp.deduct.call]).
@@ -12306,7 +12307,7 @@ class Sema final : public SemaBase {
   FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
   bool PartialOverloading, bool AggregateDeductionCandidate,
   QualType ObjectType, Expr::Classification ObjectClassification,
-  llvm::function_ref)> CheckNonDependent);
+  llvm::function_ref, bool)> CheckNonDependent);
 
   /// Deduce template arguments when taking the address of a function
   /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 3be9ade80f1d94..aded8abe5b4f7b 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7733,10 +7733,10 @@ void Sema::AddMethodTemplateCandidate(
   MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
   PartialOverloading, /*AggregateDeductionCandidate=*/false, 
ObjectType,
   ObjectClassification,
-  [&](ArrayRef ParamTypes) {
+  [&](ArrayRef ParamTypes, bool NonInstOnly) {
 return CheckNonDependentConversions(
 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
-SuppressUserConversions, ActingContext, ObjectType,
+SuppressUserConversions, NonInstOnly, ActingContext, 
ObjectType,
 ObjectClassification, PO);
   });
   Result != TemplateDeductionResult::Success) {
@@ -7818,10 +7818,11 @@ void Sema::AddTemplateOverloadCandidate(
   PartialOverloading, AggregateCandidateDeduction,
   /*ObjectType=*/QualType(),
   /*ObjectClassification=*/Expr::Classification(),
-  [&](ArrayRef ParamTypes) {
+  [&](ArrayRef ParamTypes, bool NonInstOnly) {
 return CheckNonDependentConversions(
 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
-SuppressUserConversions, nullptr, QualType(), {}, PO);
+SuppressUserConversions, NonInstOnly, nullptr, QualType(), {},
+PO);
   });
   Result != TemplateDeductionResult::Success) {
 OverloadCandidate &Candidate =
@@ -7863,7 +7864,7 @@ bool Sema::CheckNonDependentConversions(
 FunctionTemplateDecl *FunctionTemplate, ArrayRef ParamTypes,
 ArrayRef Args, OverloadCandidateSet &CandidateSet,
 ConversionSequenceList &Conversions, bool SuppressUserConversions,
-CXXRecordDecl *ActingContext, QualType ObjectType,
+bool NonInstOnly, CXXRecordDecl *ActingContext, QualType ObjectType,
 Expr::Classification ObjectClassification, OverloadCandidateParamOrder PO) 
{
   // FIXME: The cases in which we allow explicit conversions for constructor
   // arguments never consider calling a constructor template. It's not clear
@@ -7900,6 +7901,63 @@ bool Sema::CheckNonDependentConversions(
 }
   }
 
+  // 
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=2154bcd6d43cfd821ca70e1583880c4ed955355d
+  auto ConversionMightInduceInstantiation = [&](QualType ParmType,
+QualType ArgType) {
+ParmType = ParmType.getNonReferenceType();
+ArgType = ArgType.getNonReferenceType();
+bool Pointe

[llvm-branch-commits] [clang] [clang] fix template argument conversion (PR #124386)

2025-01-24 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/124386
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] fix template argument conversion (PR #124386)

2025-01-24 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

Generally looks good, but please give others a chance to take a look.

https://github.com/llvm/llvm-project/pull/124386
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] fix template argument conversion (PR #124386)

2025-01-24 Thread Younan Zhang via llvm-branch-commits


@@ -5252,63 +5253,89 @@ bool Sema::CheckTemplateArgument(
 return true;
 }
 
-switch (Arg.getArgument().getKind()) {
-case TemplateArgument::Null:
-  llvm_unreachable("Should never see a NULL template argument here");
-
-case TemplateArgument::Expression: {
-  Expr *E = Arg.getArgument().getAsExpr();
+auto checkExpr = [&](Expr *E) -> Expr * {
   TemplateArgument SugaredResult, CanonicalResult;
   unsigned CurSFINAEErrors = NumSFINAEErrors;
   ExprResult Res =
   CheckTemplateArgument(NTTP, NTTPType, E, SugaredResult,
 CanonicalResult, PartialOrderingTTP, CTAK);
-  if (Res.isInvalid())
-return true;
   // If the current template argument causes an error, give up now.
-  if (CurSFINAEErrors < NumSFINAEErrors)
-return true;
+  if (Res.isInvalid() || CurSFINAEErrors < NumSFINAEErrors)
+return nullptr;
+  SugaredConverted.push_back(SugaredResult);
+  CanonicalConverted.push_back(CanonicalResult);
+  return Res.get();
+};
+
+switch (Arg.getKind()) {
+case TemplateArgument::Null:
+  llvm_unreachable("Should never see a NULL template argument here");
 
+case TemplateArgument::Expression: {
+  Expr *E = Arg.getAsExpr();
+  Expr *R = checkExpr(E);
+  if (!R)
+return true;
   // If the resulting expression is new, then use it in place of the
   // old expression in the template argument.
-  if (Res.get() != E) {
-TemplateArgument TA(Res.get());
-Arg = TemplateArgumentLoc(TA, Res.get());
+  if (R != E) {
+TemplateArgument TA(R);
+ArgLoc = TemplateArgumentLoc(TA, R);
   }
-
-  SugaredConverted.push_back(SugaredResult);
-  CanonicalConverted.push_back(CanonicalResult);
   break;
 }
 
-case TemplateArgument::Declaration:
-case TemplateArgument::Integral:
+// As for the converted NTTP kinds, they still might need another
+// conversion, as the new corresponding parameter might be different.
+// Ideally, we would always perform substitution starting with sugared 
types
+// and never need these, as we would still have expressions. Since these 
are
+// needed so rarely, it's probably a better tradeoff to just convert them
+// back to expressions.
+case TemplateArgument::Integral: {
+  IntegerLiteral ILE(Context, Arg.getAsIntegral(), Arg.getIntegralType(),
+ SourceLocation());
+  if (!checkExpr(&ILE))

zyn0217 wrote:

So this makes `CheckTemplateArgument` take an Expr pointer to a temporary 
rather than anything persisted by ASTContext. Shall we document this behavior 
somewhere to avoid accidentally storing it longer in `CheckTemplateArgument`?

https://github.com/llvm/llvm-project/pull/124386
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [Clang][CWG2369] Implement GCC's heuristic for DR 2369 (PR #124231)

2025-01-23 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/124231

None

>From c36dd4fcac367b206072b36ccc9be4106a22ec3b Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 24 Jan 2025 13:52:37 +0800
Subject: [PATCH] Implement GCC's CWG 2369 heuristic

---
 clang/include/clang/Sema/Sema.h   |   7 +-
 clang/lib/Sema/SemaOverload.cpp   |  70 +++-
 clang/lib/Sema/SemaTemplateDeduction.cpp  |  13 +-
 .../SemaTemplate/concepts-recursive-inst.cpp  | 169 ++
 4 files changed, 246 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 87d9a335763e31..fd4d1f7e0d8f9c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10236,7 +10236,8 @@ class Sema final : public SemaBase {
   FunctionTemplateDecl *FunctionTemplate, ArrayRef ParamTypes,
   ArrayRef Args, OverloadCandidateSet &CandidateSet,
   ConversionSequenceList &Conversions, bool SuppressUserConversions,
-  CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
+  bool NonInstOnly, CXXRecordDecl *ActingContext = nullptr,
+  QualType ObjectType = QualType(),
   Expr::Classification ObjectClassification = {},
   OverloadCandidateParamOrder PO = {});
 
@@ -12272,7 +12273,7 @@ class Sema final : public SemaBase {
   sema::TemplateDeductionInfo &Info,
   SmallVectorImpl const *OriginalCallArgs = nullptr,
   bool PartialOverloading = false,
-  llvm::function_ref CheckNonDependent = [] { return false; });
+  llvm::function_ref CheckNonDependent = [](bool) { return 
false; });
 
   /// Perform template argument deduction from a function call
   /// (C++ [temp.deduct.call]).
@@ -12306,7 +12307,7 @@ class Sema final : public SemaBase {
   FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
   bool PartialOverloading, bool AggregateDeductionCandidate,
   QualType ObjectType, Expr::Classification ObjectClassification,
-  llvm::function_ref)> CheckNonDependent);
+  llvm::function_ref, bool)> CheckNonDependent);
 
   /// Deduce template arguments when taking the address of a function
   /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 3be9ade80f1d94..aded8abe5b4f7b 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7733,10 +7733,10 @@ void Sema::AddMethodTemplateCandidate(
   MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
   PartialOverloading, /*AggregateDeductionCandidate=*/false, 
ObjectType,
   ObjectClassification,
-  [&](ArrayRef ParamTypes) {
+  [&](ArrayRef ParamTypes, bool NonInstOnly) {
 return CheckNonDependentConversions(
 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
-SuppressUserConversions, ActingContext, ObjectType,
+SuppressUserConversions, NonInstOnly, ActingContext, 
ObjectType,
 ObjectClassification, PO);
   });
   Result != TemplateDeductionResult::Success) {
@@ -7818,10 +7818,11 @@ void Sema::AddTemplateOverloadCandidate(
   PartialOverloading, AggregateCandidateDeduction,
   /*ObjectType=*/QualType(),
   /*ObjectClassification=*/Expr::Classification(),
-  [&](ArrayRef ParamTypes) {
+  [&](ArrayRef ParamTypes, bool NonInstOnly) {
 return CheckNonDependentConversions(
 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
-SuppressUserConversions, nullptr, QualType(), {}, PO);
+SuppressUserConversions, NonInstOnly, nullptr, QualType(), {},
+PO);
   });
   Result != TemplateDeductionResult::Success) {
 OverloadCandidate &Candidate =
@@ -7863,7 +7864,7 @@ bool Sema::CheckNonDependentConversions(
 FunctionTemplateDecl *FunctionTemplate, ArrayRef ParamTypes,
 ArrayRef Args, OverloadCandidateSet &CandidateSet,
 ConversionSequenceList &Conversions, bool SuppressUserConversions,
-CXXRecordDecl *ActingContext, QualType ObjectType,
+bool NonInstOnly, CXXRecordDecl *ActingContext, QualType ObjectType,
 Expr::Classification ObjectClassification, OverloadCandidateParamOrder PO) 
{
   // FIXME: The cases in which we allow explicit conversions for constructor
   // arguments never consider calling a constructor template. It's not clear
@@ -7900,6 +7901,63 @@ bool Sema::CheckNonDependentConversions(
 }
   }
 
+  // 
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=2154bcd6d43cfd821ca70e1583880c4ed955355d
+  auto ConversionMightInduceInstantiation = [&](QualType ParmType,
+QualType ArgType) {
+ParmType = ParmType.getNonReferenceType();
+ArgType = ArgType.getNonReferenceType();
+bool Poin

[llvm-branch-commits] [clang] [Clang][CWG2369] Implement GCC's heuristic for DR 2369 (PR #124231)

2025-01-24 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/124231

>From f766c8c099cf8f1bc076c0308afc3a2832a5b495 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 24 Jan 2025 13:52:37 +0800
Subject: [PATCH] Implement GCC's CWG 2369 heuristic

---
 clang/include/clang/Sema/Sema.h   |   9 +-
 clang/lib/Sema/SemaOverload.cpp   |  62 ++-
 clang/lib/Sema/SemaTemplateDeduction.cpp  |  14 +-
 .../SemaTemplate/concepts-recursive-inst.cpp  | 169 ++
 4 files changed, 241 insertions(+), 13 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 87d9a335763e31..99ca65159106b5 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10236,7 +10236,8 @@ class Sema final : public SemaBase {
   FunctionTemplateDecl *FunctionTemplate, ArrayRef ParamTypes,
   ArrayRef Args, OverloadCandidateSet &CandidateSet,
   ConversionSequenceList &Conversions, bool SuppressUserConversions,
-  CXXRecordDecl *ActingContext = nullptr, QualType ObjectType = QualType(),
+  bool NonInstOnly, CXXRecordDecl *ActingContext = nullptr,
+  QualType ObjectType = QualType(),
   Expr::Classification ObjectClassification = {},
   OverloadCandidateParamOrder PO = {});
 
@@ -12272,7 +12273,9 @@ class Sema final : public SemaBase {
   sema::TemplateDeductionInfo &Info,
   SmallVectorImpl const *OriginalCallArgs = nullptr,
   bool PartialOverloading = false,
-  llvm::function_ref CheckNonDependent = [] { return false; });
+  llvm::function_ref CheckNonDependent = [](bool) {
+return false;
+  });
 
   /// Perform template argument deduction from a function call
   /// (C++ [temp.deduct.call]).
@@ -12306,7 +12309,7 @@ class Sema final : public SemaBase {
   FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info,
   bool PartialOverloading, bool AggregateDeductionCandidate,
   QualType ObjectType, Expr::Classification ObjectClassification,
-  llvm::function_ref)> CheckNonDependent);
+  llvm::function_ref, bool)> CheckNonDependent);
 
   /// Deduce template arguments when taking the address of a function
   /// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 3be9ade80f1d94..c2baa75c09bce9 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -7733,10 +7733,10 @@ void Sema::AddMethodTemplateCandidate(
   MethodTmpl, ExplicitTemplateArgs, Args, Specialization, Info,
   PartialOverloading, /*AggregateDeductionCandidate=*/false, 
ObjectType,
   ObjectClassification,
-  [&](ArrayRef ParamTypes) {
+  [&](ArrayRef ParamTypes, bool NonInstOnly) {
 return CheckNonDependentConversions(
 MethodTmpl, ParamTypes, Args, CandidateSet, Conversions,
-SuppressUserConversions, ActingContext, ObjectType,
+SuppressUserConversions, NonInstOnly, ActingContext, 
ObjectType,
 ObjectClassification, PO);
   });
   Result != TemplateDeductionResult::Success) {
@@ -7818,10 +7818,11 @@ void Sema::AddTemplateOverloadCandidate(
   PartialOverloading, AggregateCandidateDeduction,
   /*ObjectType=*/QualType(),
   /*ObjectClassification=*/Expr::Classification(),
-  [&](ArrayRef ParamTypes) {
+  [&](ArrayRef ParamTypes, bool NonInstOnly) {
 return CheckNonDependentConversions(
 FunctionTemplate, ParamTypes, Args, CandidateSet, Conversions,
-SuppressUserConversions, nullptr, QualType(), {}, PO);
+SuppressUserConversions, NonInstOnly, nullptr, QualType(), {},
+PO);
   });
   Result != TemplateDeductionResult::Success) {
 OverloadCandidate &Candidate =
@@ -7863,7 +7864,7 @@ bool Sema::CheckNonDependentConversions(
 FunctionTemplateDecl *FunctionTemplate, ArrayRef ParamTypes,
 ArrayRef Args, OverloadCandidateSet &CandidateSet,
 ConversionSequenceList &Conversions, bool SuppressUserConversions,
-CXXRecordDecl *ActingContext, QualType ObjectType,
+bool NonInstOnly, CXXRecordDecl *ActingContext, QualType ObjectType,
 Expr::Classification ObjectClassification, OverloadCandidateParamOrder PO) 
{
   // FIXME: The cases in which we allow explicit conversions for constructor
   // arguments never consider calling a constructor template. It's not clear
@@ -7900,6 +7901,54 @@ bool Sema::CheckNonDependentConversions(
 }
   }
 
+  // A heuristic & speculative workaround for bug
+  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99599 that manifests after
+  // CWG2369.
+  auto ConversionMightInduceInstantiation = [&](QualType ParmType,
+QualType ArgType) {
+ParmType = ParmType.getNonReferenceType();
+  

[llvm-branch-commits] [clang] [clang] fix nondeduced mismatch with nullptr template arguments (PR #124498)

2025-01-26 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

Thanks

https://github.com/llvm/llvm-project/pull/124498
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [clang][HeuristicResolver] Default argument heuristic for template parameters (PR #131074)

2025-03-19 Thread Younan Zhang via llvm-branch-commits


@@ -125,6 +126,20 @@ TagDecl 
*HeuristicResolverImpl::resolveTypeToTagDecl(QualType QT) {
   if (!T)
 return nullptr;
 
+  // If T is the type of a template parameter, we can't get a useful TagDecl
+  // out of it. However, if the template parameter has a default argument,
+  // as a heuristic we can replace T with the default argument type.
+  if (const auto *TTPT = dyn_cast(T)) {
+if (const auto *TTPD = TTPT->getDecl()) {
+  if (TTPD->hasDefaultArgument()) {
+const auto &DefaultArg = TTPD->getDefaultArgument().getArgument();
+if (DefaultArg.getKind() == TemplateArgument::Type) {
+  T = DefaultArg.getAsType().getTypePtrOrNull();

zyn0217 wrote:

Do we traverse the default arguments recursively? I'm thinking a case like
```cpp
template 
void bar(T t) {
  t.foo(); // Can we resolve it to Waldo::foo()?
}
```

Also there are some usages for template template parameters, e.g.
```cpp
template  class V = std::vector>
void foo(V) {
  V.push_back(42); // Would be great to resolve it to std::vector<>::push_back()
}
```

However it depends on the implementation complexity - there's no necessity to 
handle these in this patch

https://github.com/llvm/llvm-project/pull/131074
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [clang][HeuristicResolver] Default argument heuristic for template parameters (PR #131074)

2025-03-19 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/131074
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][HeuristicResolver] Default argument heuristic for template parameters (PR #131074)

2025-03-21 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

thanks

https://github.com/llvm/llvm-project/pull/131074
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][HeuristicResolver] Default argument heuristic for template parameters (PR #131074)

2025-03-21 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

@HighCommander4 did you merge it into a wrong branch?

https://github.com/llvm/llvm-project/pull/131074
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Do not emit nodiscard warnings for the base expr of static member access (#131450) (PR #131474)

2025-03-18 Thread Younan Zhang via llvm-branch-commits


@@ -10671,10 +10671,9 @@ class Sema final : public SemaBase {
SourceLocation EndLoc);
   void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
 
-  /// DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is
-  /// semantically a discarded-value expression, diagnose if any [[nodiscard]]
-  /// value has been discarded.
-  void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E);
+
+  // Unused, kept in Clang 20 for ABI stability.
+  void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E) {};

zyn0217 wrote:

trailing semicolon 

https://github.com/llvm/llvm-project/pull/131474
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] Backport/20.x: [Clang] Fix an incorrect assumption on getTemplatedDecl() (PR #131729)

2025-03-18 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/131729

This backports d9110858ee because it fixes a regression introduced in 19 and we 
don't want it to persist in 20

>From 1cfbb9f334360fc836966a79eba6d00c8d3d22c7 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Mon, 17 Mar 2025 16:53:57 +0800
Subject: [PATCH] Backport/20.x: [Clang] Fix an incorrect assumption on
 getTemplatedDecl()

This backports d9110858ee because it fixes a regression introduced in 19
and we don't want it to persist in 20
---
 clang/docs/ReleaseNotes.rst|  1 +
 clang/lib/Sema/SemaAccess.cpp  |  4 ++--
 clang/test/SemaCXX/concept-crash-on-diagnostic.cpp | 12 
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 02292c10e6964..dc63b5213c546 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1059,6 +1059,7 @@ Bug Fixes to C++ Support
   corresponding to a pack parameter (#GH124715)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Fixed an integer overflow bug in computing template parameter depths when 
synthesizing CTAD guides. (#GH128691)
+- Fixed an incorrect pointer access when checking access-control on concepts. 
(#GH131530)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index f79d9a758e7af..6813786df3fc4 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/lib/Sema/SemaAccess.cpp
@@ -1518,8 +1518,8 @@ void Sema::HandleDelayedAccessCheck(DelayedDiagnostic 
&DD, Decl *D) {
   } else if (FunctionDecl *FN = dyn_cast(D)) {
 DC = FN;
   } else if (TemplateDecl *TD = dyn_cast(D)) {
-if (isa(TD->getTemplatedDecl()))
-  DC = cast(TD->getTemplatedDecl());
+if (auto *D = dyn_cast_if_present(TD->getTemplatedDecl()))
+  DC = D;
   } else if (auto *RD = dyn_cast(D)) {
 DC = RD;
   }
diff --git a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp 
b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
index 71e55c8290ee4..c38f075de 100644
--- a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
+++ b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
@@ -36,3 +36,15 @@ void function() {
 // expected-note@#4 {{candidate template ignored: constraints not satisfied 
[with IteratorL = Object *, IteratorR = Object *]}}
 // We don't know exactly the substituted type for `lhs == rhs`, thus a 
placeholder 'expr-type' is emitted.
 // expected-note@#3 {{because 'convertible_to' would be 
invalid}}
+
+namespace GH131530 {
+
+class foo {
+  struct bar {}; // expected-note {{implicitly declared private}}
+};
+
+template 
+concept is_foo_concept = __is_same(foo::bar, T);
+// expected-error@-1 {{'bar' is a private member of 'GH131530::foo'}}
+
+}

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] Backport/20.x: [Clang] Fix an incorrect assumption on getTemplatedDecl() (PR #131729)

2025-03-17 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 milestoned 
https://github.com/llvm/llvm-project/pull/131729
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 1cfbb9f - Backport/20.x: [Clang] Fix an incorrect assumption on getTemplatedDecl()

2025-03-18 Thread Younan Zhang via llvm-branch-commits

Author: Younan Zhang
Date: 2025-03-18T12:54:25+08:00
New Revision: 1cfbb9f334360fc836966a79eba6d00c8d3d22c7

URL: 
https://github.com/llvm/llvm-project/commit/1cfbb9f334360fc836966a79eba6d00c8d3d22c7
DIFF: 
https://github.com/llvm/llvm-project/commit/1cfbb9f334360fc836966a79eba6d00c8d3d22c7.diff

LOG: Backport/20.x: [Clang] Fix an incorrect assumption on getTemplatedDecl()

This backports d9110858ee because it fixes a regression introduced in 19
and we don't want it to persist in 20

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaAccess.cpp
clang/test/SemaCXX/concept-crash-on-diagnostic.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 02292c10e6964..dc63b5213c546 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1059,6 +1059,7 @@ Bug Fixes to C++ Support
   corresponding to a pack parameter (#GH124715)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Fixed an integer overflow bug in computing template parameter depths when 
synthesizing CTAD guides. (#GH128691)
+- Fixed an incorrect pointer access when checking access-control on concepts. 
(#GH131530)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp
index f79d9a758e7af..6813786df3fc4 100644
--- a/clang/lib/Sema/SemaAccess.cpp
+++ b/clang/lib/Sema/SemaAccess.cpp
@@ -1518,8 +1518,8 @@ void Sema::HandleDelayedAccessCheck(DelayedDiagnostic 
&DD, Decl *D) {
   } else if (FunctionDecl *FN = dyn_cast(D)) {
 DC = FN;
   } else if (TemplateDecl *TD = dyn_cast(D)) {
-if (isa(TD->getTemplatedDecl()))
-  DC = cast(TD->getTemplatedDecl());
+if (auto *D = dyn_cast_if_present(TD->getTemplatedDecl()))
+  DC = D;
   } else if (auto *RD = dyn_cast(D)) {
 DC = RD;
   }

diff  --git a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp 
b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
index 71e55c8290ee4..c38f075de 100644
--- a/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
+++ b/clang/test/SemaCXX/concept-crash-on-diagnostic.cpp
@@ -36,3 +36,15 @@ void function() {
 // expected-note@#4 {{candidate template ignored: constraints not satisfied 
[with IteratorL = Object *, IteratorR = Object *]}}
 // We don't know exactly the substituted type for `lhs == rhs`, thus a 
placeholder 'expr-type' is emitted.
 // expected-note@#3 {{because 'convertible_to' would be 
invalid}}
+
+namespace GH131530 {
+
+class foo {
+  struct bar {}; // expected-note {{implicitly declared private}}
+};
+
+template 
+concept is_foo_concept = __is_same(foo::bar, T);
+// expected-error@-1 {{'bar' is a private member of 'GH131530::foo'}}
+
+}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-04-04 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/133610
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [clang] support pack expansions for trailing requires clauses (PR #133190)

2025-03-26 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

Looks like there are some dependencies on the implicit bool conversion. So feel 
free to drop the explicit specifier ;)

https://github.com/llvm/llvm-project/pull/133190
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [clang][HeuristicResolver] Default argument heuristic for template parameters (PR #131074)

2025-03-25 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

Sorry for missing this. LGTM assuming @hokein is happy too.

https://github.com/llvm/llvm-project/pull/131074
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-03-31 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

Thanks for the improvement.

https://github.com/llvm/llvm-project/pull/133610
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-03-31 Thread Younan Zhang via llvm-branch-commits


@@ -544,6 +545,35 @@ class QualifiedTemplateName : public llvm::FoldingSetNode {
   }
 };
 
+struct IdentifierOrOverloadedOperator {
+  IdentifierOrOverloadedOperator() = default;
+  IdentifierOrOverloadedOperator(const IdentifierInfo *II);
+  IdentifierOrOverloadedOperator(OverloadedOperatorKind OOK);
+
+  /// Returns the identifier to which this template name refers.
+  const IdentifierInfo *getIdentifier() const {
+if (getOperator() != OO_None)
+  return nullptr;
+return reinterpret_cast(PtrOrOp);
+  }
+
+  /// Return the overloaded operator to which this template name refers.
+  OverloadedOperatorKind getOperator() const {
+uintptr_t OOK = -PtrOrOp;
+return OOK < NUM_OVERLOADED_OPERATORS ? OverloadedOperatorKind(OOK)
+  : OO_None;

zyn0217 wrote:

IIRC this pointer/integer mechanism is also used in that lambda patch. We 
probably want to extract a generic implementation of it.

https://github.com/llvm/llvm-project/pull/133610
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-03-31 Thread Younan Zhang via llvm-branch-commits


@@ -587,12 +587,12 @@ bool Parser::ParseOptionalCXXScopeSpecifier(
   << II.getName()
   << FixItHint::CreateInsertion(Tok.getLocation(), "template ");
 }
-
-SourceLocation TemplateNameLoc = ConsumeToken();
+ConsumeToken();
 
 TemplateNameKind TNK = Actions.ActOnTemplateName(
-getCurScope(), SS, TemplateNameLoc, TemplateName, ObjectType,
-EnteringContext, Template, /*AllowInjectedClassName*/ true);
+getCurScope(), SS, /*TemplateKWLoc=*/SourceLocation(), 
TemplateName,

zyn0217 wrote:

We don't want to track the `template` keyword's location following an NNS 
prefix anymore? Even that is never used, I think we need to mention the change 
in the release note.

Or am I missing any code that would track the location instead?

https://github.com/llvm/llvm-project/pull/133610
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [libcxx] [clang] improved preservation of template keyword (PR #133610)

2025-03-31 Thread Younan Zhang via llvm-branch-commits


@@ -124,6 +124,31 @@ void SubstTemplateTemplateParmPackStorage::Profile(
   ID.AddBoolean(Final);
 }
 
+IdentifierOrOverloadedOperator::IdentifierOrOverloadedOperator(
+const IdentifierInfo *II)
+: PtrOrOp(reinterpret_cast(II)) {
+  static_assert(NUM_OVERLOADED_OPERATORS <= 4096,
+"NUM_OVERLOADED_OPERATORS is too large");

zyn0217 wrote:

How did you determine the upper limit?

https://github.com/llvm/llvm-project/pull/133610
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang][AST] Handle implicit first argument in CallExpr::getBeginLoc() (PR #135927)

2025-04-16 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.


https://github.com/llvm/llvm-project/pull/135927
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Fix a lambda pattern comparison mismatch after ecc7e6ce4 (#133863) (PR #134194)

2025-04-15 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

It's been 11 days so I think this is mature enough - @erichkeane WDYT? 

https://github.com/llvm/llvm-project/pull/134194
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Fix the trailing comma regression (#136273) (PR #136283)

2025-05-02 Thread Younan Zhang via llvm-branch-commits

zyn0217 wrote:

@cor3ntin

https://github.com/llvm/llvm-project/pull/136283
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Fix an integer overflow issue in computing CTAD's parameter depth (PR #128845)

2025-03-11 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 milestoned 
https://github.com/llvm/llvm-project/pull/128845
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang][AST] Handle dependent representation of call to function with explicit object parameter in CallExpr::getBeginLoc() (#126868) (PR #127148)

2025-02-13 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.


https://github.com/llvm/llvm-project/pull/127148
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Remove the PackExpansion restrictions for rewrite substitution (PR #127174)

2025-02-13 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 milestoned 
https://github.com/llvm/llvm-project/pull/127174
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Remove the PackExpansion restrictions for rewrite substitution (PR #127174)

2025-02-13 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/127174
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Remove the PackExpansion restrictions for rewrite substitution (PR #127174)

2025-02-13 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/127174

This backports [commit-sha] with a release note towards 20 so that we could 
resolve some pains in CTAD.


>From ec69f0589eb471877ccd488f6d7d4fd43bcf0d02 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 7 Feb 2025 17:15:05 +0800
Subject: [PATCH 1/2] [Clang] Remove the PackExpansion restrictions for rewrite
 substitution

When substituting for rewrite purposes, as in rebuilding constraints for a 
synthesized
deduction guide, it assumed that packs were in PackExpansion* form, such that 
the
instantiator could extract a pattern.

For type aliases CTAD, while rebuilding their associated constraints, this 
might not be
the case because we'll call TransformTemplateArgument() for the alias
template arguments, where there might be e.g. a non-pack expansion type into a 
pack expansion,
so the assumption wouldn't hold.

This patch fixes that by making it treat the non-pack expansions as direct 
patterns when rewriting.
---
 clang/lib/Sema/SemaTemplate.cpp|  2 +-
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 32 +++
 clang/test/AST/ast-dump-ctad-alias.cpp | 46 ++
 3 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 3944c4f67bab9..f4045debf4521 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4905,7 +4905,7 @@ bool Sema::CheckTemplateTypeArgument(
 [[fallthrough]];
   }
   default: {
-// We allow instantiateing a template with template argument packs when
+// We allow instantiating a template with template argument packs when
 // building deduction guides.
 if (Arg.getKind() == TemplateArgument::Pack &&
 CodeSynthesisContexts.back().Kind ==
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index c45d3ffe2508b..eec56b7493bad 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1467,6 +1467,18 @@ namespace {
   }
 }
 
+static TemplateArgument
+getTemplateArgumentPackPatternForRewrite(const TemplateArgument &TA) {
+  if (TA.getKind() != TemplateArgument::Pack)
+return TA;
+  assert(TA.pack_size() == 1 &&
+ "unexpected pack arguments in template rewrite");
+  TemplateArgument Arg = *TA.pack_begin();
+  if (Arg.isPackExpansion())
+Arg = Arg.getPackExpansionPattern();
+  return Arg;
+}
+
 /// Transform the given declaration by instantiating a reference to
 /// this declaration.
 Decl *TransformDecl(SourceLocation Loc, Decl *D);
@@ -1624,7 +1636,7 @@ namespace {
   TemplateArgumentLoc Input = SemaRef.getTrivialTemplateArgumentLoc(
   pack, QualType(), SourceLocation{});
   TemplateArgumentLoc Output;
-  if (SemaRef.SubstTemplateArgument(Input, TemplateArgs, Output))
+  if (TransformTemplateArgument(Input, Output, Uneval))
 return true; // fails
   TArgs.push_back(Output.getArgument());
 }
@@ -2036,11 +2048,7 @@ TemplateName TemplateInstantiator::TransformTemplateName(
   if (TemplateArgs.isRewrite()) {
 // We're rewriting the template parameter as a reference to another
 // template parameter.
-if (Arg.getKind() == TemplateArgument::Pack) {
-  assert(Arg.pack_size() == 1 && Arg.pack_begin()->isPackExpansion() &&
- "unexpected pack arguments in template rewrite");
-  Arg = Arg.pack_begin()->getPackExpansionPattern();
-}
+Arg = getTemplateArgumentPackPatternForRewrite(Arg);
 assert(Arg.getKind() == TemplateArgument::Template &&
"unexpected nontype template argument kind in template 
rewrite");
 return Arg.getAsTemplate();
@@ -2121,11 +2129,7 @@ 
TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
   if (TemplateArgs.isRewrite()) {
 // We're rewriting the template parameter as a reference to another
 // template parameter.
-if (Arg.getKind() == TemplateArgument::Pack) {
-  assert(Arg.pack_size() == 1 && Arg.pack_begin()->isPackExpansion() &&
- "unexpected pack arguments in template rewrite");
-  Arg = Arg.pack_begin()->getPackExpansionPattern();
-}
+Arg = getTemplateArgumentPackPatternForRewrite(Arg);
 assert(Arg.getKind() == TemplateArgument::Expression &&
"unexpected nontype template argument kind in template rewrite");
 // FIXME: This can lead to the same subexpression appearing multiple times
@@ -2578,11 +2582,7 @@ 
TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
 if (TemplateArgs.isRewrite()) {
   // We're rewriting the template parameter as a reference to another
   // template parameter.
-  if (Arg.getKind() == TemplateArgument::Pack) {
-assert(Arg.pac

[llvm-branch-commits] [clang] release/20.x: [Clang] Remove the PackExpansion restrictions for rewrite substitution (PR #127174)

2025-02-13 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/127174
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Remove the PackExpansion restrictions for rewrite substitution (PR #127174)

2025-02-13 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 ready_for_review 
https://github.com/llvm/llvm-project/pull/127174
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][NFC] Remove CXXRecordDecl::lookupDependentName() and its helpers (PR #128392)

2025-02-23 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 commented:

LGTM in general, but my concern would be that we're less clear if there's any 
use of this function out-of-tree, so as an alternative, can we turn the 
implementation to use HeuristicResolver and explicitly deprecate it for a while 
before eventually removing it?

https://github.com/llvm/llvm-project/pull/128392
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][NFC] Remove CXXRecordDecl::lookupDependentName() and its helpers (PR #128392)

2025-02-23 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/128392
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][NFC] Remove CXXRecordDecl::lookupDependentName() and its helpers (PR #128392)

2025-02-23 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.


https://github.com/llvm/llvm-project/pull/128392
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Fix an integer overflow issue in computing CTAD's parameter depth (PR #128845)

2025-02-26 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/128845

This fixes a potential integer overflow bug that has been around for many 
versions and was exposed by my patch recently. So we think it warrants a 
backport.

Backports b8d1f3d62.

>From 4adb975ae689d575dcd329ccd24d2cd0355bb61b Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Wed, 26 Feb 2025 16:54:19 +0800
Subject: [PATCH] [Clang] Fix an integer overflow issue in computing CTAD's
 parameter depth (#128704)

Backports b8d1f3d62.

This fixes a potential integer overflow bug that has been around for
many versions and was exposed by my patch recently. So we think it
warrants a backport
---
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/lib/Sema/SemaTemplateDeductionGuide.cpp |  9 +-
 clang/test/SemaTemplate/deduction-guide.cpp   | 32 +++
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 153afdb3d59e3..7537b2b8d42d8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1058,6 +1058,7 @@ Bug Fixes to C++ Support
 - Fixed a substitution bug in transforming CTAD aliases when the type alias 
contains a non-pack template argument
   corresponding to a pack parameter (#GH124715)
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
+- Fixed an integer overflow bug in computing template parameter depths when 
synthesizing CTAD guides. (#GH128691)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index 00c5dfd3d7a43..b424de9c8a945 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -377,8 +377,15 @@ struct ConvertConstructorToDeductionGuideTransform {
 if (NestedPattern)
   Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
 auto [Depth, Index] = getDepthAndIndex(Param);
+// Depth can still be 0 if FTD belongs to an explicit class template
+// specialization with an empty template parameter list. In that case,
+// we don't want the NewDepth to overflow, and it should remain 0.
+assert(Depth ||
+   cast(FTD->getDeclContext())
+   ->isExplicitSpecialization());
 NamedDecl *NewParam = transformTemplateParameter(
-SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment, Depth - 
1);
+SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment,
+Depth ? Depth - 1 : 0);
 if (!NewParam)
   return nullptr;
 // Constraints require that we substitute depth-1 arguments
diff --git a/clang/test/SemaTemplate/deduction-guide.cpp 
b/clang/test/SemaTemplate/deduction-guide.cpp
index a4c523595fca2..ecd152abebd74 100644
--- a/clang/test/SemaTemplate/deduction-guide.cpp
+++ b/clang/test/SemaTemplate/deduction-guide.cpp
@@ -691,3 +691,35 @@ Test test(42);
 // CHECK-NEXT: | `-ParmVarDecl {{.*}} 'auto:1'
 
 } // namespace GH122134
+
+namespace GH128691 {
+
+template 
+class NewDeleteAllocator;
+
+template <>
+struct NewDeleteAllocator<> {
+  template 
+  NewDeleteAllocator(T); // expected-note {{candidate template ignored}} \
+ // expected-note {{implicit deduction guide declared 
as}}
+};
+
+template 
+struct NewDeleteAllocator : NewDeleteAllocator<> { // expected-note 
{{candidate template ignored}} \
+   // expected-note {{implicit 
deduction guide declared as}}
+  using NewDeleteAllocator<>::NewDeleteAllocator;
+};
+
+void test() { NewDeleteAllocator abc(42); } // expected-error {{no viable 
constructor or deduction guide}}
+
+// CHECK-LABEL: Dumping GH128691:::
+// CHECK-NEXT: FunctionTemplateDecl {{.+}} 
+// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 0
+// CHECK-NEXT: | `-TemplateArgument type 'void'
+// CHECK-NEXT: |   |-inherited from TemplateTypeParm {{.+}} depth 0 index 0
+// CHECK-NEXT: |   `-BuiltinType {{.+}} 'void'
+// CHECK-NEXT: |-TemplateTypeParmDecl {{.+}} typename depth 0 index 1 T
+// CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}}  'auto (T) -> NewDeleteAllocator'
+// CHECK-NEXT:  `-ParmVarDecl {{.+}} 'T'
+
+} // namespace GH128691

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] NFC: introduce UnsignedOrNone as a replacement for std::optional (PR #134142)

2025-04-02 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 edited 
https://github.com/llvm/llvm-project/pull/134142
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang] NFC: introduce UnsignedOrNone as a replacement for std::optional (PR #134142)

2025-04-02 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

One question otherwise LGTM!

https://github.com/llvm/llvm-project/pull/134142
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang-tools-extra] [clang][HeuristicResolver] Apply default argument heuristic in resolveDeclRefExpr as well (PR #132576)

2025-03-22 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.

Thanks for following up on it, this looks great.

Please flesh out the PR body before you commit, with the reason you said in 
https://github.com/llvm/llvm-project/pull/132576#issuecomment-2745944724.
(Just a copy-paste is good enough)

https://github.com/llvm/llvm-project/pull/132576
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Fix various bugs in alias CTAD transform (PR #132697)

2025-03-24 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 milestoned 
https://github.com/llvm/llvm-project/pull/132697
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [Clang] Fix various bugs in alias CTAD transform (PR #132697)

2025-03-24 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/132697

This patch cherry-picks 032ad590d6, 868c89ff0 and 38d71c9bd onto the 20 release 
branch.

The first patch addresses recently surfaced CTAD problems, which we believe it 
would be nice to roll out the fix quickly, given the release window is not 
closed yet.

The second patch is a follow-up to the first and fixed a test failure on the 
arm32 platform.

The third patch follows-up on the previous patch that I cherry-picked to the 20 
release branch, which removes a unnecessary assertion.

>From 9dedad6dc2cd447f4f919b7c6dc25e1b392a5316 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 22 Mar 2025 22:55:58 +0800
Subject: [PATCH] release/20.x: [Clang] Fix various bugs in alias CTAD
 transform

This patch cherry-picks 032ad590d6, 868c89ff0 and 38d71c9bd onto the 20
release branch.

The first patch addresses recently surfaced CTAD problems, which we
believe it would be nice to roll out the fix quickly, given the release
window is not closed yet.

The second patch is a follow-up to the first and fixed a test failure
on the arm32 platform.

The third patch follows-up on the previous patch that I cherry-picked to
the 20 release branch, which removes a unnecessary assertion.
---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/lib/Sema/SemaTemplateDeductionGuide.cpp |  28 ++--
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  46 --
 clang/lib/Sema/TreeTransform.h|  84 ++-
 clang/test/SemaCXX/ctad.cpp   | 132 +-
 clang/test/SemaTemplate/deduction-guide.cpp   |  48 +++
 6 files changed, 283 insertions(+), 57 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 03b68271b7864..955325026f369 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1060,6 +1060,8 @@ Bug Fixes to C++ Support
 - Clang is now better at keeping track of friend function template instance 
contexts. (#GH55509)
 - Fixed an integer overflow bug in computing template parameter depths when 
synthesizing CTAD guides. (#GH128691)
 - Fixed an incorrect pointer access when checking access-control on concepts. 
(#GH131530)
+- Fixed various alias CTAD bugs involving variadic template arguments. 
(#GH123591), (#GH127539), (#GH129077),
+  (#GH129620), and (#GH129998).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index b424de9c8a945..6728857edc6d8 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -377,12 +377,10 @@ struct ConvertConstructorToDeductionGuideTransform {
 if (NestedPattern)
   Args.addOuterRetainedLevels(NestedPattern->getTemplateDepth());
 auto [Depth, Index] = getDepthAndIndex(Param);
-// Depth can still be 0 if FTD belongs to an explicit class template
-// specialization with an empty template parameter list. In that case,
-// we don't want the NewDepth to overflow, and it should remain 0.
-assert(Depth ||
-   cast(FTD->getDeclContext())
-   ->isExplicitSpecialization());
+// Depth can be 0 if FTD belongs to a non-template class/a class
+// template specialization with an empty template parameter list. In
+// that case, we don't want the NewDepth to overflow, and it should
+// remain 0.
 NamedDecl *NewParam = transformTemplateParameter(
 SemaRef, DC, Param, Args, Index + Depth1IndexAdjustment,
 Depth ? Depth - 1 : 0);
@@ -989,6 +987,19 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, 
TypeAliasTemplateDecl *AliasTemplate) {
   return {Template, AliasRhsTemplateArgs};
 }
 
+bool IsNonDeducedArgument(const TemplateArgument &TA) {
+  // The following cases indicate the template argument is non-deducible:
+  //   1. The result is null. E.g. When it comes from a default template
+  //   argument that doesn't appear in the alias declaration.
+  //   2. The template parameter is a pack and that cannot be deduced from
+  //   the arguments within the alias declaration.
+  // Non-deducible template parameters will persist in the transformed
+  // deduction guide.
+  return TA.isNull() ||
+ (TA.getKind() == TemplateArgument::Pack &&
+  llvm::any_of(TA.pack_elements(), IsNonDeducedArgument));
+}
+
 // Build deduction guides for a type alias template from the given underlying
 // deduction guide F.
 FunctionTemplateDecl *
@@ -1057,7 +1068,8 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   // !!NOTE: DeduceResults respects the sequence of template parameters of
   // the deduction guide f.
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
-if (const auto &D = DeduceResults[Index]; !D.isNull()) // Deduced
+const auto &D = DeduceResults[Index];
+if (!IsNonDeduced

[llvm-branch-commits] [clang] [clang] NFC: introduce UnsignedOrNone as a replacement for std::optional (PR #134142)

2025-04-04 Thread Younan Zhang via llvm-branch-commits


@@ -13343,28 +13344,25 @@ class Sema final : public SemaBase {
   /// The current index into pack expansion arguments that will be
   /// used for substitution of parameter packs.
   ///
-  /// The pack expansion index will be -1 to indicate that parameter packs
+  /// The pack expansion index will be none to indicate that parameter packs
   /// should be instantiated as themselves. Otherwise, the index specifies
   /// which argument within the parameter pack will be used for substitution.
-  int ArgumentPackSubstitutionIndex;
+  UnsignedOrNone ArgPackSubstIndex;
 
   /// RAII object used to change the argument pack substitution index
   /// within a \c Sema object.
   ///
-  /// See \c ArgumentPackSubstitutionIndex for more information.
-  class ArgumentPackSubstitutionIndexRAII {
+  /// See \c ArgPackSubstIndex for more information.
+  class ArgPackSubstIndexRAII {

zyn0217 wrote:

Did you rename it because it was too long to write?

https://github.com/llvm/llvm-project/pull/134142
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] Backport: [clang] Serialization: support hashing null template arguments (PR #141957)

2025-05-29 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.


https://github.com/llvm/llvm-project/pull/141957
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang-tools-extra] release/20.x: [clangd] Guard against trivial FunctionProtoTypeLoc when creating inlay hints (#143087) (PR #143344)

2025-06-08 Thread Younan Zhang via llvm-branch-commits

https://github.com/zyn0217 approved this pull request.


https://github.com/llvm/llvm-project/pull/143344
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits