cjdb updated this revision to Diff 556497.
cjdb retitled this revision from "[clang] adds 
`__reference_constructs_from_temporary`" to "adds 
`__reference_constructs_from_temporary`".
cjdb edited the summary of this revision.
cjdb added a comment.

Corrects cxx_status.html, which accidentally duplicated a lot of the file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135341/new/

https://reviews.llvm.org/D135341

Files:
  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

Index: clang/www/cxx_status.html
===================================================================
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -228,199 +228,6 @@
       <td><a href="https://wg21.link/P2797R0";>P2797R0</a></td>
       <td class="none" align="center">No</td>
     </tr>
-    <tr>
-      <td rowspan=2>Change scope of lambda trailing-return-type</td>
-      <td><a href="https://wg21.link/P2036R3";>P2036R3</a></td>
-      <td rowspan=2 class="unreleased" align="center">Clang 17</td>
-    </tr>
-    <tr>
-      <td><a href="https://wg21.link/P2579R0";>P2579R0</a></td>
-    </tr>
-    <tr>
-      <td>Multidimensional subscript operator</td>
-      <td><a href="https://wg21.link/P2128R6";>P2128R6</a></td>
-      <td class="full" align="center">Clang 15</td>
-    </tr>
-    <tr>
-      <td>Non-literal variables (and labels and gotos) in constexpr functions</td>
-      <td><a href="https://wg21.link/P2242R3";>P2242R3</a></td>
-      <td class="full" align="center">Clang 15</td>
-    </tr>
-    <tr>
-      <td>Character encoding of diagnostic text</td>
-      <td><a href="https://wg21.link/P2246R1";>P2246R1</a></td>
-      <td class="full" align="center">Yes</td>
-    </tr>
-    <tr>
-      <td>Character sets and encodings</td>
-      <td><a href="https://wg21.link/P2314R4";>P2314R4</a></td>
-      <td class="full" align="center">Yes</td>
-    </tr>
-    <tr>
-      <td>Consistent character literal encoding</td>
-      <td><a href="https://wg21.link/P2316R2";>P2316R2</a></td>
-      <td class="full" align="center">Yes</td>
-    </tr>
-    <tr>
-      <td>Add support for preprocessing directives elifdef and elifndef</td>
-      <td><a href="https://wg21.link/P2334R1";>P2334R1</a></td>
-      <td class="full" align="center">Clang 13</td>
-    </tr>
-    <tr>
-      <td>Extend init-statement to allow alias-declaration</td>
-      <td><a href="https://wg21.link/P2360R0";>P2360R0</a></td>
-      <td class="full" align="center">Clang 14</td>
-    </tr>
-    <tr>
-      <td>auto(x): decay-copy in the language</td>
-      <td><a href="https://wg21.link/P0849R8";>P0849R8</a></td>
-      <td class="full" align="center">Clang 15</td>
-    </tr>
-    <!-- February 2022 papers -->
-    <tr>
-      <td>Attributes on Lambda-Expressions</td>
-      <td><a href="https://wg21.link/P2173R1";>P2173R1</a></td>
-      <td class="full" align="center">Clang 13</td>
-    </tr>
-    <tr>
-      <td><tt>constexpr</tt> for <tt>&lt;cmath&gt;</tt> and <tt>&lt;cstdlib&gt;</tt></td>
-      <td><a href="https://wg21.link/P0533R9";>P0533R9</a></td>
-      <td class="none" align="center">No</td>
-    </tr>
-    <tr>
-      <td>Type trait to determine if a reference binds to a temporary</td>
-      <td><a href="https://wg21.link/P2255R2";>P2255R2</a></td>
-      <td class="partial" align="center">
-        <details><summary>Partial</summary>
-          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>
-      </td>
-    </tr>
-    <!-- July 2022 papers -->
-    <tr>
-      <td>The Equality Operator You Are Looking For</td>
-      <td><a href="https://wg21.link/P2468R2";>P2468R2</a></td>
-      <td class="full" align="center">Clang 16</td>
-    </tr>
-    <tr>
-      <td>De-deprecating volatile compound operations</td>
-      <td><a href="https://wg21.link/P2327R1";>P2327R1</a></td>
-      <td class="full" align="center">Clang 15</td>
-    </tr>
-    <tr>
-      <td>Support for <code>#warning</code></td>
-      <td><a href="https://wg21.link/P2437R1";>P2437R1</a></td>
-      <td class="full" align="center">Yes</td>
-    </tr>
-    <tr>
-      <td>Remove non-encodable wide character literals and multicharacter wide character literals</td>
-      <td><a href="https://wg21.link/P2362R3";>P2362R3</a></td>
-      <td class="full" align="center">Clang 14</td>
-    </tr>
-    <tr>
-      <td>Labels at the end of compound statements</td>
-      <td><a href="https://wg21.link/P2324R2";>P2324R2</a></td>
-      <td class="full" align="center">Clang 16</td>
-    </tr>
-    <tr>
-      <td>Delimited escape sequences</td>
-      <td><a href="https://wg21.link/P2290R3";>P2290R3</a></td>
-      <td class="full" align="center">Clang 15</td>
-    </tr>
-    <tr>
-      <td>Named universal character escapes</td>
-      <td><a href="https://wg21.link/P2071R2";>P2071R2</a></td>
-      <td class="full" align="center">Clang 15</td>
-    </tr>
-    <tr>
-      <td>Relaxing some constexpr restrictions</td>
-      <td><a href="https://wg21.link/P2448R2";>P2448R2</a></td>
-      <td class="partial" align="center">
-        <details><summary>Clang 17 (Partial)</summary>
-	  We do not support outside of defaulted special memeber functions the change that constexpr functions no
-          longer have to be constexpr compatible but rather support a less restricted requirements for constexpr
-          functions. Which include allowing non-literal types as return values and parameters, allow calling of
-          non-constexpr functions and constructors.
-        </details></td>
-      </td>
-    </tr>
-    <tr>
-      <td>Using unknown pointers and references in constant expressions</td>
-      <td><a href="https://wg21.link/P2280R4";>P2280R4</a> (<a href="#dr">DR</a>)</td>
-      <td class="none" align="center">No</td>
-    </tr>
-    <tr>
-      <td>static <code>operator()</code></td>
-      <td><a href="https://wg21.link/P1169R4";>P1169R4</a></td>
-      <td class="full" align="center">Clang 16</td>
-    </tr>
-    <tr>
-      <td>Extended floating-point types and standard names</td>
-      <td><a href="https://wg21.link/P1467R9";>P1467R9</a></td>
-      <td class="none" align="center">No</td>
-    </tr>
-    <tr>
-      <td>Class template argument deduction from inherited constructors</td>
-      <td><a href="https://wg21.link/P2582R1";>P2582R1</a></td>
-      <td class="none" align="center">No</td>
-    </tr>
-    <tr>
-      <td>Portable assumptions</td>
-      <td><a href="https://wg21.link/P1774R8";>P1774R8</a></td>
-      <td class="none" align="center">No</td>
-    </tr>
-    <tr>
-      <td>Support for UTF-8 as a portable source file encoding</td>
-      <td><a href="https://wg21.link/P2295R6";>P2295R6</a></td>
-      <td class="full" align="center">Clang 15</td>
-    </tr>
-    <tr>
-      <td><code>char8_t</code> Compatibility and Portability Fix</td>
-      <td><a href="https://wg21.link/P2513R3";>P2513R3</a></td>
-      <td class="full" align="center">Clang 16</td>
-    </tr>
-    <tr>
-      <td>Relax requirements on <code>wchar_t</code> to match existing practices</td>
-      <td><a href="https://wg21.link/P2460R2";>P2460R2</a></td>
-      <td class="full" align="center">Yes</td>
-    </tr>
-    <tr>
-      <td>Explicit lifetime management</td>
-      <td><a href="https://wg21.link/P2590R2";>P2590R2</a></td>
-      <td class="none" align="center">No</td>
-    </tr>
-    <!-- November 2022 (Kona) papers -->
-    <tr>
-      <td>static <code>operator[]</code></td>
-      <td><a href="https://wg21.link/P2589R1";>P2589R1</a></td>
-      <td class="full" align="center">Clang 16</td>
-    </tr>
-    <tr>
-      <td>Permitting static constexpr variables in constexpr functions</td>
-      <td><a href="https://wg21.link/P2647R1";>P2647R1</a></td>
-      <td class="full" align="center">Clang 16</td>
-    </tr>
-    <tr>
-      <td>consteval needs to propagate up</td>
-      <td><a href="https://wg21.link/P2564R3";>P2564R3</a> (<a href="#dr">DR</a>)</td>
-      <td class="unreleased" align="center">Clang 17</td>
-    </tr>
-    <tr>
-      <td>Lifetime extension in range-based for loops</td>
-      <td><a href="https://wg21.link/P2718R0";>P2718R0</a></td>
-      <td class="none" align="center">No</td>
-    </tr>
-    <!--Issaquah 2023 papers-->
-    <tr>
-      <td>Referencing The Unicode Standard</td>
-      <td><a href="https://wg21.link/P2736R2";>P2736R2</a></td>
-      <td class="full" align="center">Yes</td>
-    </tr>
 </table>
 </details>
 
