Author: Christopher Di Bella
Date: 2023-09-11T23:44:50Z
New Revision: dfd1d8d505d61c9b401a3cdd6a687848f1c37cc5

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

LOG: Revert "adds `__reference_constructs_from_temporary`"

I'm reverting this on principle, since it didn't get the Phabricator
approval I thought it had (only an informal LGTM). Will re-apply once
it has been properly approved.

This reverts commit e1bfeb6bcc627a94c5ab3a5417d290c7dc516d54.

Added: 
    

Modified: 
    clang/docs/LanguageExtensions.rst
    clang/include/clang/Basic/TokenKinds.def
    clang/lib/Lex/PPMacroExpansion.cpp
    clang/lib/Parse/ParseDeclCXX.cpp
    clang/lib/Parse/ParseExpr.cpp
    clang/lib/Sema/SemaExprCXX.cpp
    clang/test/SemaCXX/type-traits.cpp
    clang/www/cxx_status.html

Removed: 
    


################################################################################
diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index b9466b5a0bc2087..11cbdca7a268fc3 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1621,10 +1621,6 @@ The following type trait primitives are supported by 
Clang. Those traits marked
   materialized temporary object. If ``T`` is not a reference type the result
   is false. Note this trait will also return false when the initialization of
   ``T`` from ``U`` is ill-formed.
-  Deprecated, use ``__reference_constructs_from_temporary``.
-* ``__reference_constructs_from_temporary(T, U)`` (C++)
-  Returns true if a reference ``T`` can be constructed from a temporary of type
-  a non-cv-qualified ``U``.
 * ``__underlying_type`` (C++, GNU, Microsoft)
 
 In addition, the following expression traits are supported:

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 72e8df8c793a7b6..45ebc200b168986 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -531,7 +531,6 @@ TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
-TYPE_TRAIT_2(__reference_constructs_from_temporary, 
ReferenceConstructsFromTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
 EXPRESSION_TRAIT(__is_lvalue_expr, IsLValueExpr, KEYCXX)

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index ec6a084f228f32d..775cbfafa999602 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1695,7 +1695,6 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
               .Case("__array_rank", true)
               .Case("__array_extent", true)
               .Case("__reference_binds_to_temporary", true)
-              .Case("__reference_constructs_from_temporary", true)
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) .Case("__" #Trait, true)
 #include "clang/Basic/TransformTypeTraits.def"
               .Default(false);

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 5fe9abb1fdcab30..730b6e55246d6b7 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1655,9 +1655,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
           tok::kw___is_union,
           tok::kw___is_unsigned,
           tok::kw___is_void,
-          tok::kw___is_volatile,
-          tok::kw___reference_binds_to_temporary,
-          tok::kw___reference_constructs_from_temporary))
+          tok::kw___is_volatile))
     // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
     // name of struct templates, but some are keywords in GCC >= 4.3
     // and Clang. Therefore, when we see the token sequence "struct

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 74664c34abdbd89..f8bf785da2896a3 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1128,8 +1128,6 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
           REVERTIBLE_TYPE_TRAIT(__is_unsigned);
           REVERTIBLE_TYPE_TRAIT(__is_void);
           REVERTIBLE_TYPE_TRAIT(__is_volatile);
-          REVERTIBLE_TYPE_TRAIT(__reference_binds_to_temporary);
-          REVERTIBLE_TYPE_TRAIT(__reference_constructs_from_temporary);
 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait)                                     
