Make std::addressof constexpr in C++17 (Clang only).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263688 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__config b/include/__config
index c360214..f6047ca 100644
--- a/include/__config
+++ b/include/__config
@@ -779,6 +779,12 @@
 #define _LIBCPP_CONSTEXPR_AFTER_CXX11
 #endif
 
+#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
+#define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr
+#else
+#define _LIBCPP_CONSTEXPR_AFTER_CXX14
+#endif
+
 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 #  define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
 #else
diff --git a/include/type_traits b/include/type_traits
index 2922839..6840ee2 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -397,6 +397,18 @@
 #endif
 
 // addressof
+#if __has_builtin(__builtin_addressof)
+
+template <class _Tp>
+inline _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
+_Tp*
+addressof(_Tp& __x) _NOEXCEPT
+{
+    return __builtin_addressof(__x);
+}
+
+#else
 
 template <class _Tp>
 inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY
@@ -406,6 +418,8 @@
     return (_Tp*)&reinterpret_cast<const volatile char&>(__x);
 }
 
+#endif // __has_builtin(__builtin_addressof)
+
 #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF)
 // Objective-C++ Automatic Reference Counting uses qualified pointers
 // that require special addressof() signatures. When
diff --git a/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
new file mode 100644
index 0000000..a371f8e
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: gcc
+
+// <memory>
+
+// template <ObjectType T> constexpr T* addressof(T& r);
+
+#include <memory>
+#include <cassert>
+
+struct Pointer {
+  constexpr Pointer(void* v) : value(v) {}
+  void* value;
+};
+
+struct A
+{
+    constexpr A() : n(42) {}
+    void operator&() const { }
+    int n;
+};
+
+constexpr int i = 0;
+constexpr double d = 0.0;
+constexpr A a{};
+
+int main()
+{
+    static_assert(std::addressof(i) == &i, "");
+    static_assert(std::addressof(d) == &d, "");
+    constexpr const A* ap = std::addressof(a);
+    static_assert(&ap->n == &a.n, "");
+}
diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html
index 0b9023b..65c33c0 100644
--- a/www/cxx1z_status.html
+++ b/www/cxx1z_status.html
@@ -204,7 +204,7 @@
  	<tr><td></td><td></td><td></td><td></td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2192">2192</a></td><td>Validity and return type of <tt>std::abs(0u)</tt> is unclear</td><td>Jacksonville</td><td></td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2276">2276</a></td><td>Missing requirement on <tt>std::promise::set_exception</tt></td><td>Jacksonville</td><td></td></tr>
-	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2296">2296</a></td><td><tt>std::addressof</tt> should be <tt>constexpr</td><td>Jacksonville</td><td></td></tr>
+	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2296">2296</a></td><td><tt>std::addressof</tt> should be <tt>constexpr</td><td>Jacksonville</td><td>Complete (Clang Only)</td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2450">2450</a></td><td><tt>(greater|less|greater_equal|less_equal)&lt;void&gt;</tt> do not yield a total order for pointers</td><td>Jacksonville</td><td></td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2520">2520</a></td><td>N4089 broke initializing <tt>unique_ptr&lt;T[]&gt;</tt> from a <tt>nullptr</tt></td><td>Jacksonville</td><td></td></tr>
 	<tr><td><a href="http://cplusplus.github.io/LWG/lwg-defects.html#2522">2522</a></td><td>[fund.ts.v2] Contradiction in <tt>set_default_resource</tt> specification</td><td>Jacksonville</td><td></td></tr>