Skip to content

Commit 552156f

Browse files
committed
Don't expose __is_deducible trait.
1 parent c524b10 commit 552156f

File tree

10 files changed

+32
-80
lines changed

10 files changed

+32
-80
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ C++20 Feature Support
168168
to update the ``__cpp_concepts`` macro to `202002L`. This enables
169169
``<expected>`` from libstdc++ to work correctly with Clang.
170170

171-
- Implemented the `__is_deducible` builtin to check if the template arguments of
172-
a class/alias template can be deduced from a specific type,
173-
[over.match.class.deduct]p4.
174-
175171
C++23 Feature Support
176172
^^^^^^^^^^^^^^^^^^^^^
177173

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9156,10 +9156,6 @@ def note_inequality_comparison_to_or_assign : Note<
91569156
def err_incomplete_type_used_in_type_trait_expr : Error<
91579157
"incomplete type %0 used in type trait expression">;
91589158

9159-
def err_deducible_non_class_or_alias_types : Error<
9160-
"%0 is not a class or alias template; __is_deducible only supports class or "
9161-
"alias templates">;
9162-
91639159
// C++20 constinit and require_constant_initialization attribute
91649160
def warn_cxx20_compat_constinit : Warning<
91659161
"'constinit' specifier is incompatible with C++ standards before C++20">,

clang/include/clang/Basic/TokenKinds.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
537537
TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
538538
TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
539539
TYPE_TRAIT_2(__reference_constructs_from_temporary, ReferenceConstructsFromTemporary, KEYCXX)
540-
TYPE_TRAIT_2(__is_deducible, IsDeducible, KEYCXX)
541540

542541
// Embarcadero Expression Traits
543542
EXPRESSION_TRAIT(__is_lvalue_expr, IsLValueExpr, KEYCXX)