\
   REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
 #include "clang/Basic/TransformTypeTraits.def"

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 65e8edc7806ecd8..a7be01319a72393 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -30,7 +30,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Basic/TypeTraits.h"
-#include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/EnterExpressionEvaluationContext.h"
@@ -5411,15 +5410,14 @@ static bool EvaluateBooleanTypeTrait(Sema &S, TypeTrait 
Kind,
   if (Kind <= UTT_Last)
     return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  // Evaluate ReferenceBindsToTemporary and ReferenceConstructsFromTemporary
-  // alongside the IsConstructible traits to avoid duplication.
-  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary && Kind != 
BTT_ReferenceConstructsFromTemporary)
+  // Evaluate BTT_ReferenceBindsToTemporary alongside the IsConstructible
+  // traits to avoid duplication.
+  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
     return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
                                    Args[1]->getType(), RParenLoc);
 
   switch (Kind) {
   case clang::BTT_ReferenceBindsToTemporary:
-  case clang::BTT_ReferenceConstructsFromTemporary:
   case clang::TT_IsConstructible:
   case clang::TT_IsNothrowConstructible:
   case clang::TT_IsTriviallyConstructible: {
@@ -5496,23 +5494,11 @@ static bool EvaluateBooleanTypeTrait(Sema &S, TypeTrait 
Kind,
     if (Kind == clang::TT_IsConstructible)
       return true;
 
-    if (Kind == clang::BTT_ReferenceBindsToTemporary || Kind == 
clang::BTT_ReferenceConstructsFromTemporary) {
+    if (Kind == clang::BTT_ReferenceBindsToTemporary) {
       if (!T->isReferenceType())
         return false;
 
-      if (!Init.isDirectReferenceBinding())
-        return true;
-
-      if (Kind == clang::BTT_ReferenceBindsToTemporary)
-        return false;
-
-      QualType U = Args[1]->getType();
-      if (U->isReferenceType())
-        return false;
-
-      QualType TPtr = S.BuiltinAddPointer(S.BuiltinRemoveReference(T, 
UnaryTransformType::RemoveCVRef, {}), {});
-      QualType UPtr = S.BuiltinAddPointer(S.BuiltinRemoveReference(U, 
UnaryTransformType::RemoveCVRef, {}), {});
-      return EvaluateBinaryTypeTrait(S, TypeTrait::BTT_IsConvertibleTo, UPtr, 
TPtr, RParenLoc);
+      return !Init.isDirectReferenceBinding();
     }
 
     if (Kind == clang::TT_IsNothrowConstructible)

diff  --git a/clang/test/SemaCXX/type-traits.cpp 
b/clang/test/SemaCXX/type-traits.cpp
index a35689d52978fcc..0fb364eaf362664 100644
--- a/clang/test/SemaCXX/type-traits.cpp
+++ b/clang/test/SemaCXX/type-traits.cpp
@@ -2542,51 +2542,6 @@ void reference_binds_to_temporary_checks() {
   { int arr[T((__reference_binds_to_temporary(const int &, long)))]; }
 }
 
-void reference_constructs_from_temporary_checks() {
-  static_assert(!__reference_constructs_from_temporary(int &, int &), "");
-  static_assert(!__reference_constructs_from_temporary(int &, int &&), "");
-
-  static_assert(!__reference_constructs_from_temporary(int const &, int &), 
"");
-  static_assert(!__reference_constructs_from_temporary(int const &, int const 
&), "");
-  static_assert(!__reference_constructs_from_temporary(int const &, int &&), 
"");
-
-  static_assert(!__reference_constructs_from_temporary(int &, long &), ""); // 
doesn't construct
-
-  static_assert(__reference_constructs_from_temporary(int const &, long &), 
"");
-  static_assert(__reference_constructs_from_temporary(int const &, long &&), 
"");
-  static_assert(__reference_constructs_from_temporary(int &&, long &), "");
-
-  using LRef = ConvertsToRef<int, int &>;
-  using RRef = ConvertsToRef<int, int &&>;
-  using CLRef = ConvertsToRef<int, const int &>;
-  using LongRef = ConvertsToRef<long, long &>;
-  static_assert(__is_constructible(int &, LRef), "");
-  static_assert(!__reference_constructs_from_temporary(int &, LRef), "");
-
-  static_assert(__is_constructible(int &&, RRef), "");
-  static_assert(!__reference_constructs_from_temporary(int &&, RRef), "");
-
-  static_assert(__is_constructible(int const &, CLRef), "");
-  static_assert(!__reference_constructs_from_temporary(int &&, CLRef), "");
-
-  static_assert(__is_constructible(int const &, LongRef), "");
-  static_assert(__reference_constructs_from_temporary(int const &, LongRef), 
"");
-
-  // Test that it doesn't accept non-reference types as input.
-  static_assert(!__reference_constructs_from_temporary(int, long), "");
-
-  static_assert(__reference_constructs_from_temporary(const int &, long), "");
-
-  // Additional checks
-  static_assert(__reference_constructs_from_temporary(POD const&, Derives), 
"");
-  static_assert(__reference_constructs_from_temporary(int&&, int), "");
-  static_assert(__reference_constructs_from_temporary(const int&, int), "");
-  static_assert(!__reference_constructs_from_temporary(int&&, int&&), "");
-  static_assert(!__reference_constructs_from_temporary(const int&, int&&), "");
-  static_assert(__reference_constructs_from_temporary(int&&, long&&), "");
-  static_assert(__reference_constructs_from_temporary(int&&, long), "");
-}
-
 void array_rank() {
   int t01[T(__array_rank(IntAr) == 1)];
   int t02[T(__array_rank(ConstIntArAr) == 2)];

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index b0bae88fd5c33d4..da0a1c219c0ecc7 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -292,9 +292,10 @@ <h2 id="cxx23">C++23 implementation status</h2>
       <td><a href="https://wg21.link/P2255R2";>P2255R2</a></td>
       <td class="partial" align="center">
         <details><summary>Partial</summary>
-          Clang provides <tt>__reference_constructs_from_temporary</tt> type
-          trait builtin, with which 
<tt>std::reference_constructs_from_temporary</tt>
-          implemented. <tt>__reference_converts_from_temporary</tt> needs to be
+          Clang provides a <tt>__reference_binds_to_temporary</tt> type trait
+          builtin, with which the library facility can be partially 
implemented.
+          Both <tt>__reference_constructs_from_temporary</tt> and
+          <tt>__reference_converts_from_temporary</tt> builtins should be
           provided, following the normal cross-vendor convention to implement
           traits requiring compiler support directly.
         </details></td>


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

Reply via email to