@@ -1091,6 +898,197 @@
       <td><a href="https://wg21.link/p0195r2";>P0195R2</a></td>
       <td class="full" align="center">Clang 4</td>
     </tr>
+      <td rowspan=2>Change scope of lambda trailing-return-type</td>
+      <td><a href="https://wg21.link/P2036R3";>P2036R3</a></td>
+      <td rowspan=2 class="unreleased" align="center">Clang 17</td>
+    </tr>
+    <tr>
+      <td><a href="https://wg21.link/P2579R0";>P2579R0</a></td>
+    </tr>
+    <tr>
+      <td>Multidimensional subscript operator</td>
+      <td><a href="https://wg21.link/P2128R6";>P2128R6</a></td>
+      <td class="full" align="center">Clang 15</td>
+    </tr>
+    <tr>
+      <td>Non-literal variables (and labels and gotos) in constexpr functions</td>
+      <td><a href="https://wg21.link/P2242R3";>P2242R3</a></td>
+      <td class="full" align="center">Clang 15</td>
+    </tr>
+    <tr>
+      <td>Character encoding of diagnostic text</td>
+      <td><a href="https://wg21.link/P2246R1";>P2246R1</a></td>
+      <td class="full" align="center">Yes</td>
+    </tr>
+    <tr>
+      <td>Character sets and encodings</td>
+      <td><a href="https://wg21.link/P2314R4";>P2314R4</a></td>
+      <td class="full" align="center">Yes</td>
+    </tr>
+    <tr>
+      <td>Consistent character literal encoding</td>
+      <td><a href="https://wg21.link/P2316R2";>P2316R2</a></td>
+      <td class="full" align="center">Yes</td>
+    </tr>
+    <tr>
+      <td>Add support for preprocessing directives elifdef and elifndef</td>
+      <td><a href="https://wg21.link/P2334R1";>P2334R1</a></td>
+      <td class="full" align="center">Clang 13</td>
+    </tr>
+    <tr>
+      <td>Extend init-statement to allow alias-declaration</td>
+      <td><a href="https://wg21.link/P2360R0";>P2360R0</a></td>
+      <td class="full" align="center">Clang 14</td>
+    </tr>
+    <tr>
+      <td>auto(x): decay-copy in the language</td>
+      <td><a href="https://wg21.link/P0849R8";>P0849R8</a></td>
+      <td class="full" align="center">Clang 15</td>
+    </tr>
+    <!-- February 2022 papers -->
+    <tr>
+      <td>Attributes on Lambda-Expressions</td>
+      <td><a href="https://wg21.link/P2173R1";>P2173R1</a></td>
+      <td class="full" align="center">Clang 13</td>
+    </tr>
+    <tr>
+      <td><tt>constexpr</tt> for <tt>&lt;cmath&gt;</tt> and <tt>&lt;cstdlib&gt;</tt></td>
+      <td><a href="https://wg21.link/P0533R9";>P0533R9</a></td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <tr>
+      <td>Type trait to determine if a reference binds to a temporary</td>
+      <td><a href="https://wg21.link/P2255R2";>P2255R2</a></td>
+      <td class="partial" align="center">
+        <details><summary>Partial</summary>
+          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.
+      </td>
+    </tr>
+    <!-- July 2022 papers -->
+    <tr>
+      <td>The Equality Operator You Are Looking For</td>
+      <td><a href="https://wg21.link/P2468R2";>P2468R2</a></td>
+      <td class="full" align="center">Clang 16</td>
+    </tr>
+    <tr>
+      <td>De-deprecating volatile compound operations</td>
+      <td><a href="https://wg21.link/P2327R1";>P2327R1</a></td>
+      <td class="full" align="center">Clang 15</td>
+    </tr>
+    <tr>
+      <td>Support for <code>#warning</code></td>
+      <td><a href="https://wg21.link/P2437R1";>P2437R1</a></td>
+      <td class="full" align="center">Yes</td>
+    </tr>
+    <tr>
+      <td>Remove non-encodable wide character literals and multicharacter wide character literals</td>
+      <td><a href="https://wg21.link/P2362R3";>P2362R3</a></td>
+      <td class="full" align="center">Clang 14</td>
+    </tr>
+    <tr>
+      <td>Labels at the end of compound statements</td>
+      <td><a href="https://wg21.link/P2324R2";>P2324R2</a></td>
+      <td class="full" align="center">Clang 16</td>
+    </tr>
+    <tr>
+      <td>Delimited escape sequences</td>
+      <td><a href="https://wg21.link/P2290R3";>P2290R3</a></td>
+      <td class="full" align="center">Clang 15</td>
+    </tr>
+    <tr>
+      <td>Named universal character escapes</td>
+      <td><a href="https://wg21.link/P2071R2";>P2071R2</a></td>
+      <td class="full" align="center">Clang 15</td>
+    </tr>
+    <tr>
+      <td>Relaxing some constexpr restrictions</td>
+      <td><a href="https://wg21.link/P2448R2";>P2448R2</a></td>
+      <td class="partial" align="center">
+        <details><summary>Clang 17 (Partial)</summary>
+	  We do not support outside of defaulted special memeber functions the change that constexpr functions no
+          longer have to be constexpr compatible but rather support a less restricted requirements for constexpr
+          functions. Which include allowing non-literal types as return values and paremeters, allow calling of
+          non-constexpr functions and constructors.
+        </details></td>
+      </td>
+    </tr>
+    <tr>
+      <td>Using unknown pointers and references in constant expressions</td>
+      <td><a href="https://wg21.link/P2280R4";>P2280R4</a></td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <tr>
+      <td>static <code>operator()</code></td>
+      <td><a href="https://wg21.link/P1169R4";>P1169R4</a></td>
+      <td class="full" align="center">Clang 16</td>
+    </tr>
+    <tr>
+      <td>Extended floating-point types and standard names</td>
+      <td><a href="https://wg21.link/P1467R9";>P1467R9</a></td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <tr>
+      <td>Class template argument deduction from inherited constructors</td>
+      <td><a href="https://wg21.link/P2582R1";>P2582R1</a></td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <tr>
+      <td>Portable assumptions</td>
+      <td><a href="https://wg21.link/P1774R8";>P1774R8</a></td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <tr>
+      <td>Support for UTF-8 as a portable source file encoding</td>
+      <td><a href="https://wg21.link/P2295R6";>P2295R6</a></td>
+      <td class="full" align="center">Clang 15</td>
+    </tr>
+    <tr>
+      <td><code>char8_t</code> Compatibility and Portability Fix</td>
+      <td><a href="https://wg21.link/P2513R3";>P2513R3</a></td>
+      <td class="full" align="center">Clang 16</td>
+    </tr>
+    <tr>
+      <td>Relax requirements on <code>wchar_t</code> to match existing practices</td>
+      <td><a href="https://wg21.link/P2460R2";>P2460R2</a></td>
+      <td class="full" align="center">Yes</td>
+    </tr>
+    <tr>
+      <td>Explicit lifetime management</td>
+      <td><a href="https://wg21.link/P2590R2";>P2590R2</a></td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <!-- November 2022 (Kona) papers -->
+    <tr>
+      <td>static <code>operator[]</code></td>
+      <td><a href="https://wg21.link/P2589R1";>P2589R1</a></td>
+      <td class="full" align="center">Clang 16</td>
+    </tr>
+    <tr>
+      <td>Permitting static constexpr variables in constexpr functions</td>
+      <td><a href="https://wg21.link/P2647R1";>P2647R1</a></td>
+      <td class="full" align="center">Clang 16</td>
+    </tr>
+    <tr>
+      <td>consteval needs to propagate up</td>
+      <td><a href="https://wg21.link/P2564R3";>P2564R3</a> (<a href="#dr">DR</a>)</td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <tr>
+      <td>Lifetime extension in range-based for loops</td>
+      <td><a href="https://wg21.link/P2718R0";>P2718R0</a></td>
+      <td class="none" align="center">No</td>
+    </tr>
+    <!--Issaquah 2023 papers-->
+    <tr>
+      <td>Referencing The Unicode Standard</td>
+      <td><a href="https://wg21.link/P2736R2";>P2736R2</a></td>
+      <td class="full" align="center">Yes</td>
+    </tr>
 </table>
 
 <p>
