[PATCH] D50341: [libcxx] Fix XFAILs for aligned allocation tests on older OSX versions

2018-08-13 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: libcxx/test/libcxx/memory/aligned_allocation_macro.pass.cpp:18
+// XFAIL: macosx10.8
+// XFAIL: macosx10.7
 

These should probably be `UNSUPPORTED` as well.



Comment at: 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp:15
 // Older Clang versions do not support this
 // XFAIL: clang-3, apple-clang-7, apple-clang-8
 

These should probably be `UNSUPPORTED` as well (though this is less important)




Comment at: 
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_size_align.fail.cpp:15
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8

ldionne wrote:
> vsapsai wrote:
> > In what cases are we supposed to run these tests? Such extensive collection 
> > of unsupported C++ standards looks suspicious and I guess that is the 
> > reason why I haven't seen test failures with older libc++ dylibs.
> That's an excellent question. I would assume those should be enabled in C++17 
> and above, I'm not sure why they're disabled. @mclow.lists was the one to 
> introduce those tests, perhaps he can shed light on why they were disabled in 
> C++17?
IIRC, this call - `operator new(std::size_t, std::align_val_t);` was introduced 
for C++17, and `[[nodiscard]]` was added for C++20.

this test is making sure that we get a warning when you call this and don't use 
the return value. It requires C++20 and above, hence the massive UNSUPPORTED 
list


Repository:
  rCXX libc++

https://reviews.llvm.org/D50341



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I have pissed in this area, too - See 
https://bugs.llvm.org/show_bug.cgi?id=38495 and the proposed resolution here: 
https://bugs.llvm.org/attachment.cgi?id=20692
How about I just make this change as part of that fix?


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D50719#1199450, @dexonsmith wrote:

> If the bots are red from a previous commit I think it would be better for 
> Louis to commit this separately.


I'm ok with that.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

thinking about this more, I think this the wrong long-term direction.

The presence/absence of C11 features in the underlying C library does not 
depend on what version of the C++ language we're compiling with.
The tests that use `TEXT_HAS_C11_XXX` should be updated to check `TEST_STD_VER` 
instead.

However, I'm fine with this as a short-term fix.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50719: [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I will clean this up as part of https://bugs.llvm.org/show_bug.cgi?id=38495


Repository:
  rCXX libc++

https://reviews.llvm.org/D50719



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


[PATCH] D50739: Clean up macros to detect underling C library functionality

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: ldionne, EricWF, dexonsmith.

During the review of https://reviews.llvm.org/D50719, I said:

> The presence/absence of C11 features in the underlying C library does not 
> depend on what version of the C++ language we're compiling with.
>  The tests that use `TEXT_HAS_C11_XXX` should be updated to check 
> `TEST_STD_VER` instead.

This does that.
The detection of C11 features happens no matter what the language level is.
The enabling/disabling of the C++ features is done based on the language level.


https://reviews.llvm.org/D50739

Files:
  include/__config
  include/cstdlib
  test/std/language.support/support.start.term/quick_exit.pass.cpp
  test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
  test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
  test/support/test_macros.h


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,7 +124,7 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
Index: test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
===
--- test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
+++ test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined
 // results in a compile error.
Index: test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
===
--- test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
+++ test/std/language.support/support.start.term/quick_exit_check1.fail.cpp
@@ -7,6 +7,7 @@
 //
 
//===--===//
 //
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing at_quick_exit when _LIBCPP_HAS_QUICK_EXIT is not 
defined
 // results in a compile error.
Index: test/std/language.support/support.start.term/quick_exit.pass.cpp
===
--- test/std/language.support/support.start.term/quick_exit.pass.cpp
+++ test/std/language.support/support.start.term/quick_exit.pass.cpp
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test quick_exit and at_quick_exit
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -430,7 +430,7 @@
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 #endif
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)
 #define _LIBCPP_HAS_QUICK_EXIT
 #define _LIBCPP_HAS_C11_FEATURES


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,7 +124,7 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
-#if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
Index: test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
===
--- test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
+++ test/std/language.support/support.start.term/quick_exit_check2.fail.cpp
@@ -6,7 +6,7 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 //===--===//
-//
+// UNSUPPORTED: c++98, c++03
 
 // test that referencing quick_exit when _LIBCPP_HAS_QUICK_EXIT is not defined
 // results in 

[PATCH] D50739: Clean up macros to detect underling C library functionality

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/__config:433
 
-#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+#if __ISO_C_VISIBLE >= 2011
 #  if defined(__FreeBSD__)

Should we be using `__ISO_C_VISIBLE` here, or `__STDC_VERSION__`?
I didn't change this, but ...


https://reviews.llvm.org/D50739



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


[PATCH] D50748: [libc++] Detect C11 features on non-Clang compilers

2018-08-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50748



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


[PATCH] D50736: [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Is this test that's being added libc++ specific, or would it apply to other 
implementations as well?




Comment at: 
test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp:18
+
+// template  explicit mersenne_twister_engine(Sseq &q);
+

Please add a comment here about what's being tested, because when I look at 
this a year from now, I won't know what's going on.

Something like:
`//  Finally, if the most significant w − r bits of X−n are zero, and if each 
of the other resulting Xi is 0, changes X−n to 2w−1.`




Comment at: 
test/libcxx/numerics/rand/rand.eng.mers/cnstr_sseq_all_zero.pass.cpp:47
+
+template  void test(void) {
+  const std::size_t state_size = 1u;

Need a line break before `void`


Repository:
  rCXX libc++

https://reviews.llvm.org/D50736



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


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: ldionne, EricWF, dim.

Fixes this by adding a new config macro  `_LIBCPP_HAS_TIMESPEC_GET` (sigh)

There's also a drive-by fix in here about not importing `aligned_alloc` into 
namespace `std` before C++17.


https://reviews.llvm.org/D50799

Files:
  include/__config
  include/cstdlib
  include/ctime
  test/std/language.support/support.runtime/ctime.pass.cpp
  test/std/utilities/time/date.time/ctime.pass.cpp
  test/support/test_macros.h

Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,22 +124,29 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
+// This is cribbed from __config; but lives here as well because we can't assume libc++
 #if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
+//  Specifically, FreeBSD does NOT have timespec_get, even though they have all
+//  the rest of C11 - this is PR#38495
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define TEST_HAS_C11_FEATURES
+#define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  elif defined(_WIN32)
 #if defined(_MSC_VER) && !defined(__MINGW32__)
 #  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  endif
 #endif
Index: test/std/utilities/time/date.time/ctime.pass.cpp
===
--- test/std/utilities/time/date.time/ctime.pass.cpp
+++ test/std/utilities/time/date.time/ctime.pass.cpp
@@ -47,7 +47,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: test/std/language.support/support.runtime/ctime.pass.cpp
===
--- test/std/language.support/support.runtime/ctime.pass.cpp
+++ test/std/language.support/support.runtime/ctime.pass.cpp
@@ -45,7 +45,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: include/ctime
===
--- include/ctime
+++ include/ctime
@@ -73,7 +73,7 @@
 using ::localtime;
 #endif
 using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
 using ::timespec_get;
 #endif
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -331,6 +331,7 @@
 #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
 #  if defined(__FreeBSD__)
 #define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_TIMESPEC_GET
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define _LIBCPP_HAS_QUICK_EXIT
@@ -342,9 +343,11 @@
 #  endif
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_TIMESPEC_GET
 #  define _LIBCPP_HAS_C11_FEATURES
 #endif
 #  endif // __linux__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 160897.
mclow.lists added a comment.

Copy/paste error in original diff.


https://reviews.llvm.org/D50799

Files:
  include/__config
  include/cstdlib
  include/ctime
  test/std/language.support/support.runtime/ctime.pass.cpp
  test/std/utilities/time/date.time/ctime.pass.cpp
  test/support/test_macros.h

Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,22 +124,29 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
+// This is cribbed from __config; but lives here as well because we can't assume libc++
 #if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
+//  Specifically, FreeBSD does NOT have timespec_get, even though they have all
+//  the rest of C11 - this is PR#38495
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define TEST_HAS_C11_FEATURES
+#define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  elif defined(_WIN32)
 #if defined(_MSC_VER) && !defined(__MINGW32__)
 #  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  endif
 #endif
Index: test/std/utilities/time/date.time/ctime.pass.cpp
===
--- test/std/utilities/time/date.time/ctime.pass.cpp
+++ test/std/utilities/time/date.time/ctime.pass.cpp
@@ -47,7 +47,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: test/std/language.support/support.runtime/ctime.pass.cpp
===
--- test/std/language.support/support.runtime/ctime.pass.cpp
+++ test/std/language.support/support.runtime/ctime.pass.cpp
@@ -45,7 +45,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: include/ctime
===
--- include/ctime
+++ include/ctime
@@ -73,7 +73,7 @@
 using ::localtime;
 #endif
 using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
 using ::timespec_get;
 #endif
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -342,9 +342,11 @@
 #  endif
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_TIMESPEC_GET
 #  define _LIBCPP_HAS_C11_FEATURES
 #endif
 #  endif // __linux__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50799: Fix for PR 38495: no longer compiles on FreeBSD, due to lack of timespec_get()

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 160898.

https://reviews.llvm.org/D50799

Files:
  include/__config
  include/cstdlib
  include/ctime
  test/std/language.support/support.runtime/ctime.pass.cpp
  test/std/utilities/time/date.time/ctime.pass.cpp
  test/support/test_macros.h

Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -124,22 +124,29 @@
 
 // Sniff out to see if the underling C library has C11 features
 // Note that at this time (July 2018), MacOS X and iOS do NOT.
+// This is cribbed from __config; but lives here as well because we can't assume libc++
 #if __ISO_C_VISIBLE >= 2011 || TEST_STD_VER >= 11
 #  if defined(__FreeBSD__)
+//  Specifically, FreeBSD does NOT have timespec_get, even though they have all
+//  the rest of C11 - this is PR#38495
 #define TEST_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define TEST_HAS_C11_FEATURES
+#define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
+#define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  elif defined(_WIN32)
 #if defined(_MSC_VER) && !defined(__MINGW32__)
 #  define TEST_HAS_C11_FEATURES // Using Microsoft's C Runtime library
+#  define TEST_HAS_TIMESPEC_GET
 #endif
 #  endif
 #endif
Index: test/std/utilities/time/date.time/ctime.pass.cpp
===
--- test/std/utilities/time/date.time/ctime.pass.cpp
+++ test/std/utilities/time/date.time/ctime.pass.cpp
@@ -47,7 +47,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: test/std/language.support/support.runtime/ctime.pass.cpp
===
--- test/std/language.support/support.runtime/ctime.pass.cpp
+++ test/std/language.support/support.runtime/ctime.pass.cpp
@@ -45,7 +45,7 @@
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
-#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#if TEST_STD_VER > 14 && defined(TEST_HAS_TIMESPEC_GET)
 static_assert((std::is_same::value), "");
 #endif
 #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Index: include/ctime
===
--- include/ctime
+++ include/ctime
@@ -73,7 +73,7 @@
 using ::localtime;
 #endif
 using ::strftime;
-#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
 using ::timespec_get;
 #endif
 
Index: include/cstdlib
===
--- include/cstdlib
+++ include/cstdlib
@@ -151,11 +151,11 @@
 using ::wctomb;
 using ::mbstowcs;
 using ::wcstombs;
-#ifdef _LIBCPP_HAS_QUICK_EXIT
+#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT)
 using ::at_quick_exit;
 using ::quick_exit;
 #endif
-#ifdef _LIBCPP_HAS_C11_FEATURES
+#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_C11_FEATURES)
 using ::aligned_alloc;
 #endif
 
Index: include/__config
===
--- include/__config
+++ include/__config
@@ -334,6 +334,7 @@
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__Fuchsia__)
 #define _LIBCPP_HAS_QUICK_EXIT
+#define _LIBCPP_HAS_TIMESPEC_GET
 #define _LIBCPP_HAS_C11_FEATURES
 #  elif defined(__linux__)
 #if !defined(_LIBCPP_HAS_MUSL_LIBC)
@@ -342,9 +343,11 @@
 #  endif
 #  if _LIBCPP_GLIBC_PREREQ(2, 17)
 #define _LIBCPP_HAS_C11_FEATURES
+#define _LIBCPP_HAS_TIMESPEC_GET
 #  endif
 #else // defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define _LIBCPP_HAS_QUICK_EXIT
+#  define _LIBCPP_HAS_TIMESPEC_GET
 #  define _LIBCPP_HAS_C11_FEATURES
 #endif
 #  endif // __linux__
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50815: Establish the header

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: EricWF, ldionne.
Herald added a subscriber: christof.

In C++20, we're going to have a header named  for bit manipulations.
See https://wg21.link/P0553 and https://wg21.link/P0556 for more info.

This doesn't do any of that.
It just creates the header, and pulls some existing internal routines into it.
Later diffs will rename the existing routines, and implement the features from 
P0553 and P0556.

This is just moving stuff around.  NFC intended.


https://reviews.llvm.org/D50815

Files:
  include/algorithm
  include/bit
  include/module.modulemap
  test/libcxx/double_include.sh.cpp

Index: test/libcxx/double_include.sh.cpp
===
--- test/libcxx/double_include.sh.cpp
+++ test/libcxx/double_include.sh.cpp
@@ -27,6 +27,7 @@
 #ifndef _LIBCPP_HAS_NO_THREADS
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
Index: include/module.modulemap
===
--- include/module.modulemap
+++ include/module.modulemap
@@ -228,6 +228,10 @@
 header "atomic"
 export *
   }
