[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 16:53:29 PST 2017


rsmith added inline comments.


================
Comment at: lib/Sema/SemaExprCXX.cpp:4567
 
-  if (Kind <= BTT_Last)
+  // Evaluate BTT_ReferenceBindsToTemporary along side the IsConstructible
+  // traits to avoid duplication.
----------------
"alongside" is a single word.


================
Comment at: test/SemaCXX/type-traits.cpp:2102-2116
+  using LRef = ConvertsToRef<int, int&>;
+  using RRef = ConvertsToRef<int, int&&>;
+  using CLRef = ConvertsToRef<int, const int&>;
+  using LongRef = ConvertsToRef<long, long&>;
+  { int arr[T((__is_constructible(int&, LRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, LRef)))]; }
+
----------------
Please also check things like:

  `__reference_binds_to_temporary(const int&, ConvertsToRef<long, long&>)`

(That is, a user-defined conversion to a reference type followed by converting and materializing a temporary.)


https://reviews.llvm.org/D29930





More information about the cfe-commits mailing list