Index: clang/test/SemaCXX/type-traits.cpp
===================================================================
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2542,6 +2542,51 @@
   { 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)];
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -30,6 +30,7 @@
 #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"
@@ -5410,14 +5411,15 @@
   if (Kind <= UTT_Last)
     return EvaluateUnaryTypeTrait(S, Kind, KWLoc, Args[0]->getType());
 
-  // Evaluate BTT_ReferenceBindsToTemporary alongside the IsConstructible
-  // traits to avoid duplication.
-  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary)
+  // Evaluate ReferenceBindsToTemporary and ReferenceConstructsFromTemporary
+  // alongside the IsConstructible traits to avoid duplication.
+  if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary && Kind != BTT_ReferenceConstructsFromTemporary)
     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: {
@@ -5494,11 +5496,23 @@
     if (Kind == clang::TT_IsConstructible)
       return true;
 
-    if (Kind == clang::BTT_ReferenceBindsToTemporary) {
+    if (Kind == clang::BTT_ReferenceBindsToTemporary || Kind == clang::BTT_ReferenceConstructsFromTemporary) {
       if (!T->isReferenceType())
         return false;
 
-      return !Init.isDirectReferenceBinding();
+      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);
     }
 
     if (Kind == clang::TT_IsNothrowConstructible)
Index: clang/lib/Parse/ParseExpr.cpp
===================================================================
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -1128,6 +1128,8 @@
           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"
Index: clang/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1655,7 +1655,9 @@
           tok::kw___is_union,
           tok::kw___is_unsigned,
           tok::kw___is_void,
-          tok::kw___is_volatile))
+          tok::kw___is_volatile,
+          tok::kw___reference_binds_to_temporary,
+          tok::kw___reference_constructs_from_temporary))
     // 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
Index: clang/lib/Lex/PPMacroExpansion.cpp
===================================================================
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -1695,6 +1695,7 @@
               .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);
Index: clang/include/clang/Basic/TokenKinds.def
===================================================================
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -531,6 +531,7 @@
 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)
Index: clang/docs/LanguageExtensions.rst
===================================================================
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1621,6 +1621,10 @@
   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:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to