clang/include/clang/Basic/TypeTraits.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ enum TypeTrait {
2626
#include "clang/Basic/TokenKinds.def"
2727
,
2828
#define TYPE_TRAIT_2(Spelling, Name, Key) BTT_##Name,
29+
// IsDeducible is only used internally by clang for CTAD implementation and
30+
// is not exposed to users.
31+
TYPE_TRAIT_2(/**/, IsDeducible, KEYCXX)
2932
#include "clang/Basic/TokenKinds.def"
30-
BTT_Last = UTT_Last // BTT_Last == last BTT_XX in the enum.
33+
// +1 for the IsDeducible enumerator.
34+
BTT_Last = UTT_Last + 1 // BTT_Last == last BTT_XX in the enum.
35+
3136
#define TYPE_TRAIT_2(Spelling, Name, Key) +1
3237
#include "clang/Basic/TokenKinds.def"
3338
,

clang/lib/Basic/TypeTraits.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ static constexpr const char *TypeTraitNames[] = {
1919
#define TYPE_TRAIT_1(Spelling, Name, Key) #Name,
2020
#include "clang/Basic/TokenKinds.def"
2121
#define TYPE_TRAIT_2(Spelling, Name, Key) #Name,
22+
// IsDeducible is only used internally by clang for CTAD implementation and
23+
// is not exposed to users.
24+
TYPE_TRAIT_2(/**/, IsDeducible, KEYCXX)
2225
#include "clang/Basic/TokenKinds.def"
2326
#define TYPE_TRAIT_N(Spelling, Name, Key) #Name,
2427
#include "clang/Basic/TokenKinds.def"
@@ -28,6 +31,9 @@ static constexpr const char *TypeTraitSpellings[] = {
2831
#define TYPE_TRAIT_1(Spelling, Name, Key) #Spelling,
2932
#include "clang/Basic/TokenKinds.def"
3033
#define TYPE_TRAIT_2(Spelling, Name, Key) #Spelling,
34+
// __is_deducible is only used internally by clang for CTAD implementation
35+
// and is not exposed to users.
36+
TYPE_TRAIT_2(__is_deducible, /**/, KEYCXX)
3137
#include "clang/Basic/TokenKinds.def"
3238
#define TYPE_TRAIT_N(Spelling, Name, Key) #Spelling,
3339
#include "clang/Basic/TokenKinds.def"
@@ -59,6 +65,9 @@ static constexpr const unsigned TypeTraitArities[] = {
5965
#define TYPE_TRAIT_1(Spelling, Name, Key) 1,
6066
#include "clang/Basic/TokenKinds.def"
6167
#define TYPE_TRAIT_2(Spelling, Name, Key) 2,
68+
// IsDeducible is only used internally by clang for CTAD implementation and
69+
// is not exposed to users.
70+
TYPE_TRAIT_2(/**/, IsDeducible, KEYCXX)
6271
#include "clang/Basic/TokenKinds.def"
6372
#define TYPE_TRAIT_N(Spelling, Name, Key) 0,
6473
#include "clang/Basic/TokenKinds.def"

clang/lib/Parse/ParseExprCXX.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,18 +3906,14 @@ ExprResult Parser::ParseTypeTrait() {
39063906
BalancedDelimiterTracker Parens(*this, tok::l_paren);
39073907
if (Parens.expectAndConsume())
39083908
return ExprError();
3909-
TypeTrait TTKind = TypeTraitFromTokKind(Kind);
3909+
39103910
SmallVector<ParsedType, 2> Args;
39113911
do {
39123912
// Parse the next type.
3913-
TypeResult Ty = ParseTypeName(
3914-
/*SourceRange=*/nullptr,
3915-
getLangOpts().CPlusPlus
3916-
// For __is_deducible type trait, the first argument is a template
3917-
// specification type without template argument lists.
3918-
? (TTKind == BTT_IsDeducible ? DeclaratorContext::TemplateArg
3919-
: DeclaratorContext::TemplateTypeArg)
3920-
: DeclaratorContext::TypeName);
3913+
TypeResult Ty = ParseTypeName(/*SourceRange=*/nullptr,
3914+
getLangOpts().CPlusPlus
3915+
? DeclaratorContext::TemplateTypeArg
3916+
: DeclaratorContext::TypeName);
39213917
if (Ty.isInvalid()) {
39223918
Parens.skipToEnd();
39233919
return ExprError();
@@ -3941,7 +3937,7 @@ ExprResult Parser::ParseTypeTrait() {
39413937

39423938
SourceLocation EndLoc = Parens.getCloseLocation();
39433939

3944-
return Actions.ActOnTypeTrait(TTKind, Loc, Args, EndLoc);
3940+
return Actions.ActOnTypeTrait(TypeTraitFromTokKind(Kind), Loc, Args, EndLoc);
39453941
}
39463942

39473943
/// ParseArrayTypeTrait - Parse the built-in array type-trait

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6125,9 +6125,7 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI
61256125
TSTToBeDeduced->getTemplateName().getAsTemplateDecl(), RhsT,
61266126
Info) == TemplateDeductionResult::Success;
61276127
}
6128-
Self.Diag(Lhs->getTypeLoc().getBeginLoc(),
6129-
diag::err_deducible_non_class_or_alias_types)
6130-
<< LhsT << Lhs->getTypeLoc().getSourceRange();
6128+
assert("Expect to see DeducedTemplateSpecializationType!");
61316129
return false;
61326130
}
61336131
default: llvm_unreachable("not a BTT");

clang/test/SemaCXX/type-traits-is-deducible.cpp

Lines changed: 0 additions & 55 deletions
This file was deleted.

clang/test/SemaTemplate/deduction-guide.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ using AFoo = Foo<G<U>>;
282282
// CHECK-NEXT: | | `-ImplicitCastExpr {{.*}}
283283
// CHECK-NEXT: | | `-IntegerLiteral {{.*}}
284284
// CHECK-NEXT: | `-TypeTraitExpr {{.*}} 'bool' __is_deducible
285-
// CHECK-NEXT: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for AFoo> 'auto (G<type-parameter-0-0>) -> Foo<G<type-parameter-0-0>>'
285+
// CHECK-NEXT: | |-DeducedTemplateSpecializationType {{.*}} 'AFoo' dependent
286+
// CHECK-NEXT: | `-TemplateSpecializationType {{.*}} 'Foo<G<type-parameter-0-0>>' dependent Foo
287+
// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for AFoo> 'auto (G<type-parameter-0-0>) -> Foo<G<type-parameter-0-0>>'
286288
// CHECK-NEXT: | `-ParmVarDecl {{.*}} 'G<type-parameter-0-0>'
287289
// CHECK-NEXT: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for AFoo> 'auto (G<int>) -> Foo<G<int>>' implicit_instantiation
288290
// CHECK-NEXT: |-TemplateArgument type 'int'

clang/www/cxx_status.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,13 @@ <h2 id="cxx20">C++20 implementation status</h2>
875875
<tr>
876876
<td>Class template argument deduction for alias templates</td>
877877
<td><a href="https://wg21.link/p1814r0">P1814R0</a></td>
878-
<td class="partial" align="center">Clang 19 (Partial)</td>
878+
<td class="partial" align="center">
879+
<details>
880+
<summary>Clang 19 (Partial)</summary>
881+
This feature has been initially completed, but the feature macro
882+
__cpp_deduction_guides has not been updated.
883+
</details>
884+
</td>
879885
</tr>
880886
<tr>
881887
<td>Permit conversions to arrays of unknown bound</td>

0 commit comments

Comments
 (0)