+  module bit {
+header "bit"
+export *
+  }
   module bitset {
 header "bitset"
 export string
Index: include/bit
===
--- include/bit
+++ include/bit
@@ -0,0 +1,169 @@
+// -*- C++ -*-
+//===-- bit --===//
+//
+// 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.
+//
+//===-===//
+
+#ifndef _LIBCPP_BIT
+#define _LIBCPP_BIT
+
+/*
+bit synopsis
+
+namespace std {
+
+} // namespace std
+
+*/
+
+#include <__config>
+
+#if defined(__IBMCPP__)
+#include "support/ibm/support.h"
+#endif
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include 
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Precondition:  __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned __ctz(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_ctz(__x));
+#else
+  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+  static_assert(sizeof(unsigned long) == 4, "");
+  unsigned long where;
+  // Search from LSB to MSB for first set bit.
+  // Returns zero if no set bit is found.
+  if (_BitScanForward(&where, __x))
+return where;
+  return 32;
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long __ctz(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_ctzl(__x));
+#else
+static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
+return __ctz(static_cast(__x));
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long __ctz(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_ctzll(__x));
+#else
+unsigned long where;
+// Search from LSB to MSB for first set bit.
+// Returns zero if no set bit is found.
+#if defined(_LIBCPP_HAS_BITSCAN64)
+(defined(_M_AMD64) || defined(__x86_64__))
+  if (_BitScanForward64(&where, __x))
+return static_cast(where);
+#else
+  // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
+  // Scan the Low Word.
+  if (_BitScanForward(&where, static_cast(__x)))
+return where;
+  // Scan the High Word.
+  if (_BitScanForward(&where, static_cast(__x >> 32)))
+return where + 32; // Create a bit offset from the LSB.
+#endif
+  return 64;
+#endif // _LIBCPP_COMPILER_MSVC
+}
+
+// Precondition:  __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned __clz(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_clz(__x));
+#else
+  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+  static_assert(sizeof(unsigned long) == 4, "");
+  unsigned long where;
+  // Search from LSB to MSB for first set bit.
+  // Returns zero if no set bit is found.
+  if (_BitScanReverse(&where, __x))
+return 31 - where;
+  return 32; // Undefined Behavior.
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long __clz(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_clzl (__x));
+#else
+static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+return __clz(static_cast(__x));
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long __clz(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_clzll(__x));
+#else
+  unsigned long where;
+// BitScanReverse scans from MSB to LSB for first set bit.
+// Returns 0 if no set bit is found.
+#if defined(_LIBCPP_HAS_BITSCAN64)
+  if (_BitScanReverse64(&where, __x))
+return static_cast(63 - where);
+#else
+  // Scan the high

