https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 2385c46a2ae67e0890a7232fdec16b0b92da060b Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/3] [clang] CTAD: implement the missing IsDeducible
constraint for a
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 2385c46a2ae67e0890a7232fdec16b0b92da060b Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/3] [clang] CTAD: implement the missing IsDeducible
constraint for a
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
You can test this locally with the following command:
``bash
git-clang-format --diff 83bc7b57714dc2f6b33c188f2b95a0025468ba51
502066518604dde5c7596f377a61d25562d2a5ab --
@@ -868,13 +868,7 @@ C++20 implementation status
Class template argument deduction for alias templates
https://wg21.link/p1814r0";>P1814R0
-
-
- Clang 19 (Partial)
- The associated constraints (over.match.class.deduct#3.3) for th
hokein wrote:
OK, I have hidden the `__is_deducible` trait as suggested. Please take another
look.
https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/
cor3ntin wrote:
> OK, I have hidden the `__is_deducible` trait as suggested. Please take
> another look.
Sorry, I think my suggestion was not clear enough.
did you try to put `TYPE_TRAIT_2(/**/, IsDeducible, KEYCXX)` in
`TokenKinds.def` (and then other headers should _NOT_ be modified)
https
hokein wrote:
> > OK, I have hidden the `__is_deducible` trait as suggested. Please take
> > another look.
>
> Sorry, I think my suggestion was not clear enough. did you try to put
> `TYPE_TRAIT_2(/**/, IsDeducible, KEYCXX)` in `TokenKinds.def` (and then other
> headers should _NOT_ be modifi
cor3ntin wrote:
> Ah, I see. I haven't tried that, but one downside I can see is that it will
> make diagnostics for CTAD worse, we need to spell the type trait name in
> error messages when the __is_deducible trait fails.
I think we should have a custom diag for that anyway
"is not deducible
hokein wrote:
> > Ah, I see. I haven't tried that, but one downside I can see is that it will
> > make diagnostics for CTAD worse, we need to spell the type trait name in
> > error messages when the __is_deducible trait fails.
>
> I think we should have a custom diag for that anyway "is not de
hokein wrote:
It appears that the consensus is to avoid exposing the internal
`__is_deducible` type trait to end-users, as there are no compelling use cases
and it's not expected to be used in libc++. This also aligns with the approach
taken by GCC.
Regarding implementation, the current table
cor3ntin wrote:
@hokein Independently of the direction taken I'd like to see a better
diagnostic than "atomic constraint using an undocumented/cryptic trait that is
not in the code is not satisfied". So when we try to print atomic constraints,
we should do something more user friendly for is_d
hokein wrote:
> @hokein Independently of the direction taken I'd like to see a better
> diagnostic than "atomic constraint using an undocumented/cryptic trait that
> is not in the code is not satisfied".
> So when we try to print atomic constraints, we should do something more user
> friendly
cor3ntin wrote:
> I agree with you -- having a well-described diagnostic message is better and
> clearer. I'm happy to improve it once we settle on the final implementation
> approach (the current diagnostic because '__is_deducible(AFoo, Foo)'
> evaluated to false seems okay to me. GCC also em
https://github.com/hokein created
https://github.com/llvm/llvm-project/pull/89358
Fixes https://github.com/llvm/llvm-project/issues/85192
Fixes https://github.com/llvm/llvm-project/issues/84492
This patch implements the "IsDeducible" constraint where the template arguments
of the alias templat
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Haojian Wu (hokein)
Changes
Fixes https://github.com/llvm/llvm-project/issues/85192
Fixes https://github.com/llvm/llvm-project/issues/84492
This patch implements the "IsDeducible" constraint where the template arguments
of the alias templ
hokein wrote:
Regarding the __is_deducible type trait, GCC also provides one, but it was
hidden from users and only used for internal CTAD implementation. I'm not sure
if we should follow the same strategy in clang, ideas?
https://github.com/llvm/llvm-project/pull/89358
__
https://github.com/erichkeane commented:
Needs a release note, and I think we actually DO have to do those diagnostics
here.
https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.o
@@ -6100,6 +6100,17 @@ static bool EvaluateBinaryTypeTrait(Sema &Self,
TypeTrait BTT, const TypeSourceI
tok::kw___is_pointer_interconvertible_base_of);
return Self.IsPointerInterconvertibleBaseOf(Lhs, Rhs);
+ }
+ case BTT_IsDeducible: {
+
@@ -3207,6 +3241,59 @@
Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
return ::DeduceTemplateArguments(*this, Partial, TemplateArgs, Info);
}
+TemplateDeductionResult
+Sema::DeduceTemplateArgumentsFromType(TemplateDecl *TD, QualType FromType,
+
https://github.com/erichkeane edited
https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 9583811bfa66ff058f5e33012cd77501ce3e5e23 Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/2] [clang] CTAD: implement the missing IsDeducible
constraint for a
@@ -3207,6 +3241,59 @@
Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
return ::DeduceTemplateArguments(*this, Partial, TemplateArgs, Info);
}
+TemplateDeductionResult
+Sema::DeduceTemplateArgumentsFromType(TemplateDecl *TD, QualType FromType,
+
@@ -6100,6 +6100,17 @@ static bool EvaluateBinaryTypeTrait(Sema &Self,
TypeTrait BTT, const TypeSourceI
tok::kw___is_pointer_interconvertible_base_of);
return Self.IsPointerInterconvertibleBaseOf(Lhs, Rhs);
+ }
+ case BTT_IsDeducible: {
+
hokein wrote:
> Needs a release note, and I think we actually DO have to do those diagnostics
> here.
Added a release note for the new builtin.
https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
h
cor3ntin wrote:
> Regarding the __is_deducible type trait, GCC also provides one, but it was
> hidden from users and only used for internal CTAD implementation. I'm not
> sure if we should follow the same strategy in clang, ideas?
I have mixed feeling. What do you think @AaronBallman ?
https:
AaronBallman wrote:
> > Regarding the __is_deducible type trait, GCC also provides one, but it was
> > hidden from users and only used for internal CTAD implementation. I'm not
> > sure if we should follow the same strategy in clang, ideas?
>
> I have mixed feeling. What do you think @AaronBal
@@ -868,13 +868,7 @@ C++20 implementation status
Class template argument deduction for alias templates
https://wg21.link/p1814r0";>P1814R0
-
-
- Clang 19 (Partial)
- The associated constraints (over.match.class.deduct#3.3) for th
hokein wrote:
> > > Regarding the __is_deducible type trait, GCC also provides one, but it
> > > was hidden from users and only used for internal CTAD implementation. I'm
> > > not sure if we should follow the same strategy in clang, ideas?
> >
> >
> > I have mixed feeling. What do you think
@@ -868,13 +868,7 @@ C++20 implementation status
Class template argument deduction for alias templates
https://wg21.link/p1814r0";>P1814R0
-
-
- Clang 19 (Partial)
- The associated constraints (over.match.class.deduct#3.3) for th
cor3ntin wrote:
> This approach is doable technically, but it feels hacky and fragile. What if
> we emit an error (or warning) diagnostic and reject the code when we parse
> the __is_deducible type trait?
Why do you think it is fragile? I think a comment around `BTT_IsDeducible`
would take ca
@@ -868,13 +868,7 @@ C++20 implementation status
Class template argument deduction for alias templates
https://wg21.link/p1814r0";>P1814R0
-
-
- Clang 19 (Partial)
- The associated constraints (over.match.class.deduct#3.3) for th
cor3ntin wrote:
> > > This approach is doable technically, but it feels hacky and fragile. What
> > > if we emit an error (or warning) diagnostic and reject the code when we
> > > parse the __is_deducible type trait?
> >
> >
> > Why do you think it is fragile? I think a comment around `BTT_Is
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 20947c1a34fae3593a98dba125e5d70d652c7190 Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH] [clang] CTAD: implement the missing IsDeducible constraint
for alias
@@ -190,13 +196,15 @@ template struct Foo { Foo(T); };
template using AFoo = Foo;
template concept False = false;
-template using BFoo = AFoo;
+template
+using BFoo = AFoo; // expected-note {{candidate template ignored:
constraints not satisfied [with V = int]}} \
+
@@ -18,6 +18,7 @@
#include "clang/AST/ExprCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
hokein wrote:
Done.
https://github.com/llvm/llvm-project/pull/89358
__
@@ -27,7 +27,8 @@ enum TypeTrait {
,
#define TYPE_TRAIT_2(Spelling, Name, Key) BTT_##Name,
#include "clang/Basic/TokenKinds.def"
- BTT_Last = UTT_Last // BTT_Last == last BTT_XX in the enum.
+ BTT_Last = UTT_Last
hokein wrote:
Reverted the change.
https:/
@@ -6116,6 +6116,17 @@ static bool EvaluateBinaryTypeTrait(Sema &Self,
TypeTrait BTT, const TypeSourceI
tok::kw___is_pointer_interconvertible_base_of);
return Self.IsPointerInterconvertibleBaseOf(Lhs, Rhs);
+ }
+ case BTT_IsDeducible: {
+
@@ -2774,6 +2775,41 @@ Expr *transformRequireClause(Sema &SemaRef,
FunctionTemplateDecl *FTD,
return E.getAs();
}
+// Build the associated constraints for the alias deduction guides.
+// C++ [over.match.class.deduct]p3.3:
+// The associated constraints ([temp.constr.decl]
https://github.com/cor3ntin edited
https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -2774,6 +2775,41 @@ Expr *transformRequireClause(Sema &SemaRef,
FunctionTemplateDecl *FTD,
return E.getAs();
}
+// Build the associated constraints for the alias deduction guides.
+// C++ [over.match.class.deduct]p3.3:
+// The associated constraints ([temp.constr.decl]
https://github.com/cor3ntin approved this pull request.
I'll approve that modulo nit but i think we want
- An issue to keep track of the duplication in `FinishTemplateArgumentDeduction`
- A follow up PR to improve diagnostics
Thanks!
https://github.com/llvm/llvm-project/pull/89358
___
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 20947c1a34fae3593a98dba125e5d70d652c7190 Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/2] [clang] CTAD: implement the missing IsDeducible
constraint for a
hokein wrote:
Thanks for the review.
> I'll approve that modulo nit but i think we want
>
> * An issue to keep track of the duplication in
> `FinishTemplateArgumentDeduction`
Filed #92224.
> * A follow up PR to improve diagnostics
Filed #92225, and assigned to myself. Will do it.
> Thanks!
@@ -2774,6 +2775,41 @@ Expr *transformRequireClause(Sema &SemaRef,
FunctionTemplateDecl *FTD,
return E.getAs();
}
+// Build the associated constraints for the alias deduction guides.
+// C++ [over.match.class.deduct]p3.3:
+// The associated constraints ([temp.constr.decl]
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 659cf5b5c1216ab9f6a8dbb63b4f93de41cd173d Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/2] [clang] CTAD: implement the missing IsDeducible
constraint for a
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 659cf5b5c1216ab9f6a8dbb63b4f93de41cd173d Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/2] [clang] CTAD: implement the missing IsDeducible
constraint for a
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 659cf5b5c1216ab9f6a8dbb63b4f93de41cd173d Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/2] [clang] CTAD: implement the missing IsDeducible
constraint for a
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From 659cf5b5c1216ab9f6a8dbb63b4f93de41cd173d Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/2] [clang] CTAD: implement the missing IsDeducible
constraint for a
https://github.com/cor3ntin approved this pull request.
https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/hokein closed https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/hokein updated
https://github.com/llvm/llvm-project/pull/89358
>From bf6acda6c7cb9a08b82b149c0df38d90e395f9e1 Mon Sep 17 00:00:00 2001
From: Haojian Wu
Date: Fri, 19 Apr 2024 10:54:12 +0200
Subject: [PATCH 1/4] [clang] CTAD: implement the missing IsDeducible
constraint for a
hokein wrote:
> > I agree with you -- having a well-described diagnostic message is better
> > and clearer. I'm happy to improve it once we settle on the final
> > implementation approach (the current diagnostic because
> > '__is_deducible(AFoo, Foo)' evaluated to false seems okay to me. GCC a
@@ -18,6 +18,7 @@
#include "clang/AST/ExprCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
cor3ntin wrote:
Probably not a needed change
https://github.com/llvm/llvm-project/pull/89358
_
@@ -3239,6 +3239,40 @@ static TemplateDeductionResult
FinishTemplateArgumentDeduction(
return TemplateDeductionResult::Success;
}
+/// Complete template argument deduction for DeduceTemplateArgumentsFromType.
+/// FIXME: this is mostly duplicated with the above two versions
@@ -6116,6 +6116,17 @@ static bool EvaluateBinaryTypeTrait(Sema &Self,
TypeTrait BTT, const TypeSourceI
tok::kw___is_pointer_interconvertible_base_of);
return Self.IsPointerInterconvertibleBaseOf(Lhs, Rhs);
+ }
+ case BTT_IsDeducible: {
+
@@ -3307,6 +3341,58 @@
Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
return ::DeduceTemplateArguments(*this, Partial, TemplateArgs, Info);
}
+TemplateDeductionResult
+Sema::DeduceTemplateArgumentsFromType(TemplateDecl *TD, QualType FromType,
-
@@ -190,13 +196,15 @@ template struct Foo { Foo(T); };
template using AFoo = Foo;
template concept False = false;
-template using BFoo = AFoo;
+template
+using BFoo = AFoo; // expected-note {{candidate template ignored:
constraints not satisfied [with V = int]}} \
+
@@ -2774,6 +2775,41 @@ Expr *transformRequireClause(Sema &SemaRef,
FunctionTemplateDecl *FTD,
return E.getAs();
}
+// Build the associated constraints for the alias deduction guides.
+// C++ [over.match.class.deduct]p3.3:
+// The associated constraints ([temp.constr.decl]
@@ -27,7 +27,8 @@ enum TypeTrait {
,
#define TYPE_TRAIT_2(Spelling, Name, Key) BTT_##Name,
#include "clang/Basic/TokenKinds.def"
- BTT_Last = UTT_Last // BTT_Last == last BTT_XX in the enum.
+ BTT_Last = UTT_Last
cor3ntin wrote:
Why remove the comment?
ht
https://github.com/hokein edited https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3239,6 +3239,40 @@ static TemplateDeductionResult
FinishTemplateArgumentDeduction(
return TemplateDeductionResult::Success;
}
+/// Complete template argument deduction for DeduceTemplateArgumentsFromType.
+/// FIXME: this is mostly duplicated with the above two versions
@@ -27,7 +27,8 @@ enum TypeTrait {
,
#define TYPE_TRAIT_2(Spelling, Name, Key) BTT_##Name,
#include "clang/Basic/TokenKinds.def"
- BTT_Last = UTT_Last // BTT_Last == last BTT_XX in the enum.
+ BTT_Last = UTT_Last
hokein wrote:
oops, this is not intended. T
@@ -190,13 +196,15 @@ template struct Foo { Foo(T); };
template using AFoo = Foo;
template concept False = false;
-template using BFoo = AFoo;
+template
+using BFoo = AFoo; // expected-note {{candidate template ignored:
constraints not satisfied [with V = int]}} \
+
@@ -3307,6 +3341,58 @@
Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
return ::DeduceTemplateArguments(*this, Partial, TemplateArgs, Info);
}
+TemplateDeductionResult
+Sema::DeduceTemplateArgumentsFromType(TemplateDecl *TD, QualType FromType,
-
https://github.com/hokein commented:
Replied some review comments. I haven't updated the code yet (plan to do it
after #90961)
https://github.com/llvm/llvm-project/pull/89358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.o
@@ -190,13 +196,15 @@ template struct Foo { Foo(T); };
template using AFoo = Foo;
template concept False = false;
-template using BFoo = AFoo;
+template
+using BFoo = AFoo; // expected-note {{candidate template ignored:
constraints not satisfied [with V = int]}} \
+
@@ -3237,6 +3237,40 @@ static TemplateDeductionResult
FinishTemplateArgumentDeduction(
return TemplateDeductionResult::Success;
}
+/// Complete template argument deduction for DeduceTemplateArgumentsFromType.
+/// FIXME: this is mostly duplicated with the above two versions
68 matches
Mail list logo