<div dir="ltr">FYI dblaikie, we'll see if this one works :-)</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 27, 2016 at 1:32 PM, JF Bastien via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jfb<br>
Date: Sun Mar 27 15:32:21 2016<br>
New Revision: 264541<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264541&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=264541&view=rev</a><br>
Log:<br>
isPodLike: more precise<br>
<br>
I tried to use isPodLike in:<br>
  <a href="http://reviews.llvm.org/D18483" rel="noreferrer" target="_blank">http://reviews.llvm.org/D18483</a><br>
<br>
That failed because !is_class is too strict on platforms which don't yet<br>
have is_trivially_copyable. This update tries to make isPodLike smarter<br>
for platforms which don't have is_trivially_copyable, and AFAICT it<br>
Should Just Work on all of them. I'll revert if the bots disagree with<br>
me.<br>
<br>
I'll also rename isPodLike to isTriviallyCopyable if this all works out,<br>
since that's what the standard calls it now and one day we'll be rid of<br>
isPodLike.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/Support/type_traits.h<br>
<br>
Modified: llvm/trunk/include/llvm/Support/type_traits.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=264541&r1=264540&r2=264541&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=264541&r1=264540&r2=264541&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/type_traits.h (original)<br>
+++ llvm/trunk/include/llvm/Support/type_traits.h Sun Mar 27 15:32:21 2016<br>
@@ -24,12 +24,11 @@<br>
<br>
 namespace llvm {<br>
<br>
-/// isPodLike - This is a type trait that is used to determine whether a given<br>
-/// type can be copied around with memcpy instead of running ctors etc.<br>
-template <typename T><br>
-struct isPodLike {<br>
-  // std::is_trivially_copyable is available in libc++ with clang, libstdc++<br>
-  // that comes with GCC 5.<br>
+/// Type trait used to determine whether a given type can be copied around with<br>
+/// memcpy instead of running ctors.<br>
+template <typename T> struct isPodLike {<br>
+// std::is_trivially_copyable is available in libc++ with clang, libstdc++<br>
+// that comes with GCC 5.<br>
 #if (__has_feature(is_trivially_copyable) && defined(_LIBCPP_VERSION)) ||      \<br>
     (defined(__GNUC__) && __GNUC__ >= 5)<br>
   // If the compiler supports the is_trivially_copyable trait use it, as it<br>
@@ -40,10 +39,15 @@ struct isPodLike {<br>
   // don't know if the standard library does. This is the case for clang in<br>
   // conjunction with libstdc++ from GCC 4.x.<br>
   static const bool value = __is_trivially_copyable(T);<br>
+#elif defined(__GNUC__)<br>
+  // Fallback to ye olden compiler intrinsic, which isn't as accurate as the new<br>
+  // one but more widely supported.<br>
+  static const bool value = __has_trivial_copy(T);<br>
 #else<br>
-  // If we don't know anything else, we can (at least) assume that all non-class<br>
-  // types are PODs.<br>
-  static const bool value = !std::is_class<T>::value;<br>
+  // If we really don't know anything else is_pod will do, is widely supported,<br>
+  // but is too strict (e.g. a user-defined ctor doesn't prevent trivial copy<br>
+  // but prevents POD-ness).<br>
+  static const bool value = std::is_pod<T>::value;<br>
 #endif<br>
 };<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>