[PATCH] D50736: [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback

2018-08-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Thanks for doing this.
This looks good to me; but I want to play with it a bit before committing. I'll 
do that tonight.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50736



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


[PATCH] D50736: [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback

2018-08-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This LGTM. Do you want me to commit it for you?


Repository:
  rCXX libc++

https://reviews.llvm.org/D50736



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


[PATCH] D50815: Establish the header

2018-08-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

landed as revision 339943


https://reviews.llvm.org/D50815



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


[PATCH] D50876: Clean up newly created header

2018-08-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: ldionne, EricWF.

Still NFC here.

1. Take the 9 functions that each had an `#ifndef _LIBCPP_COMPILER_MSVC` .. 
`#else` .. `endif` block in them and make just two blocks, each with 9 
functions. Much easier to read, but makes for a terrible diff.

2. Change the return type of `__ctz` and `__clz` from the same type as the 
parameter to `int`.  I would have preferred `unsigned`, but that's not what 
P0553 gave us. I reviewed all the call sites for these functions, and for 
`__ctz` it was always immediately static_cast-ed to another type, and `__clz` 
it made no difference either.

3. Change the name `__pop_count` to `__popcount` to match the name that we're 
going to add from P0553.

4. Rename the local variable in the windows code from `where` to `__where`. 
Shame on someone ;-)


https://reviews.llvm.org/D50876

Files:
  include/__bit_reference
  include/bit

Index: include/bit
===
--- include/bit
+++ include/bit
@@ -35,135 +35,134 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifndef _LIBCPP_COMPILER_MSVC
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __ctz(unsigned __x)   { return __builtin_ctz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __ctz(unsigned long __x)  { return __builtin_ctzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __ctz(unsigned long long __x) { return __builtin_ctzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __clz(unsigned __x)   { return __builtin_clz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __clz(unsigned long __x)  { return __builtin_clzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __clz(unsigned long long __x) { return __builtin_clzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __popcount(unsigned __x)   { return __builtin_popcount  (__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __popcount(unsigned long __x)  { return __builtin_popcountl (__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __popcount(unsigned long long __x) { return __builtin_popcountll(__x); }
+
+#else  // _LIBCPP_COMPILER_MSVC
+
 // Precondition:  __x != 0
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned __ctz(unsigned __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_ctz(__x));
-#else
+int __ctz(unsigned __x) {
   static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
   static_assert(sizeof(unsigned long) == 4, "");
-  unsigned long where;
+  unsigned long __where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanForward(&where, __x))
-return where;
+  if (_BitScanForward(&__where, __x))
+return static_cast(__where);
   return 32;
-#endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned long __ctz(unsigned long __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_ctzl(__x));
-#else
+int __ctz(unsigned long __x) {
 static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
 return __ctz(static_cast(__x));
-#endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned long long __ctz(unsigned long long __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_ctzll(__x));
-#else
-unsigned long where;
+int __ctz(unsigned long long __x) {
+unsigned long __where;
 // Search from LSB to MSB for first set bit.
 // Returns zero if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
 (defined(_M_AMD64) || defined(__x86_64__))
-  if (_BitScanForward64(&where, __x))
-return static_cast(where);
+  if (_BitScanForward64(&__where, __x))
+return static_cast(__where);
 #else
   // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
   // Scan the Low Word.
-  if (_BitScanForward(&where, static_cast(__x)))
-return where;
+  if (_BitScanForward(&__where, static_cast(__x)))
+return __where;
   // Scan the High Word.
-  if (_BitScanForward(&where, static_cast(__x >> 32)))
-return where + 32; // Create a bit offset from the LSB.
+  if (_BitScanForward(&__where, static_cast(__x >> 32)))
+return __where + 32; // Create a bit offset from the LSB.
 #endif
   return 64;
-#endif // _LIBCPP_COMPILER_MSVC
 }
 
 // Precondition:  __x != 0
 inline _LIBCPP_INLINE_VISIBILITY
 unsigned __clz(unsigned __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_clz(__x));
-#else
   static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
   static_assert(sizeof(unsigned long) == 4, "");
-  unsigned long where;
+  unsigned long __where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanReverse(&where, __x))
-return 31 - where;
+  if (_BitScanReverse(&__where, __x))
+return 31 - __where;
   return 32; // Undefined Behavior.
-#endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned long __clz(unsigned long __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_clzl (__x));
-#else
+int 

[PATCH] D50876: Clean up newly created header

2018-08-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/bit:113
 inline _LIBCPP_INLINE_VISIBILITY
 unsigned __clz(unsigned __x) {
   static_assert(sizeof(unsigned) == sizeof(unsigned long), "");

Missed this one. Should be `int`


https://reviews.llvm.org/D50876



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


[PATCH] D50876: Clean up newly created header

2018-08-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/bit:117
+  unsigned long __where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.

lebedev.ri wrote:
> Like i commented in the original review, this should probably be 
> ```
> // Search from *M*SB to *L*SB for first set bit.
> ```
I think my preference would be to just remove the comment.


https://reviews.llvm.org/D50876



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


[PATCH] D50876: Clean up newly created header

2018-08-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/bit:61
+inline _LIBCPP_INLINE_VISIBILITY
+int __popcount(unsigned __x)   { return __builtin_popcount  (__x); }
+

ldionne wrote:
> Funny spacing between `__builtin_popcount` and `(__x)`
It's actually there to line up with the ones below.
(Though now that I look, I didn't do that for the ones above)


https://reviews.llvm.org/D50876



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


[PATCH] D50876: Clean up newly created header

2018-08-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 161284.
mclow.lists added a comment.

Clean up the windows code a bit - though I don't think is used - since I don't 
think it will compile.


https://reviews.llvm.org/D50876

Files:
  include/__bit_reference
  include/bit

Index: include/bit
===
--- include/bit
+++ include/bit
@@ -35,135 +35,123 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+#ifndef _LIBCPP_COMPILER_MSVC
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __ctz(unsigned __x)   { return __builtin_ctz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __ctz(unsigned long __x)  { return __builtin_ctzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __ctz(unsigned long long __x) { return __builtin_ctzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __clz(unsigned __x)   { return __builtin_clz(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __clz(unsigned long __x)  { return __builtin_clzl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __clz(unsigned long long __x) { return __builtin_clzll(__x); }
+
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __popcount(unsigned __x)   { return __builtin_popcount(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __popcount(unsigned long __x)  { return __builtin_popcountl(__x); }
+
+inline _LIBCPP_INLINE_VISIBILITY
+int __popcount(unsigned long long __x) { return __builtin_popcountll(__x); }
+
+#else  // _LIBCPP_COMPILER_MSVC
+
 // Precondition:  __x != 0
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned __ctz(unsigned __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_ctz(__x));
-#else
+int __ctz(unsigned __x) {
   static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
   static_assert(sizeof(unsigned long) == 4, "");
-  unsigned long where;
-  // Search from LSB to MSB for first set bit.
-  // Returns zero if no set bit is found.
-  if (_BitScanForward(&where, __x))
-return where;
+  unsigned long __where;
+  if (_BitScanForward(&__where, __x))
+return static_cast(__where);
   return 32;
-#endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned long __ctz(unsigned long __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_ctzl(__x));
-#else
+int __ctz(unsigned long __x) {
 static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
 return __ctz(static_cast(__x));
-#endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned long long __ctz(unsigned long long __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_ctzll(__x));
-#else
-unsigned long where;
-// Search from LSB to MSB for first set bit.
-// Returns zero if no set bit is found.
+int __ctz(unsigned long long __x) {
+unsigned long __where;
 #if defined(_LIBCPP_HAS_BITSCAN64)
 (defined(_M_AMD64) || defined(__x86_64__))
-  if (_BitScanForward64(&where, __x))
-return static_cast(where);
+  if (_BitScanForward64(&__where, __x))
+return static_cast(__where);
 #else
   // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
-  // Scan the Low Word.
-  if (_BitScanForward(&where, static_cast(__x)))
-return where;
-  // Scan the High Word.
-  if (_BitScanForward(&where, static_cast(__x >> 32)))
-return where + 32; // Create a bit offset from the LSB.
+  if (_BitScanForward(&__where, static_cast(__x)))
+return static_cast(__where);
+  if (_BitScanForward(&__where, static_cast(__x >> 32)))
+return static_cast(__where + 32);
 #endif
   return 64;
-#endif // _LIBCPP_COMPILER_MSVC
 }
 
 // Precondition:  __x != 0
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned __clz(unsigned __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_clz(__x));
-#else
+int __clz(unsigned __x) {
   static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
   static_assert(sizeof(unsigned long) == 4, "");
-  unsigned long where;
-  // Search from LSB to MSB for first set bit.
-  // Returns zero if no set bit is found.
-  if (_BitScanReverse(&where, __x))
-return 31 - where;
+  unsigned long __where;
+  if (_BitScanReverse(&__where, __x))
+return static_cast(31 - __where);
   return 32; // Undefined Behavior.
-#endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned long __clz(unsigned long __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_clzl (__x));
-#else
+int __clz(unsigned long __x) {
 static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
 return __clz(static_cast(__x));
-#endif
 }
 
 inline _LIBCPP_INLINE_VISIBILITY
-unsigned long long __clz(unsigned long long __x) {
-#ifndef _LIBCPP_COMPILER_MSVC
-return static_cast(__builtin_clzll(__x));
-#else
-  unsigned long where;
-// BitScanReverse scans from MSB to LSB for first set bit.
-// Returns 0 if no set bit is found.
+int __clz(unsigned long long __x) {
+  unsigned long __where;
 #if defined(_LIBCPP_HAS_BITSCAN64)
-  if (_BitScanReverse64(&where, __x))
-return static_cast(63 - where);
+  if (_BitScanReverse64(&__wher

[PATCH] D50876: Clean up newly created header

2018-08-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/bit:96
 #if defined(_LIBCPP_HAS_BITSCAN64)
 (defined(_M_AMD64) || defined(__x86_64__))
+  if (_BitScanForward64(&__where, __x))

I'm not sure this code is ever used - since how can this compile?


https://reviews.llvm.org/D50876



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


[PATCH] D50876: Clean up newly created header

2018-08-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

@craig.topper - that's existing code; I'm not changing it.
If we have a test bot that I can test this against, I'm happy to update it.


https://reviews.llvm.org/D50876



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


[PATCH] D50876: Clean up newly created header

2018-08-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D50876#1204531, @mclow.lists wrote:

> @craig.topper - that's existing code; I'm not changing it.
>  If we have a test bot that I can test this against, I'm happy to update it.


I'm not really sure that this code is actually used anywhere.


https://reviews.llvm.org/D50876



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


[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-05-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

>> One way we could deal with this is by adding an attribute to the compiler to 
>> indicate "the const is a lie", that we can apply to std::pair::first, with 
>> the semantics being that a top-level const is ignored when determining the 
>> "real" type of the member (and so mutating the member after a const_cast has 
>> defined behavior). This would apply to all std::pairs, not just the 
>> node_handle case, but in practice we don't optimize on the basis of a member 
>> being declared const *anyway*, so this isn't such a big deal right now.
> 
> I'm a fan of this idea, this would also have the bonus of fixing some 
> pre-existing type-punning between pair and pair (see 
> __hash_value_type and __value_type in  and ).

This was //supposed// to be taken care of by [class.mem]/21 (common initial 
sequence), but that foundered on "standard-layout".


https://reviews.llvm.org/D46845



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


[PATCH] D41347: [libc++] Lift std::errc into a separated header

2018-05-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Sorry this took so long. Please update `test/libcxx/double_include.sh.cpp` and 
commit.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41347



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


[PATCH] D39308: [libcxx] Keep track of heap allocated regex states

2018-05-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.
Herald added subscribers: bixia, christof.

What we need to do here is to here is to add a new macro 
`_LIBCPP_ABI_REGEX_MEMORY` in `<__config>` (around line 89) and then make these 
changes available only when this macro is defined.

By default - we get no change.
If `_LIBCPP_ABI_REGEX_MEMORY` is defined, we get the new behavior.

Then we can start adding other ABI changes as well.


https://reviews.llvm.org/D39308



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-05-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/charconv:89
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum class _LIBCPP_ENUM_VIS chars_format

lichray wrote:
> EricWF wrote:
> > We need to hide these names when `_LIBCPP_STD_VER < 17`, since we're not 
> > allowed to introduce new names into namespace `std` in older dialects.
> But this header is backported to C++11, so I intended to not to guard it.
> But this header is backported to C++11, so I intended to not to guard it.

In general, we don't provide new features for old language versions.

The only time we've ever done that is for `string_view`, and I'm **still** not 
sure I did the right thing there.



Comment at: src/charconv.cpp:34
+
+#define APPEND1(i)  \
+do  \

I'd really like to see some numbers here showing how this (somewhat awkward) 
code performs better than the straightforward versions.

Because maintenance is forever.

Note: I'm sure that this was true on older compilers - but is it true today?



Comment at: test/support/charconv_test_helpers.h:24
+
+template 
+constexpr auto

If this is supposed to be a C++17 or later header (and I'm pretty sure it is), 
you should add a `static_assert(TEST_STD_VER > 14, "");` to this header.



Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



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


[PATCH] D46964: Implement class deduction guides for `std::array`

2018-05-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.

According to 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0433r2.html

Once this is reviewed, I'll do the rest of the sequence containers.


https://reviews.llvm.org/D46964

Files:
  include/array
  test/std/containers/sequences/array/array.cons/deduct.fail.cpp
  test/std/containers/sequences/array/array.cons/deduct.pass.cpp

Index: test/std/containers/sequences/array/array.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/array/array.cons/deduct.pass.cpp
+++ test/std/containers/sequences/array/array.cons/deduct.pass.cpp
@@ -0,0 +1,45 @@
+//===--===//
+//
+// 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: libcpp-no-deduction-guides
+
+
+// template 
+//   array(T, U...) -> array;
+//
+//  Requires: (is_same_v && ...) is true. Otherwise the program is ill-formed.
+
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main()
+{
+{
+std::array arr{1,2,3};
+static_assert(std::is_same_v>, "");
+assert(arr[0] == 1);
+assert(arr[1] == 2);
+assert(arr[2] == 3);
+}
+
+{
+std::array arr{1L, 4L, 9L, 16L};
+static_assert(std::is_same_v, "");
+static_assert(arr.size() == 4, "");
+assert(arr[0] == 1);
+assert(arr[1] == 4);
+assert(arr[2] == 9);
+}
+}
Index: test/std/containers/sequences/array/array.cons/deduct.fail.cpp
===
--- test/std/containers/sequences/array/array.cons/deduct.fail.cpp
+++ test/std/containers/sequences/array/array.cons/deduct.fail.cpp
@@ -0,0 +1,32 @@
+//===--===//
+//
+// 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: libcpp-no-deduction-guides
+
+
+// template 
+//   array(T, U...) -> array;
+//
+//  Requires: (is_same_v && ...) is true. Otherwise the program is ill-formed.
+
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+int main()
+{
+{
+std::array arr{1,2,3L}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'array'}}
+}
+}
Index: include/array
===
--- include/array
+++ include/array
@@ -72,6 +72,9 @@
 const T* data() const noexcept;
 };
 
+  template 
+array(T, U...) -> array;
+
 template 
   bool operator==(const array& x, const array& y);
 template 
@@ -354,6 +357,14 @@
 };
 
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template && ...), void>::type
+ >
+array(_Tp, _Args...)
+  -> array<_Tp, 1 + sizeof...(_Args)>;
+#endif
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46975: Implement deduction guides for `std::deque`

2018-05-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.

Based off of 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0433r2.html


https://reviews.llvm.org/D46975

Files:
  include/deque
  test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp


Index: test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
+++ test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
@@ -0,0 +1,51 @@
+//===--===//
+//
+// 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: libcpp-no-deduction-guides
+
+
+// template ::value_type>>
+//deque(InputIterator, InputIterator, Allocator = Allocator())
+//-> deque::value_type, Allocator>;
+//
+
+
+#include 
+#include 
+#include 
+#include 
+#include  // INT_MAX
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+
+int main()
+{
+   
+{
+   const int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+std::deque deq(std::begin(arr), std::end(arr));
+
+static_assert(std::is_same_v>, "");
+assert(std::equal(deq.begin(), deq.end(), std::begin(arr), std::end(arr)));
+}
+
+{
+   const long arr[] = {INT_MAX, 1L + INT_MAX, 2L, 3L };
+std::deque deq(std::begin(arr), std::end(arr), std::allocator());
+static_assert(std::is_same_v, "");
+assert(deq.size() == 4);
+assert(deq[0] == INT_MAX);
+assert(deq[1] == 1L + INT_MAX);
+assert(deq[2] == 2L);
+}
+}
Index: include/deque
===
--- include/deque
+++ include/deque
@@ -128,6 +128,10 @@
 void clear() noexcept;
 };
 
+template ::value_type>>
+   deque(InputIterator, InputIterator, Allocator = Allocator())
+   -> deque::value_type, Allocator>;
+
 template 
 bool operator==(const deque& x, const deque& y);
 template 
@@ -1461,6 +1465,23 @@
 void __move_assign(deque& __c, false_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type>,
+ class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ >
+deque(_InputIterator, _InputIterator)
+  -> deque::value_type, _Alloc>;
+
+template::value, void>::type
+ >
+deque(_InputIterator, _InputIterator, _Alloc)
+  -> deque::value_type, _Alloc>;
+#endif
+
+
 template 
 deque<_Tp, _Allocator>::deque(size_type __n)
 {


Index: test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
+++ test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
@@ -0,0 +1,51 @@
+//===--===//
+//
+// 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: libcpp-no-deduction-guides
+
+
+// template ::value_type>>
+//deque(InputIterator, InputIterator, Allocator = Allocator())
+//-> deque::value_type, Allocator>;
+//
+
+
+#include 
+#include 
+#include 
+#include 
+#include  // INT_MAX
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+
+int main()
+{
+	
+{
+	const int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+std::deque deq(std::begin(arr), std::end(arr));
+
+static_assert(std::is_same_v>, "");
+assert(std::equal(deq.begin(), deq.end(), std::begin(arr), std::end(arr)));
+}
+
+{
+	const long arr[] = {INT_MAX, 1L + INT_MAX, 2L, 3L };
+std::deque deq(std::begin(arr), std::end(arr), std::allocator());
+static_assert(std::is_same_v, "");
+assert(deq.size() == 4);
+assert(deq[0] == INT_MAX);
+assert(deq[1] == 1L + INT_MAX);
+assert(deq[2] == 2L);
+}
+}
Index: include/deque
===
--- include/deque
+++ include/deque
@@ -128,6 +128,10 @@
 void clear() noexcept;
 };
 
+template ::value_type>>
+   deque(InputIterator, InputIterator, Allocator = Allocator())
+   -> deque::value_type, Allocator>;
+
 template 
 bool operator==(const deque& x, const deque& y);
 template 
@@ -1461,6 +1465,23 @@
 void __move_assign(deque& __c, false_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type>,
+ class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+  

[PATCH] D46975: Implement deduction guides for `std::deque`

2018-05-16 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I should probably add some tests for the implicit deduction guides, too.


https://reviews.llvm.org/D46975



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


[PATCH] D46975: Implement deduction guides for `std::deque`

2018-05-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 147317.
mclow.lists added a comment.

Added tests (and fix!) for the implicit deduction guides.


https://reviews.llvm.org/D46975

Files:
  include/deque
  test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp

Index: test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
===
--- test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
+++ test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp
@@ -0,0 +1,98 @@
+//===--===//
+//
+// 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: libcpp-no-deduction-guides
+
+
+// template ::value_type>>
+//deque(InputIterator, InputIterator, Allocator = Allocator())
+//-> deque::value_type, Allocator>;
+//
+
+
+#include 
+#include 
+#include 
+#include 
+#include  // INT_MAX
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "test_allocator.h"
+
+struct A {};
+
+int main()
+{
+  
+//  Test the explicit deduction guides
+{
+const int arr[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+std::deque deq(std::begin(arr), std::end(arr));
+
+static_assert(std::is_same_v>, "");
+assert(std::equal(deq.begin(), deq.end(), std::begin(arr), std::end(arr)));
+}
+
+{
+const long arr[] = {INT_MAX, 1L + INT_MAX, 2L, 3L };
+std::deque deq(std::begin(arr), std::end(arr), std::allocator());
+static_assert(std::is_same_v, "");
+assert(deq.size() == 4);
+assert(deq[0] == INT_MAX);
+assert(deq[1] == 1L + INT_MAX);
+assert(deq[2] == 2L);
+}
+
+//  Test the implicit deduction guides
+
+{
+//  We don't expect this one to work.
+//  std::deque deq(std::allocator()); // deque (allocator &)
+}
+
+{
+std::deque deq(1, A{}); // deque (size_type, T)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 1);
+}
+
+{
+std::deque deq(1, A{}, test_allocator()); // deque (size_type, T, allocator)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 1);
+}
+
+{
+std::deque deq{1U, 2U, 3U, 4U, 5U}; // deque(initializer-list)
+static_assert(std::is_same_v, "");
+assert(deq.size() == 5);
+assert(deq[2] == 3U);
+}
+
+{
+std::deque deq({1.0, 2.0, 3.0, 4.0}, test_allocator()); // deque(initializer-list, allocator)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 4);
+assert(deq[3] == 4.0);
+}
+
+{
+std::deque source;
+std::deque deq(source); // deque(deque &)
+static_assert(std::is_same_v, "");
+static_assert(std::is_same_v>, "");
+assert(deq.size() == 0);
+}
+}
Index: include/deque
===
--- include/deque
+++ include/deque
@@ -128,6 +128,10 @@
 void clear() noexcept;
 };
 
+template ::value_type>>
+   deque(InputIterator, InputIterator, Allocator = Allocator())
+   -> deque::value_type, Allocator>;
+
 template 
 bool operator==(const deque& x, const deque& y);
 template 
@@ -921,13 +925,14 @@
 {
 __deque_base(const __deque_base& __c);
 __deque_base& operator=(const __deque_base& __c);
+public:
+typedef _Allocator   allocator_type;
+typedef allocator_traits __alloc_traits;
+typedef typename __alloc_traits::size_type   size_type;
 protected:
 typedef _Tp  value_type;
-typedef _Allocator   allocator_type;
-typedef allocator_traits __alloc_traits;
 typedef value_type&  reference;
 typedef const value_type&const_reference;
-typedef typename __alloc_traits::size_type   size_type;
 typedef typename __alloc_traits::difference_type difference_type;
 typedef typename __alloc_traits::pointer pointer;
 typedef typename __alloc_traits::const_pointer   const_pointer;
@@ -946,6 +951,7 @@
 typedef __deque_iteratorconst_iterator;
 
+protected:
 __map __map_;
 size_type __start_;
 __compressed_pair __size_;
@@ -1461,6 +1467,23 @@
 void __move_assign(deque& __c, false_type);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type>,
+ class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ >
+deque(_InputIterator, _InputIterator)
+  -> deque::value_type, _Alloc>;
+
+template::value, void>::type
+ >
+deque(_InputIterator, _InputIterator, _Alloc)

[PATCH] D46964: Implement class deduction guides for `std::array`

2018-05-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/array:75
 
+  template 
+array(T, U...) -> array;

EricWF wrote:
> Don't we normally comment `// C++17` or similar for new features in the 
> synopsis?
we do.



Comment at: include/array:361
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template && ...), void>::type

EricWF wrote:
> The `is same` clause is a requirement, not a SFINAE constraint. Should this 
> be a hard error? Should we really SFINAE it?
If we SFINAE it, then we'll get a hard error; because there are no other 
deduction guides.



Comment at: test/std/containers/sequences/array/array.cons/deduct.fail.cpp:12
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// XFAIL: libcpp-no-deduction-guides
+

EricWF wrote:
> This should be `UNSUPPORTED`. We don't expect this test to ever pass without 
> deduction guides.
OK


https://reviews.llvm.org/D46964



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


[PATCH] D46964: Implement class deduction guides for `std::array`

2018-05-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Committed as revision 332768


https://reviews.llvm.org/D46964



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


[PATCH] D41976: Low-hanging fruit optimization in string::__move_assign().

2018-05-29 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Howard just pointed out to me that `__clear_and_shrink` should be noexcept - 
otherwise we get the generation of an exception table and a call to `terminate` 
in string's move assignment operator.  Fixed in revision 333435.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41976



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


[PATCH] D38757: [libc++] Fix PR34898 - vector iterator constructors and assign method perform push_back instead of emplace_back.

2017-10-11 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM - thanks!


https://reviews.llvm.org/D38757



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


[PATCH] D37955: [libcxx] Fix invert negative bracket match.

2017-10-18 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Landed as revision 316095.


https://reviews.llvm.org/D37955



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


[PATCH] D39066: [libcxx, regex] Fix signed overflow when constructing integers from brace expressions.

2017-10-19 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D39066



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


[PATCH] D39066: [libcxx, regex] Fix signed overflow when constructing integers from brace expressions.

2017-10-19 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Committed as revision 316172.


https://reviews.llvm.org/D39066



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


[PATCH] D51262: Implement P0553 and P0556

2018-08-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: EricWF, ldionne.
Herald added a subscriber: christof.

LWG adopted https://wg21.link/P0553 in Rapperswil, and suggested minor changes 
to https://wg21.link/P0556.

They kind of go together; for example, `ispow2` is easily implemented using 
`popcount` - and they share a bunch of infastructure.

I don't recommend landing this until P0556 is approved, but when I implemented 
one, the other was easy.
None of this stuff will be constexpr on Windows, because the underlying 
primitives are not constexpr on Windows.

Sorry for the large-ish diff, but (like span) it's 85%+ tests.


https://reviews.llvm.org/D51262

Files:
  include/bit
  test/libcxx/numerics/bit/bitops.count/countl_one.pass.cpp
  test/libcxx/numerics/bit/bitops.count/countl_zero.pass.cpp
  test/libcxx/numerics/bit/bitops.count/countr_one.pass.cpp
  test/libcxx/numerics/bit/bitops.count/countr_zero.pass.cpp
  test/libcxx/numerics/bit/bitops.count/popcount.pass.cpp
  test/libcxx/numerics/bit/bitops.rot/rotl.pass.cpp
  test/libcxx/numerics/bit/bitops.rot/rotr.pass.cpp
  test/std/numerics/bit/bit.pow.two/ceil2.fail.cpp
  test/std/numerics/bit/bit.pow.two/ceil2.pass.cpp
  test/std/numerics/bit/bit.pow.two/floor2.fail.cpp
  test/std/numerics/bit/bit.pow.two/floor2.pass.cpp
  test/std/numerics/bit/bit.pow.two/ispow2.fail.cpp
  test/std/numerics/bit/bit.pow.two/ispow2.pass.cpp
  test/std/numerics/bit/bit.pow.two/log2p1.fail.cpp
  test/std/numerics/bit/bit.pow.two/log2p1.pass.cpp
  test/std/numerics/bit/bitops.count/countl_one.fail.cpp
  test/std/numerics/bit/bitops.count/countl_one.pass.cpp
  test/std/numerics/bit/bitops.count/countl_zero.fail.cpp
  test/std/numerics/bit/bitops.count/countl_zero.pass.cpp
  test/std/numerics/bit/bitops.count/countr_one.fail.cpp
  test/std/numerics/bit/bitops.count/countr_one.pass.cpp
  test/std/numerics/bit/bitops.count/countr_zero.fail.cpp
  test/std/numerics/bit/bitops.count/countr_zero.pass.cpp
  test/std/numerics/bit/bitops.count/popcount.fail.cpp
  test/std/numerics/bit/bitops.count/popcount.pass.cpp
  test/std/numerics/bit/bitops.rot/rotl.fail.cpp
  test/std/numerics/bit/bitops.rot/rotl.pass.cpp
  test/std/numerics/bit/bitops.rot/rotr.fail.cpp
  test/std/numerics/bit/bitops.rot/rotr.pass.cpp
  test/std/numerics/bit/nothing_to_do.pass.cpp

Index: test/std/numerics/bit/nothing_to_do.pass.cpp
===
--- test/std/numerics/bit/nothing_to_do.pass.cpp
+++ test/std/numerics/bit/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+int main()
+{
+}
Index: test/std/numerics/bit/bitops.rot/rotr.pass.cpp
===
--- test/std/numerics/bit/bitops.rot/rotr.pass.cpp
+++ test/std/numerics/bit/bitops.rot/rotr.pass.cpp
@@ -0,0 +1,137 @@
+//===--===//
+//
+// 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, c++17 
+
+// template 
+//   constexpr int rotr(T x, unsigned int s) noexcept;
+
+// Remarks: This function shall not participate in overload resolution unless 
+//	T is an unsigned integer type
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+template 
+constexpr bool constexpr_test()
+{
+	const T max = std::numeric_limits::max();
+
+	return std::rotr(T(128), 0) == T(128)
+	   &&  std::rotr(T(128), 1) == T( 64)
+	   &&  std::rotr(T(128), 2) == T( 32)
+	   &&  std::rotr(T(128), 3) == T( 16)
+	   &&  std::rotr(T(128), 4) == T(  8)
+	   &&  std::rotr(T(128), 5) == T(  4)
+	   &&  std::rotr(T(128), 6) == T(  2)
+	   &&  std::rotr(T(128), 7) == T(  1)
+	   &&  std::rotr(max, 0)  == max
+	   &&  std::rotr(max, 1)  == max
+	   &&  std::rotr(max, 2)  == max
+	   &&  std::rotr(max, 3)  == max
+	   &&  std::rotr(max, 4)  == max
+	   &&  std::rotr(max, 5)  == max
+	   &&  std::rotr(max, 6)  == max
+	   &&  std::rotr(max, 7)  == max
+	  ;
+}
+
+
+template 
+void runtime_test()
+{
+	ASSERT_SAME_TYPE(T, decltype(std::rotr(T(0), 0)));
+	ASSERT_NOEXCEPT( std::rotr(T(0), 0));
+	const T max = std::numeric_limits::max();
+	const T val = std::numeric_limits::max() - 1;
+
+	const T uppers [] = {
+		max,	  // not used
+		max - max,	  // 000 .. 0
+		max - (max >> 1), // 800 .. 0
+		max - (max >> 2), // C00 .. 0
+		max - (max >> 3), // E00 .. 0
+		max - (max >> 4), // 

[PATCH] D51262: Implement P0553 and P0556

2018-08-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I should also mention that as a conforming extension, I have implemented the 
non-numeric bit operations for `std::byte`


https://reviews.llvm.org/D51262



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


[PATCH] D50101: [asan] Update a vector's storage annotation during destruction.

2018-09-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

landed as revision 341671.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50101



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


[PATCH] D51955: Create infrastructure for defining and testing feature test macros

2018-09-11 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: ldionne, EricWF.
Herald added a reviewer: jfb.
Herald added a subscriber: jfb.
mclow.lists edited the summary of this revision.

In P0941 , the committee standardized a bunch of 
feature test macros.
[ I think it's a bad idea, but whatever. ]

This patch puts the existing libc++ feature test macros in ``, where 
P0941 specifies, and makes sure that all the correct headers include 
``. It also introduces a full set of tests, one per header file that 
might get something defined.

At the moment, most of those tests are empty, since libc++ does not define many 
feature test macros.
But now it's easy to add more. Put them in `` and update the 
appropriate tests. Helpfully, the list is at the top of each of the test files.


https://reviews.llvm.org/D51955

Files:
  include/algorithm
  include/any
  include/array
  include/atomic
  include/bit
  include/chrono
  include/cmath
  include/complex
  include/cstddef
  include/deque
  include/exception
  include/filesystem
  include/forward_list
  include/functional
  include/iomanip
  include/iterator
  include/list
  include/map
  include/memory
  include/mutex
  include/new
  include/numeric
  include/optional
  include/regex
  include/scoped_allocator
  include/set
  include/shared_mutex
  include/string
  include/string_view
  include/tuple
  include/type_traits
  include/unordered_map
  include/unordered_set
  include/utility
  include/variant
  include/vector
  include/version
  
test/std/language.support/support.limits/support.limits.general/algorithm.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/any.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/array.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/atomic.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/bit.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/chrono.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/cmath.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/concepts.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/cstddef.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/deque.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/exception.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/execution.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/forward_list.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/functional.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/iomanip.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/iterator.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/list.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/map.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/mutex.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/new.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/numeric.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/optional.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/regex.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/scoped_allocator.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/set.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/shared_mutex.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/string.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/string_view.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/type_traits.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/unordered_map.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/unordered_set.version.pass.cpp
  
test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp
  
test/std/language.support/support

[PATCH] D51955: Create infrastructure for defining and testing feature test macros

2018-09-12 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

landed as revision 342073


https://reviews.llvm.org/D51955



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


[PATCH] D49647: [libcxx] Library support for contracts (C++2a)

2018-07-22 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Thanks for doing this, but it needs tests before it can land.
If I were to define `class contract_violation {};` that would pass the tests 
you've provided.
(Heck, if I removed the entire definition of `contract_violation`, it would 
still pass.)




Comment at: include/contract:41
+
+class contract_violation {
+public:

Needs `_LIBCPP_TYPE_VIS`


Repository:
  rCXX libc++

https://reviews.llvm.org/D49647



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


[PATCH] D49647: [libcxx] Library support for contracts (C++2a)

2018-07-22 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I get that lib++ will not make these things, but we still need some tests 
showing that the whole machinery works.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49647



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


[PATCH] D49647: [libcxx] Library support for contracts (C++2a)

2018-07-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

> Testing whether it's actually hooked up correctly is quite problematic; it 
> isn't meant to be instantiable. What's the best way to proceed with this?

The compiler is supposed to create these - right?
Does clang currently do this?

- If not, we should wait for them to catch up.
- If so, then we should have tests that have a contract violation, and pass 
these around.

Since the method for hooking up a CV proc is implementation-defined, those 
tests will probably have to go into `test/libcxx`.




Comment at: 
test/std/language.support/support.contract/contract_violation.pass.cpp:27
+
+  ASSERT_NOEXCEPT(violation.line_number());
+  ASSERT_NOEXCEPT(violation.file_name());

You can do this better with static_assert and declval:

   static_assert(noexcept(std::declval().line_number()), "");

and same with the types:

   static_assert(std::is_same_v().line_number()>, std::uint_least32_t>, "");


(It's shorter to write `using CV = const contract_violation;` and then 
`declval()`)



https://reviews.llvm.org/D49647



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


[PATCH] D49647: [libcxx] Library support for contracts (C++2a)

2018-07-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I'd like to be clear that I'm not against using `ASSERT_NOEXCEPT` or 
`ASSERT_SAME_TYPE` - that's fine.
But I'd rather you use `declval<>` - which is only useful in an unevaluated 
context, rather than having a function that takes a parameter - which someone 
might actually call.

Also, then you can move all the tests into `main` and get rid of the function.


https://reviews.llvm.org/D49647



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


[PATCH] D49647: [libcxx] Library support for contracts (C++2a)

2018-07-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: test/libcxx/language.support/support.contract/version.pass.cpp:9
+//===--===//
+
+// 

All the tests need `// UNSUPPORTED: c++03, c++11, c++14, c++17`


https://reviews.llvm.org/D49647



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


[PATCH] D49338: Implement - P0122R7

2018-07-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists marked 5 inline comments as done.
mclow.lists added a comment.

I think I've answered all of Louis' questions that don't require code changes.
New patch will be coming soon.




Comment at: include/span:217
+using pointer= _Tp *;
+using const_pointer  = const _Tp *; // not in standard
+using reference  = _Tp &;

ldionne wrote:
> Why are we providing them if they are not in the standard?
Because (a) they're useful (see the definition of `const_iterator` below, and 
(b) I (and STL, who wrote the final version of the `span` paper, believe that 
not having them was just an oversight.




Comment at: include/span:235
+
+_LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, index_type 
__count) : __data{__ptr}
+{ (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in 
span's constructor (ptr, len)"); }

ldionne wrote:
> Those functions are specified to throw nothing in the standard. Do we want to 
> add `noexcept` as a QOI thing? What's our usual stance on this?
Yes. The standard follows the "Lakos rule", which says that narrow contract 
functions should not be marked `noexcept`,  because goodness knows what might 
happen if you fail to fulfill the preconditions.

Library implementors have the freedom to mark things as `noexcept` (and libc++ 
does - see `vector::operator[]` for example).





Comment at: include/span:254
+constexpr span(const _Container& __c,
+const enable_if_t<__is_span_compatible_container::value, nullptr_t> = nullptr)
+: __data{_VSTD::data(__c)}

ldionne wrote:
> For both of these `Container` constructors, the paper expresses the SFINAE 
> conditions based on `Container`, not on `Container` in one case and 
> `Container const` in the other, which is what you're doing.
> 
> This is actually a bug in the paper, because this will make code like this 
> compile:
> 
> ```
> std::vector const v;
> std::span s(v);
> ```
> 
> Instead, this should be a compiler error because we're clearly not 
> const-correct here, initializing a `span`-over-non-const from a const 
> `vector`. Example: https://wandbox.org/permlink/kYCui3o0LEGRQ67x
> 
> This happens because we're discarding the constness of the `_Container` 
> template parameter if we stick 100% to the wording of the paper. Should this 
> be a DR?
Yes, this should be an LWG issue.



Comment at: include/span:275
+
+//  ~span() noexcept = default;
+

ldionne wrote:
> Why is this commented out?
This is commented out because of a clang bug 
https://bugs.llvm.org/show_bug.cgi?id=38143, where copy constructor will become 
non-constexpr.  Once this fixed, we can un-comment this line (though it should 
make no difference if it is present or not).




Comment at: include/span:351
+{
+pointer __p = __data;
+__data = __other.__data;

ldionne wrote:
> Just curious -- why not use `_VSTD::swap(__data, __other.__data)`? This would 
> avoid any potential for a stupid logic error to sneak up.
Not to have to include ``? (It may get included anyway)



Comment at: include/span:356-359
+_LIBCPP_INLINE_VISIBILITY span 
__as_bytes() const noexcept
+{ return {reinterpret_cast(data()), size_bytes()}; }
+
+_LIBCPP_INLINE_VISIBILITY span 
__as_writeable_bytes() const noexcept

ldionne wrote:
> It looks like neither `as_bytes` nor `as_writeable_bytes` is marked `const` 
> in the paper. Why are we deviating?
In N4762, they're marked as non-member functions that take `span` by 
value. This implementation just turns around and calls a member function (with 
an unpronounceable name) to do the work.  The standard never mentions 
`__as_bytes` or `__as_writeable_bytes`.








Comment at: include/span:531
+operator==(const span<_Tp1, _Extent1>& __lhs, const span<_Tp2, _Extent2>& 
__rhs)
+{ return equal(__lhs.begin(), __lhs.end(), __rhs.begin(), __rhs.end()); }
+

ldionne wrote:
> It's kind of crazy those are not constrained in any way, but that's what the 
> paper says. I would expect some constraint based on whether we can compare 
> `_Tp1` and _Tp2`.
In my prototype implementation, they were constrained. But LEWG decided not to 
go there (which is the same approach taken in https://wg21.link/P0805 ). There 
needs to be another paper written about constraining container comparisons.

It also applies to homogenous comparisons. Consider `vector>`  
Two of them can't be compared (less than, etc), because `complex` 
doesn't have a `operator<`


https://reviews.llvm.org/D49338



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


[PATCH] D49338: Implement - P0122R7

2018-07-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists marked 13 inline comments as done.
mclow.lists added a comment.

I missed the container constructors being `noexcept`, and the asserts on 
`operator[]` and `operator()` are half done (stupid signed indicies).

I'll wait for other feedback before doing those bits.




Comment at: include/span:320
+constexpr span
+inline _LIBCPP_INLINE_VISIBILITY
+   subspan(index_type __offset, index_type __count = dynamic_extent) const 
noexcept

ldionne wrote:
> I think we generally put those annotations before the return type. Consider 
> doing so here and below for consistency.
I'm not sure where you're referring to "and below". We already do so for the 
other `subspan`.
But definitely here.




Comment at: include/span:335-336
+
+_LIBCPP_INLINE_VISIBILITY constexpr reference operator[](index_type __idx) 
const noexcept { return __data[__idx]; }
+_LIBCPP_INLINE_VISIBILITY constexpr reference operator()(index_type __idx) 
const noexcept { return __data[__idx]; }
+_LIBCPP_INLINE_VISIBILITY constexpr pointer data() 
const noexcept { return __data; }

ldionne wrote:
> Those two could have a `_LIBCPP_ASSERT(__idx >= 0 && __idx < size())`. Is it 
> a conscious choice not to put one?
D'oh! only half done!


https://reviews.llvm.org/D49338



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


[PATCH] D49338: Implement - P0122R7

2018-07-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists marked an inline comment as done.
mclow.lists added a comment.

> I missed the container constructors being `noexcept`

Never mind; they're not `noexcept` (and they should not be)


https://reviews.llvm.org/D49338



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


[PATCH] D49067: Stop wrapping __has_include in another macro

2018-07-23 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added inline comments.
This revision is now accepted and ready to land.



Comment at: include/__config:153
+#ifndef __has_include
+#define __has_include(...) 0
 #endif

rsmith wrote:
> arichardson wrote:
> > EricWF wrote:
> > > I do prefer not hijacking this name, but if it's needed to make things 
> > > work, then it's OK with me.
> > > 
> > > @mclow.lists Are you OK if we steal this identifier and `#define` it 
> > > ourselves.
> > This is the correct way of dealing with missing `__has_include()` according 
> > to @rsmith
> If you would prefer to not define this name yourself, the other option would 
> be to replace all uses of `__has_include(blah)` with
> 
> ```
> #ifdef __has_include
> #if __has_include(blah)
> //...
> #endif
> #endif
> ```
Agreed with @EricWF in general - we prefer to wrap rather than hijack other 
people's names.

However, we can't wrap here, so I'm ok with the hijack.



Repository:
  rCXX libc++

https://reviews.llvm.org/D49067



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


[PATCH] D49711: [CMake] Fix the setting of LIBCXX_HEADER_DIR in standalone build

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Testing this on my system (Mac OS 10.13.6, using system libc++abi), I get a lot 
of files in my build's `include/c++/v1` folder. Previously, there were two 
(`__cxxabi_config.h` and`ccxxabi.h`).
Now there are 131 files - all the libc++ header files.

Why?

The cmake command I use is: `CXX=$LLVM_BIN/clang++ cmake -DLLVM_PATH=$LLVM/llvm 
-DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS=/usr/include $LIBCXX`


Repository:
  rCXX libc++

https://reviews.llvm.org/D49711



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


[PATCH] D49711: [CMake] Fix the setting of LIBCXX_HEADER_DIR in standalone build

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

> phosek updated this revision to Diff 157043.

This fixes the problem with copying all the include files.
This *also* fixes my broken build (that was broken by r337630 wanting to copy 
`cxxabi.h` to `/include/c++/v1/`).

LG for my configuration.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49711



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


[PATCH] D49752: [CMake] Don't install c++abi headers in standalone libc++ build

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

With this change, only one copy of the c++abi headers gets copied - into 
`include/c++/v1/`.
LGTM.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49752



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


[PATCH] D49773: Add new file test/support/test_comparisons.h

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added reviewers: ldionne, EricWF.

As I've been plowing through the `` stuff, I found myself writing tests 
to make sure that the comparisons for a bunch of different types are "sane".

So I factored them out into something that can be used over and over.


https://reviews.llvm.org/D49773

Files:
  test/support/test_comparisons.h

Index: test/support/test_comparisons.h
===
--- test/support/test_comparisons.h
+++ test/support/test_comparisons.h
@@ -0,0 +1,175 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+//  A set of routines for testing the comparison operators of a type
+//
+//  6 tests all six comparison operators
+//  2 tests only op== and op!=
+//
+//  AssertComparisonsXAreNoexcept   static_asserts that the operations are all noexcept.
+//  AssertComparisonsXReturnBoolstatic_asserts that the operations return bool.
+//  AssertComparisonsXConvertibleToBool static_asserts that the operations return something convertible to bool.
+
+
+#ifndef TEST_COMPARISONS_H
+#define TEST_COMPARISONS_H
+
+#include 
+#include "test_macros.h"
+
+//  Test all six comparison operations for sanity
+template 
+constexpr bool testComparisons6(const T& t1, const T& t2, bool isEqual, bool isLess)
+{
+if (isEqual)
+{
+if (!(t1 == t2)) return false;
+if (!(t2 == t1)) return false;
+if ( (t1 != t2)) return false;
+if ( (t2 != t1)) return false;
+if ( (t1  < t2)) return false;
+if ( (t2  < t1)) return false;
+if (!(t1 <= t2)) return false;
+if (!(t2 <= t1)) return false;
+if ( (t1  > t2)) return false;
+if ( (t2  > t1)) return false;
+if (!(t1 >= t2)) return false;
+if (!(t2 >= t1)) return false;
+}
+else if (isLess)
+{
+if ( (t1 == t2)) return false;
+if ( (t2 == t1)) return false;
+if (!(t1 != t2)) return false;
+if (!(t2 != t1)) return false;
+if (!(t1  < t2)) return false;
+if ( (t2  < t1)) return false;
+if (!(t1 <= t2)) return false;
+if ( (t2 <= t1)) return false;
+if ( (t1  > t2)) return false;
+if (!(t2  > t1)) return false;
+if ( (t1 >= t2)) return false;
+if (!(t2 >= t1)) return false;
+}
+else /* greater */
+{
+if ( (t1 == t2)) return false;
+if ( (t2 == t1)) return false;
+if (!(t1 != t2)) return false;
+if (!(t2 != t1)) return false;
+if ( (t1  < t2)) return false;
+if (!(t2  < t1)) return false;
+if ( (t1 <= t2)) return false;
+if (!(t2 <= t1)) return false;
+if (!(t1  > t2)) return false;
+if ( (t2  > t1)) return false;
+if (!(t1 >= t2)) return false;
+if ( (t2 >= t1)) return false;
+}
+
+return true;
+}
+
+//  Easy call when you can init from something already comparable.
+template 
+constexpr bool testComparisons6Values(Param val1, Param val2)
+{
+const bool isEqual = val1 == val2;
+const bool isLess  = val1  < val2;
+
+return testComparisons6(T{val1}, T{val2}, isEqual, isLess);
+}
+
+template 
+void AssertComparisons6AreNoexcept()
+{
+ASSERT_NOEXCEPT(std::declval() == std::declval());
+ASSERT_NOEXCEPT(std::declval() != std::declval());
+ASSERT_NOEXCEPT(std::declval() <  std::declval());
+ASSERT_NOEXCEPT(std::declval() <= std::declval());
+ASSERT_NOEXCEPT(std::declval() >  std::declval());
+ASSERT_NOEXCEPT(std::declval() >= std::declval());
+}
+
+template 
+void AssertComparisons6ReturnBool()
+{
+ASSERT_SAME_TYPE(decltype(std::declval() == std::declval()), bool);
+ASSERT_SAME_TYPE(decltype(std::declval() != std::declval()), bool);
+ASSERT_SAME_TYPE(decltype(std::declval() <  std::declval()), bool);
+ASSERT_SAME_TYPE(decltype(std::declval() <= std::declval()), bool);
+ASSERT_SAME_TYPE(decltype(std::declval() >  std::declval()), bool);
+ASSERT_SAME_TYPE(decltype(std::declval() >= std::declval()), bool);
+}
+
+
+template 
+void AssertComparisons6ConvertibleToBool()
+{
+static_assert((std::is_convertible() == std::declval()), bool>::value), "");
+static_assert((std::is_convertible() != std::declval()), bool>::value), "");
+static_assert((std::is_convertible() <  std::declval()), bool>::value), "");
+static_assert((std::is_convertible() <= std::declval()), bool>::value), "");
+static_assert((std::is_convertible() >  std::declval()), bool>::value), "");
+static_assert((std::is_convertible() >= std::declval()), bool>::value),

[PATCH] D49773: Add new file test/support/test_comparisons.h

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Usage looks like this:

  AssertComparisons6AreNoexcept();
  AssertComparisons6ReturnBool();
  
  static_assert(testComparisons6Values( 5U,  5U), "");
  static_assert(testComparisons6Values( 5U, 10U), "");
  static_assert(testComparisons6Values(10U,  5U), "");


https://reviews.llvm.org/D49773



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


[PATCH] D49773: Add new file test/support/test_comparisons.h

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

> Can they be non-constexpr in C++11 and still function?

Sure. I'll fix that.


https://reviews.llvm.org/D49773



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


[PATCH] D49773: Add new file test/support/test_comparisons.h

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Committed as 337885 after changing `constexpr` -> `TEST_CONSTEXPR_CXX14`


https://reviews.llvm.org/D49773



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


[PATCH] D49774: [libc++] Use __int128_t to represent file_time_type.

2018-07-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I haven't reviewed this closely, but you might want to look at 
http://wg21.link/P0355, where we added a `file_clock` and `file_time` types.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49774



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


[PATCH] D49774: [libc++] Use __int128_t to represent file_time_type.

2018-07-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D49774#1175062, @ldionne wrote:

> In https://reviews.llvm.org/D49774#1174588, @EricWF wrote:
>
> > In https://reviews.llvm.org/D49774#1174565, @mclow.lists wrote:
> >
> > > I haven't reviewed this closely, but you might want to look at 
> > > http://wg21.link/P0355, where we added a `file_clock` and `file_time` 
> > > types.
> >
> >
> > Thanks for the information. It doesn't look to have too much bearing on 
> > this from a design standpoint. Except to note that it seems to solve
> >  the streaming problem by adding explicit streaming overload for time 
> > points.
>
>
> It doesn't change anything from a design standpoint, but I don't think we can 
> ship something deemed stable without taking P0355 into account. That's 
> because it adds `file_clock` and changes `file_time_type` to use it, which is 
> an ABI break. So if we take `filesystem` out of `experimental` and ship it 
> before we've actually implemented the parts of P0355 that change the ABI, 
> we'll have to take an ABI break in the future. That would suck because this 
> ABI break would be necessary to implement C++20 properly in a fairly major 
> way.


Another problem (that Eric and I discussed last night) is that filesystem is 
part of C++17, and `file_clock` is C++20. So we need a solution for C++17 as 
well.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49774



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


[PATCH] D41415: [libcxx] implement casts.

2018-07-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.
Herald added subscribers: bixia, jlebar.

In general, this looks good to me.
I suggested a lot of test improvements, but not very much to the code.
Needs the same kind of namespace changes in the tests as in 
https://reviews.llvm.org/D41376, but that's a minor thing.




Comment at: libcxx/include/experimental/simd:1068
   static typename std::enable_if::size() ==
  simd<_Tp, _NewAbi>::size(),
  simd<_Tp, _NewAbi>>::type

Weird indentation in the `enable_if`



Comment at: libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp:19
 #include 
 
 using namespace std::experimental::parallelism_v2;

All the tests should `#include "test_macros.h"`



Comment at: libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp:22
 
+template 
+auto unsupported_cast(Args&&... args)

I think this is worth a comment here - "This conversion is deleted so that it 
prevents ..."



Comment at: 
libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp:33
 static_assert(
 std::is_same>(
  fixed_size_simd())),

General comment: We have a macro called `ASSERT_SAME_TYPE` that makes this 
clearer.

Instead of all this, you can just write:
   ASSERT_SAME_TYPE(decltype(static_simd_cast>(fixed_size_simd())), simd::size()>(

Since this is an extension, then the test needs to live in test/libcxx, not 
test/std.
(and should probably be two tests, one in test/std, and one in test/libcxx).

Same for to_native.pass.cpp below.



Comment at: 
libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp:30
+void test_to_fixed_size() {
+  auto v = to_fixed_size(native_simd([](int i) { return i; }));
+  static_assert(std::is_same::size()>,

All of these tests need to check the "noexcept-ness" of the operation.
Fortunately, we have a macro for that, too:

ASSERT_NOEXCEPT ( to_fixed_size(std::declval>()));
ASSERT_SAME_TYPE(decltype(to_fixed_size(std::declval>())), 
fixed_size_simd::size()>);



https://reviews.llvm.org/D41415



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


[PATCH] D41422: [libcxx] implement operators and reduction.

2018-07-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.
Herald added subscribers: bixia, jlebar.

A few nits, a bit of things moving underneath you, but this looks good.
Need to add more stuff to the tests ;-)




Comment at: libcxx/include/experimental/simd:1421
 template 
-_Tp hmin(const simd<_Tp, _Abi>&);
+_Tp hmin(const simd<_Tp, _Abi>& __v) {
+  _Tp __acc = __v[0];

In the TS, `hmin`, `hmax` (and a bunch of others) are noexcept. This was added 
in P1110, in response to NB comments CH 30 and CH 33.

Need to fix that here, and add `ASSERT_NOEXCEPT` to a bunch of tests.



Comment at: libcxx/include/experimental/simd:1482
 template 
 class const_where_expression {
 public:

We're going to need a lot of `_LIBCPP_TYPE_VIS` and other annotations. That can 
be a separate patch, though



Comment at: libcxx/include/experimental/simd:1657
+  simd operator++(int) {
+auto __tmp = *this;
+++*this;

I don't think that `auto` buys you anything here. `simd` is fine, and no longer.



Comment at: libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp:23
+
+void test_hmax() {
+  {

Check the return types here with `ASSERT_SAME_TYPE`


https://reviews.llvm.org/D41422



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


[PATCH] D49774: [libc++] Use __int128_t to represent file_time_type.

2018-07-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In https://reviews.llvm.org/D49774#1175650, @ldionne wrote:

> In https://reviews.llvm.org/D49774#1175543, @BillyONeal wrote:
>
> > In https://reviews.llvm.org/D49774#1175131, @mclow.lists wrote:
> >
> > > Another problem (that Eric and I discussed last night) is that filesystem 
> > > is part of C++17, and `file_clock` is C++20. So we need a solution for 
> > > C++17 as well.
> >
> >
> > It seems like we need to fix C++20 to allow that to be a typedef to a type 
> > in std::filesystem or that will be ABI breaking for MSVC++. IMO we should 
> > fix the spec to allow that rather than make libc++ jump through insane 
> > hoops.
>
>
> We could also just provide `file_clock` "early" in C++17. Strictly speaking 
> that may make our implementation non-conforming, but IDK how big of a deal 
> this would be?


Since I've been working on implementing P0355 for C++20, I'll work on 
`file_clock` tonight.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49774



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


[PATCH] D49338: Implement - P0122R7

2018-07-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Landed as r337804.


https://reviews.llvm.org/D49338



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


[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.

2018-07-28 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Getting really close.




Comment at: libcxx/include/experimental/simd:726
+#if defined(_LIBCPP_COMPILER_CLANG)
+#define _SPECIALIZE_VEC_EXT(_TYPE, _NUM_ELEMENT)   
\
+  template <>  
\

timshen wrote:
> mclow.lists wrote:
> > When we define user-visible macros in libc++, we prepend them with _LIBCPP_ 
> > to avoid collisions.
> > Accordingly, `_SPECIALIZE_VEC_EXT` should be named 
> > `_LIBCPP_SPECIALIZE_VEC_EXT`
> > 
> Well _SPECIALIZE_VEC_EXT and _SPECIALIZE_VEC_EXT_32 are not user-visible, as 
> they are (1) '#undef'ed after all uses, and (2) they start with underscore, 
> so don't collide with existing user-defined macros.
I agree, but starting them with _LIBCPP means that people (like me) know that 
they come from libc++, and not (say) clang, or whatever C library we're sitting 
on top of.




Comment at: libcxx/include/experimental/simd:703
+public:
+  _Tp __get(size_t __index) const { return (&__storage_)[__index]; };
+  void __set(size_t __index, _Tp __val) { (&__storage_)[__index] = __val; }

Can these (`__get` and `__set`) be noexcept? Obviously, it depends on `_Tp`.



Comment at: libcxx/include/experimental/simd:811
+class __simd_reference {
+  static_assert(std::is_same<_Vp, _Tp>::value, "");
+

If `_Vp` and `_Tp` have to name the same type, why have two of them?
What is the difference, and when would you use each one internally?

__simd_reference(__simd_storage<_Tp, _Abi>* __ptr, size_t __index);
vs.
__simd_reference operator=(_Vp __value) &&;



https://reviews.llvm.org/D41376



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


[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.

2018-07-30 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I am not in favor of this patch.

I'm in favor of fixing the problem that Arthur has described, but not like 
this, for the following reasons:

- Conceptually, these are (similar to) "Allocator-based versions of the 
algorithms proposed in P0040 ", and should (probably? 
possibly?) look more like them.

- Mainly, though, I think that the goal of this patch (which is see as 'getting 
to memcpy') is not the direction that libc++ should take.  Instead, we should 
be writing simple loops that the compiler can optimize into a call to memcpy if 
it chooses. Having calls to `memcpy` in the code paths makes it impossible to 
"constexp-ify" this code. (See https://libcxx.llvm.org/cxx2a_status.html 
(comments on `std::copy` and https://bugs.llvm.org/show_bug.cgi?id=25165).


Repository:
  rCXX libc++

https://reviews.llvm.org/D49317



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


[PATCH] D49914: [libc++] Add the _LIBCPP_HIDE_FROM_ABI_AFTER_V1 macro

2018-07-30 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This LGTM, but suggests another cleanup.

We have a bunch of `_LIBCPP_BUILDING_XXX` macros defined in libcxx/src - do we 
need them any more now that we have `_LIBCPP_BUILDING_LIBRARY`?

  src/bind.cpp:10: #define _LIBCPP_BUILDING_BIND
  src/memory.cpp:10: #define _LIBCPP_BUILDING_MEMORY
  src/mutex.cpp:10: #define _LIBCPP_BUILDING_MUTEX
  src/new.cpp:10: #define _LIBCPP_BUILDING_NEW
  src/shared_mutex.cpp:13: #define _LIBCPP_BUILDING_SHARED_MUTEX
  src/system_error.cpp:12: #define _LIBCPP_BUILDING_SYSTEM_ERROR
  src/utility.cpp:10: #define _LIBCPP_BUILDING_UTILITY

I can take care of this post-branch for release.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49914



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


[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.

2018-07-30 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/vector:318
+}
+}
+

Quuxplusone wrote:
> Marshall writes:
> > Instead, we should be writing simple loops that the compiler can optimize 
> > into a call to memcpy if it chooses. Having calls to memcpy in the code 
> > paths makes it impossible to "constexp-ify" this code.
> 
> Well, I have three thoughts on that.
> 
> (A), "removing the calls to memcpy" sounds like you want to just call the 
> *actual* move-constructor in a loop, and then later call the actual 
> destructor in a loop. Which is to say, you don't want libc++ to have a 
> codepath for this speed optimization at all. That's just leaving a ton of 
> performance on the table, and I strongly disagree with that idea.
> 
> (B), regardless, couldn't you achieve that goal simply by taking this patch 
> almost exactly as it is except removing the overloads that take `true_type`? 
> If you want constexpr-friendliness badly enough that you're willing to call 
> the move-constructor and destructor even of trivially copyable types, then 
> you can still use this framework; you just have to remove the overloads that 
> call memcpy. That wouldn't be a major refactoring.
> 
> (C), surely if you want the best of both worlds, you should be pushing 
> someone to invent a constexpr memcpy and/or a way to [detect 
> constexpr-context at compile 
> time](https://quuxplusone.github.io/blog/2018/06/12/perennial-impossibilities/#detect-the-constexprness-of-the-current-context)?
>  I don't think it makes sense to pessimize existing (non-constexpr) users in 
> C++03-through-C++17 just because someone hypothetically might in 
> C++2a-or-later want to mutate a std::vector in a constexpr context.
> Which is to say, you don't want libc++ to have a codepath for this speed 
> optimization at all. 

You're completely correct. I don't want libc++ to have such a code path.
I want clang to generate a `memcpy` from the code w/o ever mentioning `memcpy` 
in the source.




Repository:
  rCXX libc++

https://reviews.llvm.org/D49317



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


[PATCH] D49317: Move __construct_forward (etc.) out of std::allocator_traits.

2018-07-30 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

> I don't think it makes sense to pessimize existing (non-constexpr) users in 
> C++03-through-C++17 just because someone hypothetically might in 
> C++2a-or-later want to mutate a std::vector in a constexpr context.

That's not the right (implied) question.

The correct question is:

> Will libc++pessimize existing (non-constexpr) users in C++03-through-C++17 
> ***who are using old compilers*** in order to support new constexpr features 
> that come down the pike?

And the answer to that is yes - eventually. 
I don't know when that will be, since the //new compilers// don't yet exist.
That's the point of https://bugs.llvm.org/show_bug.cgi?id=25165.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49317



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


[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.

2018-07-30 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D41376



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-30 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Getting close here.  I'll have a couple more comments later today, so don't 
post a new diff quite yet.




Comment at: include/charconv:244
+static _LIBCPP_INLINE_VISIBILITY char const*
+read(char const* __p, char const* __ep, type& __a, type& __b)
+{

Quuxplusone wrote:
> mclow.lists wrote:
> > lichray wrote:
> > > mclow.lists wrote:
> > > > Same comment as above about `read` and `inner_product` - they need to 
> > > > be "ugly names"
> > > Unlike `traits` which is a template parameter name in the standard, 
> > > `read` and `inner_product` are function names in the standard, which 
> > > means the users cannot make a macro for them (and there is no guarantee 
> > > about what name you make **not** get by including certain headers), so we 
> > > don't need to use ugly names here, am I right?
> > I understand your reasoning, but I don't agree. 
> > 
> > Just last month, I had to rename a function in `vector` from `allocate` to 
> > `__vallocate` because it confused our "is this an allocator" detection. The 
> > function in question was private, so it shouldn't have mattered, but GCC 
> > has a bug where sometimes it partially ignores access restrictions in 
> > non-deduced contexts, and then throws a hard error when it comes back to a 
> > different context. The easiest workaround was to rename the function in 
> > `vector`.
> > 
> > Since then, I've been leery of public names that match others. This is 
> > pretty obscure, since it's in a private namespace, but I'd feel better if 
> > they were `__read` and `__inner_product`.
> > 
> FWIW, +1 to ugly names. Even if the un-ugly code is "technically not broken 
> yet", and besides the technical reason Marshall gives,
> (1) it's nice that libc++ has style rules and sticks to them, precisely to 
> *avoid* bikeshedding the name of every private member in the world;
> (2) just because users can't `#define read write` doesn't mean they *won't* 
> do it. I would actually be extremely surprised if `read` were *not* defined 
> as a macro somewhere inside ``. :)
> 
> See also: "should this function call be `_VSTD::`-qualified?" Sometimes the 
> answer is technically "no", but stylistically "yes", precisely to indicate 
> that we *don't* intend for it to be an ADL customization point. Consistent 
> style leads to maintainability.
> See also: "should this function call be _VSTD::-qualified

We already have an `inner_product` ( in ``), so I think not.

We `_VSTD::` qualify `move` and `forward` always. `min`/`max` due mostly to 
windows macros. `swap` when need to disable ADL. 

Other things we're inconsistent about: `declval` sometimes (I don't know why), 
`use_facet`, `addressof`, `to_raw_pointer`.

I'll figure out when we should mark things with `_VSTD` and write it up.




Comment at: include/charconv:359
+auto __gen_digit = [](_Tp __c) {
+return "0123456789abcdefghijklmnopqrstuvwxyz"[__c];
+};

lichray wrote:
> mclow.lists wrote:
> > Thinking some more - did this used to do more? Because I don't see why 
> > having a lambda here is a benefit, as compared to:
> > 
> > const char *__digits = "0123456789abcdefghijklmnopqrstuvwxyz";
> > 
> > and
> > *--p = digits[__c];
> > 
> I use a lambda here because it may do more in the future.  If someone wants 
> to let it support non-ASCII platforms, then they only need to make a patch 
> against this lambda rather than changing the sites of uses.  After all, there 
> is nothing wrong to abstract out anything into a function, I think...
I don't think that making it a lambda today buys us anything. Since it is 
local, we can make it a lambda again in the future if we need to w/o breaking 
anyone.

Shades of YAGNI.



Comment at: include/charconv:158
+
+#if !defined(_LIBCPP_COMPILER_MSVC)
+static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v)

In general, we don't put `_LIBCPP_COMPILER_XXX` in header files in libc++.
Instead, we declare a feature macro `_LIBCPP_HAS_` in `<__config>` and then 
use that everywhere.

I see that most of the uses of `_LIBCPP_COMPILER_MSVC` are in ``, 
and center around the builtins for `__builtin_clz`, etc.

We can clean this up later. (/me makes note).




Comment at: include/charconv:285
+inline _LIBCPP_INLINE_VISIBILITY auto
+__to_unsigned(_Tp __x)
+{

in libc++, we put the return type on the left.

template 
inline _LIBCPP_INLINE_VISIBILITY
auto __to_unsigned(_Tp __x)

(and then ask 'why auto'?)




Comment at: test/support/charconv_test_helpers.h:226
+void
+run(type_list)
+{

This name `run` concerns me. I'd feel better if it was `run_integral_tests` or 
something a bit less general.

On the other hand, it's in a test, so we can change it whenever we want.



Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



___

[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

One more thing - 
When you add a new header file, you need to update `include/module.modulemap`, 
`test/libcxx/double_include.sh.cpp`, and `include/CMakeLists.txt`.
Take a look at https://reviews.llvm.org/D49338 for an example.


https://reviews.llvm.org/D46845



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


[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.

In https://reviews.llvm.org/D46845#1183462, @erik.pilkington wrote:

> In https://reviews.llvm.org/D46845#1183435, @mclow.lists wrote:
>
> > One more thing - 
> >  When you add a new header file, you need to update 
> > `include/module.modulemap`, `test/libcxx/double_include.sh.cpp`, and 
> > `include/CMakeLists.txt`.
> >  Take a look at https://reviews.llvm.org/D49338 for an example.
>
>
> Are you sure we have to update test/libcxx/double_include.sh.cpp? Looks like 
> that file only has public headers, but this patch only adds `__node_handle`, 
> which is internal. The new patch adds this header to include/CMakeLists.txt 
> though (`__node_handle` already appeared in module.modulemap)


D'oh! You're right. I didn't see that you had a patch for `module.modulemap`.
Sorry for the noise.

Go ahead and commit (and thanks for doing this!)


https://reviews.llvm.org/D46845



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



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


[PATCH] D50008: [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This looks fine to me.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50008



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


[PATCH] D50101: [asan] Update a vector's storage annotation during destruction.

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

I'm OK with this.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50101



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


[PATCH] D49997: [libcxx] Fix _LIBCPP_NO_EXCEPTIONS redefined warning

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

I'm fine with this; it matches the pattern used on line #354 of this file. 
(which is in the 'clang' block).

We don't do anything like this for the IBM or MS compilers - yet.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49997



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


[PATCH] D50170: [libcxxabi] Fix test_exception_address_alignment test for ARM

2018-08-02 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

That certainly ***looks*** more correct to me.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D50170



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


[PATCH] D42945: [libc++] Fix misleading indentation.

2018-02-06 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

The second change is not quite right. There's a couple of lines that need 
indentation changes.
Phab is not really good about changes like this.  "This file was changed only 
by adding or removing whitespace"

I'll just make these changes myself - thanks for calling them out.


Repository:
  rCXX libc++

https://reviews.llvm.org/D42945



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


[PATCH] D42945: [libc++] Fix misleading indentation.

2018-02-06 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Committed as revision 324378


Repository:
  rCXX libc++

https://reviews.llvm.org/D42945



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


[PATCH] D42987: [libc++abi] fix compilation in C++17 mode

2018-02-06 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I'm fine with this, though I wonder if using the more specific 
`_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS` might be a better thing to 
define.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D42987



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


[PATCH] D41629: [libcxx] Improve accuracy of complex asinh and acosh

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

This all looks good to me.
I think that one more test should be added - and that's one that tests `__sqr` 
directly.
Since that's not a public routine, the test should go in 
"test/libcxx/numerics/complex.number"


https://reviews.llvm.org/D41629



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


[PATCH] D41992: [libcxx] Avoid spurious construction of valarray elements

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This LGTM.




Comment at: include/valarray:3728
+{
+__clear();
 if (__n)

I thought that you had lost an exception guarantee here, but it turns out that 
there wasn't one before.  If the allocation fails, you are left with an empty 
array instead of the old contents.




https://reviews.llvm.org/D41992



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


[PATCH] D26596: [RFC] Add _LIBCPP_NO_DISCARD and apply it to `Container::empty()`, `unique_ptr::release()`, and `Lockable::try_lock()`

2018-02-07 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists requested changes to this revision.
mclow.lists added a comment.
This revision now requires changes to proceed.

Since we've implemented P0600, I believe that this patch is out of date.
The correct macro is `_LIBCPP_NODISCARD_AFTER_CXX17`, and I think that several 
of these cases are now handled.


https://reviews.llvm.org/D26596



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


[PATCH] D43167: Fix incorrect indentation.

2018-02-13 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This is fine.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43167



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


[PATCH] D43277: limits: Use `false` instead of `type(0)`.

2018-02-14 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I see no benefit to this change.  `bool(0)` is `false`.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43277



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


[PATCH] D43226: __threading_support: Remove (void) in favor of ().

2018-02-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.
Herald added a subscriber: christof.

Which clang-tidy module generates this warning, and what is the actual warning?


Repository:
  rCXX libc++

https://reviews.llvm.org/D43226



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


[PATCH] D43273: [libcxx] [test] Fix MSVC warnings and errors.

2018-02-15 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

The `` bit is fine.
The `veryLarge` is "ok".
The rest of them are just bogus.


https://reviews.llvm.org/D43273



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


[PATCH] D41629: [libcxx] Improve accuracy of complex asinh and acosh

2018-02-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM. Do you need me to commit this?


https://reviews.llvm.org/D41629



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


[PATCH] D43273: [libcxx] [test] Fix MSVC warnings and errors.

2018-02-19 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: 
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp:80
 {
 std::vector v(10);
 std::iota(v.begin(), v.end(), 1);

What if we just made the containers `vector` ?  (and `triangle`)


https://reviews.llvm.org/D43273



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


[PATCH] D43579: [libcxx] Do not include the C math.h header before __config

2018-02-21 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This LGTM.


https://reviews.llvm.org/D43579



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


[PATCH] D43579: [libcxx] Do not include the C math.h header before __config

2018-02-21 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/math.h:1499
+// has previously been included.
+#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
+#include_next 

pcc wrote:
> Nit: you don't actually need the ` && defined(_USE_MATH_DEFINES)` part.
I proposed that deliberately.

With the test, if you don't define `_USE_MATH_DEFINES` and re-include 
`` it does nothing; which is what you want.

The MS-supplied `` probably does this already, but ...


https://reviews.llvm.org/D43579



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


[PATCH] D43273: [libcxx] [test] Fix MSVC warnings and errors.

2018-02-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM - thanks!


https://reviews.llvm.org/D43273



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


[PATCH] D43773: Implement the container bits of P0805R1

2018-02-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.
mclow.lists added a reviewer: EricWF.

P0805R1  
is about comparing heterogenous containers.

This is the implementation for `array`, `vector`, `deque`, `list` and 
`forward_list`.
The `tuple` bits will follow soon.

I hope to land this immediately after it is adopted in Jacksonville.


https://reviews.llvm.org/D43773

Files:
  include/array
  include/deque
  include/list
  include/vector
  test/std/containers/sequences/array/compare.fail.cpp
  test/std/containers/sequences/array/compare.pass.cpp
  test/std/containers/sequences/deque/compare.fail.cpp
  test/std/containers/sequences/deque/compare.pass.cpp
  test/std/containers/sequences/forwardlist/compare.fail.cpp
  test/std/containers/sequences/forwardlist/compare.pass.cpp
  test/std/containers/sequences/list/compare.fail.cpp
  test/std/containers/sequences/list/compare.pass.cpp
  test/std/containers/sequences/vector/compare.fail.cpp
  test/std/containers/sequences/vector/compare.pass.cpp

Index: test/std/containers/sequences/vector/compare.pass.cpp
===
--- test/std/containers/sequences/vector/compare.pass.cpp
+++ test/std/containers/sequences/vector/compare.pass.cpp
@@ -0,0 +1,90 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  bool operator==(const vector& x, const vector& y);
+// template  bool operator< (const vector& x, const vector& y);
+// template  bool operator!=(const vector& x, const vector& y);
+// template  bool operator> (const vector& x, const vector& y);
+// template  bool operator>=(const vector& x, const vector& y);
+// template  bool operator<=(const vector& x, const vector& y);
+// 
+// C++20
+// template
+//   bool operator==(const vector& x, const vector& y);
+// template
+//   bool operator< (const vector& x, const vector& y);
+// template
+//   bool operator!=(const vector& x, const vector& y);
+// template
+//   bool operator> (const vector& x, const vector& y);
+// template
+//   bool operator>=(const vector& x, const vector& y);
+// template
+//   bool operator<=(const vector& x, const vector& y);
+
+
+#include 
+#include 
+
+#include "min_allocator.h"
+#include "test_macros.h"
+
+template 
+void test_compare(const Vector& LHS, const Vector& RHS, bool isLess, bool isEqual) {
+  assert((LHS == RHS) ==  isEqual);
+  assert((LHS != RHS) == !isEqual);
+  assert((LHS  < RHS) ==  isLess);
+  assert((LHS <= RHS) ==  (isLess | isEqual));
+  assert((LHS  > RHS) == !(isLess | isEqual));
+  assert((LHS >= RHS) == !isLess);
+}
+
+template 
+void test_compare(const Vector1& LHS, const Vector2& RHS, bool isLess, bool isEqual) {
+  assert((LHS == RHS) ==  isEqual);
+  assert((LHS != RHS) == !isEqual);
+  assert((LHS  < RHS) ==  isLess);
+  assert((LHS <= RHS) ==  (isLess | isEqual));
+  assert((LHS  > RHS) == !(isLess | isEqual));
+  assert((LHS >= RHS) == !isLess);
+}
+
+int main()
+{
+  {
+typedef int T;
+typedef std::vector C;
+C c0 = {};
+C c1 = {1, 2, 3};
+C c2 = {1, 2, 3};
+C c3 = {3, 2, 1};
+C c4 = {1, 2, 1};
+test_compare(c0, c1, true, false);
+test_compare(c1, c2, false, true);
+test_compare(c1, c3, true, false);
+test_compare(c1, c4, false, false);
+  }
+
+#if TEST_STD_VER > 17
+  {
+std::vector   c0 = {};
+std::vector   c1 = {4};
+std::vector  c2 = {4L};
+std::vector c3 = {2};
+std::vector> c4 = {4};
+test_compare(c0, c1, true, false);  // same type, different lengths
+test_compare(c0, c2, true, false);  // different type, different lengths
+test_compare(c1, c2, false, true);  // different types, same length, same values
+test_compare(c1, c3, false, false); // different types, same length, different values
+test_compare(c1, c4, false, true);  // different types, same length, same value, different allocator
+  }
+#endif
+}
Index: test/std/containers/sequences/vector/compare.fail.cpp
===
--- test/std/containers/sequences/vector/compare.fail.cpp
+++ test/std/containers/sequences/vector/compare.fail.cpp
@@ -0,0 +1,70 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  bool operator==(const vector& x, const vector& y);
+// template  bool operator< (const vector

[PATCH] D43773: Implement the container bits of P0805R1

2018-02-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 135941.
mclow.lists added a comment.

forgot to include the changes for `` in the diff.


https://reviews.llvm.org/D43773

Files:
  include/array
  include/deque
  include/forward_list
  include/list
  include/vector
  test/std/containers/sequences/array/compare.fail.cpp
  test/std/containers/sequences/array/compare.pass.cpp
  test/std/containers/sequences/deque/compare.fail.cpp
  test/std/containers/sequences/deque/compare.pass.cpp
  test/std/containers/sequences/forwardlist/compare.fail.cpp
  test/std/containers/sequences/forwardlist/compare.pass.cpp
  test/std/containers/sequences/list/compare.fail.cpp
  test/std/containers/sequences/list/compare.pass.cpp
  test/std/containers/sequences/vector/compare.fail.cpp
  test/std/containers/sequences/vector/compare.pass.cpp

Index: test/std/containers/sequences/vector/compare.pass.cpp
===
--- test/std/containers/sequences/vector/compare.pass.cpp
+++ test/std/containers/sequences/vector/compare.pass.cpp
@@ -0,0 +1,90 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  bool operator==(const vector& x, const vector& y);
+// template  bool operator< (const vector& x, const vector& y);
+// template  bool operator!=(const vector& x, const vector& y);
+// template  bool operator> (const vector& x, const vector& y);
+// template  bool operator>=(const vector& x, const vector& y);
+// template  bool operator<=(const vector& x, const vector& y);
+// 
+// C++20
+// template
+//   bool operator==(const vector& x, const vector& y);
+// template
+//   bool operator< (const vector& x, const vector& y);
+// template
+//   bool operator!=(const vector& x, const vector& y);
+// template
+//   bool operator> (const vector& x, const vector& y);
+// template
+//   bool operator>=(const vector& x, const vector& y);
+// template
+//   bool operator<=(const vector& x, const vector& y);
+
+
+#include 
+#include 
+
+#include "min_allocator.h"
+#include "test_macros.h"
+
+template 
+void test_compare(const Vector& LHS, const Vector& RHS, bool isLess, bool isEqual) {
+  assert((LHS == RHS) ==  isEqual);
+  assert((LHS != RHS) == !isEqual);
+  assert((LHS  < RHS) ==  isLess);
+  assert((LHS <= RHS) ==  (isLess | isEqual));
+  assert((LHS  > RHS) == !(isLess | isEqual));
+  assert((LHS >= RHS) == !isLess);
+}
+
+template 
+void test_compare(const Vector1& LHS, const Vector2& RHS, bool isLess, bool isEqual) {
+  assert((LHS == RHS) ==  isEqual);
+  assert((LHS != RHS) == !isEqual);
+  assert((LHS  < RHS) ==  isLess);
+  assert((LHS <= RHS) ==  (isLess | isEqual));
+  assert((LHS  > RHS) == !(isLess | isEqual));
+  assert((LHS >= RHS) == !isLess);
+}
+
+int main()
+{
+  {
+typedef int T;
+typedef std::vector C;
+C c0 = {};
+C c1 = {1, 2, 3};
+C c2 = {1, 2, 3};
+C c3 = {3, 2, 1};
+C c4 = {1, 2, 1};
+test_compare(c0, c1, true, false);
+test_compare(c1, c2, false, true);
+test_compare(c1, c3, true, false);
+test_compare(c1, c4, false, false);
+  }
+
+#if TEST_STD_VER > 17
+  {
+std::vector   c0 = {};
+std::vector   c1 = {4};
+std::vector  c2 = {4L};
+std::vector c3 = {2};
+std::vector> c4 = {4};
+test_compare(c0, c1, true, false);  // same type, different lengths
+test_compare(c0, c2, true, false);  // different type, different lengths
+test_compare(c1, c2, false, true);  // different types, same length, same values
+test_compare(c1, c3, false, false); // different types, same length, different values
+test_compare(c1, c4, false, true);  // different types, same length, same value, different allocator
+  }
+#endif
+}
Index: test/std/containers/sequences/vector/compare.fail.cpp
===
--- test/std/containers/sequences/vector/compare.fail.cpp
+++ test/std/containers/sequences/vector/compare.fail.cpp
@@ -0,0 +1,70 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// 
+
+// template  bool operator==(const vector& x, const vector& y);
+// template  bool operator< (const vector& x, const vector& y);
+// template  bool operator!=(const vector& x, const vector& y);
+// template  bool operator> (const vector& x, const vector& y);
+// template  bool operator>=(const vector& x, const vector& y);
+// template  bool o

[PATCH] D43773: Implement the container bits of P0805R1

2018-02-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I can certainly make them all the same.


https://reviews.llvm.org/D43773



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


[PATCH] D43773: Implement the container bits of P0805R1

2018-02-26 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

> Is there a subtle reason for this inconsistency that I'm not seeing?

I suspect that it's because they were written at different times.
(When I say 'written at different times', I mean I adapted the existing `op==` 
for the containers - not that this new code was written at different times)

I'm a fan of the four-legged bits, but in `op==` (except for `forward_list` we 
know the sizes are the same.


https://reviews.llvm.org/D43773



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


[PATCH] D33424: Lexer: allow imaginary constants in GNU mode (only).

2017-05-24 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

This broke a libc++ test.  The following is expected to fail to compile:

  #include 
  #include 
  
  int main()
  {
  std::complex foo  = 1.0if;  // should fail w/conversion operator 
not found
  }

when build as C++1z


https://reviews.llvm.org/D33424



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


  1   2   3   4   5   >