Summary:
This patch contains the following changes:
1. Require that libc++ can find a LLVM source directory. This is done the same way as `libc++abi` currently does.
2. Cleanup ugly configuration code in CMakeLists.txt by using `add_flags`, `add_flags_if`, and `add_flags_if_supported` macros.
The goals for this patch are:
1. Help libc++ be more consistent with how LLVM handles CMake options (see PR23670 PR23671).
2. Make it easier to use sanitizers using the `LLVM_USE_SANITIZER` option.
3. Make libc++'s CMakeLists.txt file easier to understand and change.
4. Move towards allowing libc++ to create Sphinx documentation (see http://efcs.ca/libcxx-docs).
5. Move towards allowing libc++ to use other LLVM utilities such as `not` and `FileCheck`.
Reviewers: mclow.lists, jroelofs, danalbert
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D11308
llvm-svn: 243503
The key changes in this patch are:
1. Remove the zero-argument overload in mem_fn. A member function must always
be invoked with at least one argument, the class instance. The zero-argument
operator()() in mem_fn would cause mem_fn to fail to compile when because
the call to '__invoke(pm)' is not well formed.
2. Prevent evaluation of '__apply_cv<Tp, Ret>' when 'Ret' is a function type.
'Ret' is a function type whenever 'Ret Tp::*' is a pointer to member function.
Attempting to add cv and ref qualifiers to a function type can cause a hard
compile error.
3. Remove the dummy overload __invoke(Rp Tp::*). It was present to help work
around #1. It will be replaced with a different '__invoke' overload that
represents a bad call to invoke.
After applying this patch the test func.wrap.func.inv/invoke.pass.cpp now
passes.
llvm-svn: 243370
This patch does a couple of things to get __invoke working for free-functions
and call objects.
1. Turn all uses of declval<Tp>() into declval<Tp&>(). The C++03 __invoke only
supports lvalues but it will be used when the compiler supports rvalue
references but not variadic templates. This change makes sure we don't
generate an rvalue.
2. Call objects for bullet 5 are now passed by reference and not value. Copying
the functor is incorrect. It will fail to compile for non-copyable functors
and it will discard cv-qualifiers on the call object, possibly leading to the
wrong function being called. I suspect that the reason the call object
was originally taken by value was to support temporary call objects.
However __invoke is only used internally and it is never given a temporary.
llvm-svn: 243368
The implementation of mem_fn doesn't actually require any C++11 support.
For some reason there were 17 overloads for mem_fn in C++03 when only one
is needed. This patch removes the extra overloads and uses the same implementation
of mem_fn in C++03 and C++11.
__mem_fn does require variadics to implement the call operator. Instead of
having two entirely different implementations of the __mem_fn struct, this patch
uses the same __mem_fn struct but provides different call operators when
variadics are not available.
The only thing left in <__functional_03> is the C++03 implementation of
std::function.
llvm-svn: 242959
This patch removes a large amount of duplicate code found in both
<__functional_base> and <__functional_base_03>. The only code that remains
in <__functional_base_03> is the C++03 implementation of __invoke and
__invoke_return.
llvm-svn: 242951
<__functional_03> provides the C++03 definitions for std::memfun and
std::function. However the interaction between <functional> and <__functional_03>
is ugly and duplicates code needlessly. This patch cleans up how the two
headers work together.
The major changes are:
- Provide placeholders, is_bind_expression and is_placeholder in <functional>
for both C++03 and C++11.
- Provide bad_function_call, function fwd decl,
__maybe_derive_from_unary_function and __maybe_derive_from_binary_function
in <functional> for both C++03 and C++11.
- Move the <__functional_03> include to the bottom of <functional>. This makes
it easier to see how <__functional_03> interacts with <functional>
- Remove a commented out implementation of bind in C++03. It's never going
to get implemented.
- Mark almost all std::bind tests as unsupported in C++03. std::is_placeholder
works in C++03 and C++11. std::is_bind_expression is provided in C++03 but
always returns false.
llvm-svn: 242870
Summary: This patch adds special configuration logic to find the compiler_rt libraries required by sanitizers on OS X. The supported sanitizers are Address and Undefined.
Reviewers: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D11381
llvm-svn: 242858
Although CMake adds warning flags, they are ignored in the libc++ headers
because the headers '#pragma system header' themselves.
This patch disables the system header pragma when building libc++ and fixes
the warnings that arose.
The warnings fixed were:
1. <memory> - anonymous structs are a GNU extension
2. <functional> - anonymous structs are a GNU extension.
3. <__hash_table> - Embedded preprocessor directives have undefined behavior.
4. <string> - Definition is missing noexcept from declaration.
5. <__std_stream> - Unused variable.
llvm-svn: 242623
Summary: This patch adds proper guards to the is_destructible tests depending on the standard version so that they pass in c++03.
Reviewers: mclow.lists, EricWF
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D10047
llvm-svn: 242612
Summary:
In some places in libc++ we need to use the `__atomic_*` builtins. This patch adds a header that provides access to those builtins in a uniform way from within the dylib source.
If the compiler building the dylib does not support these builtins then a warning is issued.
Only relaxed loads are needed within the headers. A singe function to do these relaxed loads has been added to `<memory>`.
This patch applies the new atomic builtins to `__shared_count` and `call_once`.
Reviewers: mclow.lists
Subscribers: majnemer, jroelofs, cfe-commits
Differential Revision: http://reviews.llvm.org/D10406
llvm-svn: 241532
Automatically enable clang verify whenever the '-verify-ignore-unexpected' flag
is supported.
Failure tests are run using verify if they contain one or more "expected-*"
diagnostics tags. Otherwise they are run normally.
llvm-svn: 241492
After r241454 landed, libc++'s locale code compiles on CloudABI, with
the exception of the following two bits:
- CloudABI doesn't have setlocale(), as the C library does not keep
track of any global state. The global locale is always set to "C".
Disable the call to setlocale() on this system.
- Similarly, mbtowc_l() is also not present, as it is also not
thread-safe. As CloudABI does not support state-dependent encodings,
simply disable that part of the logic.
The locale code now compiles out of the box on CloudABI.
Differential Revision: http://reviews.llvm.org/D10729
Reviewed by: jroelofs
llvm-svn: 241455
The __cloc() function is only present in case the environment does not
provide a way to refer to the C locale using a compile-time constant
expression. _LIBCPP_GET_C_LOCALE seems to be defined unconditionally.
This improves compilation of the locale code on CloudABI.
Differential Revision: http://reviews.llvm.org/D10690
Reviewed by: jroelofs
llvm-svn: 241454
One of the aspects of CloudABI is that it aims to help you write code
that is thread-safe out of the box. This is very important if you want
to write libraries that are easy to reuse. For CloudABI we decided to
not provide the thread-unsafe functions. So far this is working out
pretty well, as thread-unsafety issues are detected really early on.
The following patch adds a knob to libc++,
_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS, that can be set to disable
thread-unsafe functions that can easily be avoided in practice. The
following functions are not thread-safe:
- <clocale>: locale handles should be preferred over setlocale().
- <cstdlib>: mbrlen(), mbrtowc() and wcrtomb() should be preferred over
their non-restartable counterparts.
- <ctime>: asctime(), ctime(), gmtime() and localtime() are not
thread-safe. The first two are also deprecated by POSIX.
Differential Revision: http://reviews.llvm.org/D8703
Reviewed by: marshall
llvm-svn: 240527
The C++03 version of function tried to default construct the allocator
in the uses allocator constructors when no allocation was performed. These
constructors would fail to compile when used with allocators that had no
default constructor.
llvm-svn: 239708
The two main fixes this patch contains are:
- use __identity_t instead of common_type. common_type was used as an
identity metafunction but the decay resulted in incorrect results.
- Pointers to free functions were not counted as functions. Remove the pointer
before checking if a type is a function.
llvm-svn: 239668
Summary:
when `unordered_set::insert(value_type&&)` was called it would be treated like `unordered_set::emplace(Args&&)` and it would allocate and construct a node before trying to insert it.
This caused unnecessary allocations when the value was already in the set. This patch adds an overload to `__hash_table::__insert_unique` that specifically handles `value_type&&` more link `value_type const &`.
This patch also adds a single unified insert function for values into `__hash_table` called `__insert_unique_value` that handles the cases for `__insert_unique(value_type&&)` and `__insert_unique(value_type const &)`.
This patch fixes PR12999: http://llvm.org/bugs/show_bug.cgi?id=12999.
Reviewers: mclow.lists, titus, danalbert
Reviewed By: danalbert
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D7570
llvm-svn: 239666
Summary: Currently we only enable the use of __is_final(...) with Clang. GCC also provides __is_final(...) since 4.7 in all standard modes. This patch creates the macro _LIBCPP_HAS_IS_FINAL to note the availability of `__is_final`.
Reviewers: danalbert, mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D8795
llvm-svn: 239664
Summary:
Both clang and GCC provide C++11 decltype semantics as __decltype in c++03 mode. We should use this instead of __typeof__ when availble.
GCC added __decltype in 4.6.0, and AFAIK clang provided __decltype ever since 3.3. Unfortunately `__has_builtin(__decltype)` doesn't work for clang so we need to check the compiler version instead.
Reviewers: mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D10426
llvm-svn: 239662
This patch fixes LWG issue 2422 by removing the DECAY_COPY from call once.
The review can be found here: http://reviews.llvm.org/D10191
llvm-svn: 239654
Until GCC 5.1 the __is_trivially* intrinsics were not provided. Enable use of
the builtins for GCC 5.1.
Also enable Reference qualified member functions for GCC 4.9 and greater.
This patch also defines _GNUC_VER to 0 when __GNUC__ is not defined because
libc++ assumes _GNUC_VER is always defined.
llvm-svn: 239653
Replacing the dependancy on __member_function_traits with is_function allows
is_member_function_pointer to work more often. In particular it allows it to
work when we don't have variadic templates but the function has an arity > 3.
llvm-svn: 239649
The __atomic_is_lock_free(...) function sometimes requires linkage to libatomic
if it cannot be evaluated at compile time. Remove __c11_atomic_is_lock_free
and use __atomic_is_lock_free(sizeof(Tp)) directly so that it can be evaluated
at compile time.
llvm-svn: 239648
Within the shared state methods do not unlock the lock guards manually. This
could cause a race condition where the shared state is destroyed before the
method is complete.
llvm-svn: 239577
The changes in src/exception.cpp and cmake/Modules/HandleLibCXXABI.cmake fix a
bug when building libc++ with GCC. Because GCC does not support __has_include
we need to explicitly tell it that we are building against libc++abi via the
preprocessor definition `LIBCXX_BUILDING_LIBCXXABI`.
The changes in include/ratio are to work around CWG defect
1712 (constexpr variable template declarations). GCC 4.8 and before has not
adopted the resolution to this defect.
The changes in include/exception work around an issue where is_final is used
without it being defined in type_traits.
llvm-svn: 237767
Summary:
This patch does 2 main things:
1. Enable sized delete if the feature test macro `__cpp_sized_deallocation` is enabled.
2. Rework and cleanup all of the sized delete tests.
Test Plan:
The sized delete replacement tests are now split into 4 files:
1. sized_delete11.pass.cpp: Ensure overriding sized delete in C++11 has no effect.
2. sized_delete14.pass.cpp: Test overriding sized delete in C++14 and ensure it is called. This test fails on clang and GCC < 5.1.
3. size_delete_calls_unsized_delete_.pass.cpp: Test that the default sized delete calls unsized delete.
4. sized_delete_fsizeddeallocation.pass.cpp: Test overriding sized delete when -fsized-deallocation is passed. This test should pass on clang and GCC >= 5.1
I have also removed a lot of cruft from the old tests. They no longer replace the new handler and tests that it is called for bad allocations.
Reviewers: mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D9831
llvm-svn: 237662
The previous commit breaks the builds when libc++abi is not built with
libunwind becuase the default value for LIBCXXABI_USE_LLVM_UNWINDER is
OFF, which is not pythonized.
This CL fix the problem by calling pythonize_bool().
llvm-svn: 237519
The test cases were crashing due to the mixed usage of the unwinding
functions from both libunwind and libgcc_s. The unwind functions are
mixed because the "llvm_unwinder" entry is not available in the
lit.site.cfg for libc++. As a result, "-lgcc_s" is picked instead of
"-lunwind". The extra option to lit --param=link_flags="-lunwind" won't
help either.
This CL fix the problem by adding llvm_unwinder to lit.site.cfg.in.
llvm-svn: 237518
The system_clock::now() function currently uses gettimeofday(). The
problem with gettimeofday() is that it is an obsolete XSI function,
hence unavailable on CloudABI. See:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html
Change this code to use clock_gettime() with CLOCK_REALTIME instead,
which is more consistent, as clock_gettime() is already used for
steady_clock.
A previous version of this change actually attempted to change
system_clock::duration, but I reverted this part as it breaks the
existing ABI.
Differential Revision: http://reviews.llvm.org/D8253
Approved by: jroelofs
llvm-svn: 237390
The test class 'G' reads and writes to the same static variables in its
constructor, destructor and call operator. When threads are
constructed using `std::thread t((G()))` there is a race condition between the
destruction of the temporary and the execution of `G::operator()()`.
The fix is to simply create the input before creating the thread.
llvm-svn: 233946
Summary:
The summary of the bug, provided by Stephan T. Lavavej:
In shared_timed_mutex::try_lock_until() (line 195 in 3.6.0), you need to deliver a notification. The scenario is:
* There are N threads holding the shared lock.
* One thread calls try_lock_until() to attempt to acquire the exclusive lock. It sets the "I want to write" bool/bit, then waits for the N readers to drain away.
* K more threads attempt to acquire the shared lock, but they notice that someone said "I want to write", so they block on a condition_variable.
* At least one of the N readers is stubborn and doesn't release the shared lock.
* The wannabe-writer times out, gives up, and unsets the "I want to write" bool/bit.
At this point, a notification (it needs to be notify_all) must be delivered to the condition_variable that the K wannabe-readers are waiting on. Otherwise, they can block forever without waking up.
Reviewers: mclow.lists, jyasskin
Reviewed By: jyasskin
Subscribers: jyasskin, cfe-commits
Differential Revision: http://reviews.llvm.org/D8796
llvm-svn: 233944
Summary:
In certain cases vector can use memcpy to construct a range of elements at the back of the vector. We currently don't do this resulting in terrible code gen in non-optimized mode and a
very large slowdown compared to libstdc++.
This patch adds a `__construct_forward_range(Allocator, Iter, Iter, _Ptr&)` and `__construct_forward_range(Allocator, Tp*, Tp*, Tp*&)` functions to `allocator_traits` which act similarly to the existing `__construct_forward(...)` functions.
This patch also changes vectors `__construct_at_end(Iter, Iter)` to be `__construct_at_end(Iter, Iter, SizeType)` where SizeType is the size of the range. `__construct_at_end(Iter, Iter, SizeType)` now calls `allocator_traits<Tp>::__construct_forward_range(...)`.
This patch is based off the design of `__swap_out_circular_buffer(...)` which uses `allocator_traits<Tp>::__construct_forward(...)`.
On my machine this code performs 4x better than the current implementation when tested against `std::vector<int>`.
Reviewers: howard.hinnant, titus, kcc, mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D8109
llvm-svn: 233711
Summary:
This patch adds configuration to CMake and LIT for running the libc++ test-suite to generate code coverage.
To use code coverage use following instructions.
* Find the clang resource dir using `$CXX -print-search-dirs`. Let <library-dir> be the first library search directory.
* `cmake <regular-options> -DLIBCXX_GENERATE_COVERAGE=ON -DLIBCXX_COVERAGE_LIBRARY=<library-dir>/lib/<platform>/libclang_rt.profile.a <source>`
* `make cxx`
* `make check-libcxx`
* `make generate-libcxx-coverage`
The reason I want this patch upstreamed is so I can setup a bot that generates code coverage and posts in online for every revision.
Reviewers: mclow.lists, jroelofs, danalbert
Reviewed By: danalbert
Differential Revision: http://reviews.llvm.org/D8716
llvm-svn: 233669
Summary:
Currently the conversion check does not take place in a context where access control SFINAE is applied. This patch changes the context of the test expression so that SFINAE occurs if access control does not permit the conversion.
Related bug: https://llvm.org/bugs/show_bug.cgi?id=22771
Reviewers: mclow.lists, rsmith, dim
Reviewed By: dim
Subscribers: dim, rodrigc, emaste, cfe-commits
Differential Revision: http://reviews.llvm.org/D8461
llvm-svn: 233552
The idea behind Nuxi CloudABI is that it is targeted at (but not limited to)
running networked services in a sandboxed environment. The model behind stdin,
stdout and stderr is strongly focused on interactive tools in a command shell.
CloudABI does not support the notion of stdin and stdout, as 'standard
input/output' does not apply to services. The concept of stderr does makes
sense though, as services do need some mechanism to log error messages in a
uniform way.
This patch extends libc++ in such a way that std::cin and std::cout and the
associated <cstdio>/<cwchar> functions can be disabled through the flags
_LIBCPP_HAS_NO_STDIN and _LIBCPP_HAS_NO_STDOUT, respectively. At the same time
it attempts to clean up src/iostream.cpp a bit. Instead of using a single array
of mbstate_t objects and hardcoding the array indices, it creates separate
objects that declared next to the iostream objects and their buffers. The code
is also restructured by interleaving the construction and setup of c* and wc*
objects. That way it is more obvious that this is done identically.
The c* and wc* objects already have separate unit tests. Make use of this fact
by adding XFAILs in case libcpp-has-no-std* is set. That way the tests work in
both directions. If stdin or stdout is disabled, these tests will therefore
test for the absence of c* and wc*.
Differential Revision: http://reviews.llvm.org/D8340
llvm-svn: 233275
If we want to add support for making std::cin and std::cout optional, it
is impractical to have all of the mbstate_t objects in one array. This
would mean that if std::cin and std::cout are omitted, the state_types
array is only used partially.
Solve this by using separate global variables. These are placed right
next to the iostream object and the buffer, meaning we can easily #ifdef
them away.
Differential Revision: http://reviews.llvm.org/D8359
llvm-svn: 233274
The time_put test doesn't seem to work on Linux and CloudABI. For Linux
we already have an XFAIL. Closer inspection seems to reveal that this
test does not pass for a couple of reasons.
First of all, the tm_yday field is set to an invalid value. The
strftime() function doesn't behave consistently across platforms in case
the values in the tm structure are incoherent. Fix up this field to have
the value 121, which corresponds with tm_mday, tm_mon and tm_year. This
of course affects the output of time_put for some modifiers, so update
the tests accordingly.
Second, some of the tests actually use modifiers that are only present
on BSD derived systems. They are not part of the C standard/POSIX.
Simply remove them.
Finally, some of the tests actually use invalid modifiers, causing a
malformed format string to be passed to strftime(). Remove these tests
as well.
Differential Revision: http://reviews.llvm.org/D8349
llvm-svn: 233262
Summary:
Add symbol checking scripts for extracting a list of symbols from shared libraries and for comparing symbol lists for differences.
Reviewers: mclow.lists, danalbert, EricWF
Reviewed By: EricWF
Subscribers: majnemer, emaste, cfe-commits
Differential Revision: http://reviews.llvm.org/D4946
llvm-svn: 232855
Summary: This patch also fixes one test case that failed in the library version of is_convertible.
Reviewers: mclow.lists, EricWF
Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D8456
llvm-svn: 232764
Summary:
Clean up all the different possible CMake options for specifying the ABI include paths into one CMake option named `LIBCXX_CXX_ABI_INCLUDE_PATHS`.
The documentation has been updated to reflect this change.
For the next week I have added explicit errors if any of the old flags is used. These errors inform users of the change and the new option to use.
Before committing the change I will announce this change on cfe-dev.
Reviewers: danalbert, mclow.lists
Reviewed By: danalbert, mclow.lists
Subscribers: jroelofs, cbergstrom, cfe-commits
Differential Revision: http://reviews.llvm.org/D5039
llvm-svn: 232762
Summary:
This patch changes std::function to use allocator_traits to rebind the allocator instead of allocator itself.
It also changes most of the tests to use `bare_allocator` where possible instead of `test_allocator`.
Reviewers: mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D8391
llvm-svn: 232686
1) <cstdlib> header should define std::abs([int|long|long long])
functions. They use "using ::abs" to import these functions (which are
declared in <stdlib.h>) into std namespace.
2) <cmath> header should define std::abs([float|double|long double])
function. If we try define new functions in std namespace, then it
will cause compile error in <cstdlib> because "using ::abs" will try
import not only [int|long|long long] functions, but also
[float|double|long double] which are defined in <math.h> header on
solaris.
Patch by C Bergstrom.
llvm-svn: 232641
Interleave the code for narrow and wide character streams. This makes it
more obvious that the two pieces of code are identical. Furthermore, it
makes it easier to conditionally compile support for certain streams, as
less #ifdef blocks are needed.
Differential Revision: http://reviews.llvm.org/D8342
Reviewed by: marshall
llvm-svn: 232516
Summary:
This patch adds the `<experimental/tuple>` header (almost) as specified in the latest draft of the library fundamentals TS.
The main changes in this patch are:
1. Added variable template `tuple_size_v`
2. Added function `apply(Func &&, Tuple &&)`.
3. Changed `__invoke` to be `_LIBCPP_CONSTEXPR_AFTER_CXX11`.
The `apply(...)` implementation uses `__invoke` to invoke the given function. `__invoke` already provides the required functionality. Using `__invoke` also allows `apply` to be used on pointers to member function/objects as an extension. In order to facilitate this `__invoke` has to be marked `constexpr`.
Test Plan:
Each new feature was tested.
The test cases for `tuple_size_v` are as follows:
1. tuple_size_v.pass.cpp
- Check `tuple_size_v` on cv qualified tuples, pairs and arrays.
2. tuple_size_v.fail.cpp
- Test on reference type.
3. tuple_size_v_2.fail.cpp
- Test on non-tuple
4. tuple_size_v_3.fail.cpp
- Test on pointer type.
The test cases for tuple.apply are as follows:
1. arg_type.pass.cpp
- Ensure that ref/pointer/cv qualified types are properly passed.
2. constexpr_types.pass.cpp
- Ensure constexpr evaluation of apply is possible for `tuple` and `pair`.
3. extended_types.pass.cpp
- Test apply on function types permitted by extension.
4. large_arity.pass.cpp
- Test that apply can evaluated on tuples and arrays with large sizes.
5. ref_qualifiers.pass.cpp
- Test that apply respects ref qualified functions.
6. return_type.pass.cpp
- Test that apply returns the proper type.
7. types.pass.cpp
- Test apply on function types as required by LFTS.
Reviewers: mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D4512
llvm-svn: 232515
Summary:
There is no reason to guard `tuple_size`, `tuple_element` and `get<I>(...)` for pair and array inside of `<__tuple>` so that they are only available when we have variadic templates.
This requires there be redundant declarations and definitions. It also makes it easy to get things wrong.
For example the following code should compile (and does in c++11).
```
#define _LIBCPP_HAS_NO_VARIADICS
#include <array>
int main()
{
static_assert((std::tuple_size<std::array<int, 10> volatile>::value == 10), "");
}
```
This patch lifts the non-variadic parts of `tuple_size`, `tuple_types`, and `get<I>(...)` to the top of `<__tuple>` where they don't require variadic templates. This patch also removes `<__tuple_03>` because there is no longer a need for it.
Reviewers: danalbert, K-ballo, mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D7774
llvm-svn: 232492
In one of the ostream tests we attempt to validate whether the output of
%p is correct. This is actually outside the scope of libc++, for the
%reason that the format of %p is implementation defined. Change the test
%to validate that the output of %p is non-empty and is different when
%given two unequal addresses.
Differential Revision: http://reviews.llvm.org/D8354
Reviewed by: marshall
llvm-svn: 232390
We already have a definition for the Czech locale name in
platform_support.h. Use this one instead.
While there, respect the common format of the tests. For most other
tests it's the case that test_iterators.h is placed right underneath the
other #includes (without an empty line). platform_support.h is included
after an empty line.
llvm-svn: 232383
According to POSIX, *abs() and *div() are allowed to be macros (in
addition to being functions). Make sure we undefine these, so that
std::*abs() and std::*div() work as expected.
llvm-svn: 232379
The rest of the test uses the #defines for the locale names properly. In
this single spot we do hardcode the string. This causes this test to
fail on CloudABI, where this locale is called en_US.UTF-8@UTC.
llvm-svn: 232365
Though common, there is no requirement that fenv_t and fexcept_t are
structure and integer types, respectively. fexcept_t is a structure on
CloudABI.
llvm-svn: 232329
Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of
capability-based security on the way processes can interact with the
filesystem API. It is no longer possible to interact with the VFS
through calls like open(), unlink(), rename(), etc. Instead, processes
are only allowed to interact with files and directories to which they
have been granted access. The *at() functions can be used for this
purpose.
This change adds a new config switch called
_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality
that requires the global filesystem namespace will be disabled. More
concretely:
- fstream's open() function will be removed.
- cstdio will no longer pull in fopen(), rename(), etc.
- The test suite's get_temp_file_name() will be removed. This will cause
all tests that use the global filesystem namespace to break, but will
at least make all the other tests run (as get_temp_file_name will not
build anyway).
It is important to mention that this change will make fstream rather
useless on those systems for now. Still, I'd rather not have fstream
disabled entirely, as it is of course possible to come up with an
extension for fstream that would allow access to local filesystem
namespaces (e.g., by adding an openat() member function).
Differential revision: http://reviews.llvm.org/D8194
Reviewed by: jroelofs (thanks!)
llvm-svn: 232049
This basically reverts the revert in r216508, and fixes a few more cases while
I'm at it. Reading my commit message on that commit again, I think it's bupkis.
http://reviews.llvm.org/D8237
llvm-svn: 231940
On a new platform that I am working on
(https://github.com/NuxiNL/cloudlibc) I am not implementing the
cat{open,close,gets}() API, just like Android, Newlib, etc.
Instead of adding yet another operating system name to the #ifs,
introduce _LIBCPP_HAS_CATOPEN in include/__config. Also adjust the code
to only pull in nl_types.h when _LIBCPP_HAS_CATOPEN is set. We only
needed this header for the cat*() API.
Differential Revision: http://reviews.llvm.org/D8163
Reviewed by: marshall
llvm-svn: 231937
Summary:
The data files for any given test will be in the same directory as the
source with a file name that matches *.dat. To make these available to
tests running remotely (such as over adb or ssh), copy them into the
test's remote working directory.
Note that we will perform more copies than we actually need. The data
files in the directory may only be used by one of the tests, but will
be copied for all tests in the same directory.
This patch also moves the remote test binary into the working
directory (previously it was only invoked from the working directory
rather than existing in it).
Reviewers: EricWF, jroelofs
Reviewed By: jroelofs
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D8118
llvm-svn: 231864
Before I discovered that NetBSD provides a permanent handle to the C
locale called LC_C_LOCALE, I also added support for this to CloudABI
under the name LC_POSIX_LOCALE. I've renamed it to LC_C_LOCALE to
improve compatibility.
llvm-svn: 231780
CloudABI provides the _l() functions that are part of POSIX.1-2008, but
also the extensions that are available on systems like OS X and *BSD
(scanf_l, printf_l, etc).
llvm-svn: 231777
As CloudABI does not provide sysctl(), this header is not present. Make
thread.cpp build correctly (and pass all tests) by not including the header.
llvm-svn: 231768
There are a couple of places where libc++ prints log/error messages to
stdout on its own. This may of course interfere with the output
generated with applications. Log/error messages should be directed to
stderr instead.
Differential Revision: http://reviews.llvm.org/D8135
Reviewed by: marshall
llvm-svn: 231767
Nuxi CloudABI (https://github.com/NuxiNL/cloudlibc) does not allow
processes to access the global filesystem namespace. This breaks
random_device, as it attempts to use /dev/{u,}random. This change adds
support for arc4random(), which is present on CloudABI.
In my opinion it would also make sense to use arc4random() on other
operating systems, such as *BSD and Mac OS X, but I'd rather leave that
to the maintainers of the respective platforms. Switching to
arc4random() does change the ABI.
This change also attempts to make some cleanups to the code. It adds a
single #define for every random interface, instead of testing against
operating systems explicitly.
As discussed, also validate the token argument to be equal to
"/dev/urandom" on all systems that only provide pseudo-random numbers.
This should cause little to no breakage, as "/dev/urandom" is also the
default argument value.
Reviewed by: jfb
Differential Revision: http://reviews.llvm.org/D8134
llvm-svn: 231764
Summary: Fix suggested by @mclow.lists on D8109. Store the size of the un-poisoned vector upon construction instead of calculating it later.
Reviewers: titus, mclow.lists, kcc, EricWF
Reviewed By: EricWF
Subscribers: mclow.lists, cfe-commits
Differential Revision: http://reviews.llvm.org/D8172
llvm-svn: 231729
The _Pp typedef in __tree<_Tp, _Compare, _Allocator>::__count_multi()
isn't used anywhere, so adding _LIBCPP_UNUSED is unecessary.
Differential Revision: http://reviews.llvm.org/D8140
llvm-svn: 231705
On CloudABI we should append the timezone name to the end of the locale
(e.g., nl_NL.UTF-8@Europe/Amsterdam). By fixing the locale names we can
already let a lot of locale related tests pass.
llvm-svn: 231649
The PrefixExecutor wasn't passing the exe_path down the chain, so the
command was overriding that, the work_dir was being passed as the
command, and so on.
I've cleaned up a few pylint issues while I was here.
llvm-svn: 231496
Summary:
This patch add the CMake option `LIBCXX_ENABLE_STATIC_ABI_LIBRARY` which, when enabled, will link libc++ against the static version of the ABI library.
Reviewers: mclow.lists, jroelofs, danalbert
Reviewed By: danalbert
Subscribers: compnerd, cfe-commits
Differential Revision: http://reviews.llvm.org/D8017
llvm-svn: 231076
MSVCRT 12.0 introduces better compatibility for C99. This includes a number of
math routines that were previously undefined. Use the crtversion.h header to
detect the version of MSVCRT being targeted and avoid re-declaring the
variables.
Since copysign has been introduced in MSVCRT, importing the definition via using
makes it difficult to provide overloads (due to minor differences between
throw () and noexcept. Avoid defining the overloads on newer MSVCRT
targets.
llvm-svn: 230867
Executors can be specified at configure time by using the -DLIBCXX_EXECUTOR=""
option. Examples include:
$ cmake <other_flags> -DLIBCXX_EXECUTOR="TimeoutExecutor(30,LocalExecutor())"
This runs individual tests with a maximum duration
$ cmake <other_flags> -DLIBCXX_EXECUTOR="SSHExecutor('hostname','username')"
This runs tests on a remote target, using scp to shuttle binaries to the
target, and ssh to invoke commands there.
$ cmake <other_flags> -DLIBCXX_EXECUTOR="PrefixExecutor('/path/to/run/script',LocalExecutor())"
This assumes the script knows how to copy run the executables passed to it,
and allows for the ultimate control. This is useful for running things
inside emulators like Valgrind & QEMU.
TODO: This doesn't claim to support ShTest tests yet, that will take a bit more
thought & finagling (I'm still not sure how to orchestrate copy-in for those cases.
I've also punted on what to do about tests that read data files. The testsuite
has several tests that need to read *.dat files placed next to them, and
currently those aren't copied over when using, say, an SSHExecutor. The
affected tests are:
libc++ :: std/input.output/file.streams/fstreams/filebuf.virtuals/pbackfail.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.assign/member_swap.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.assign/move_assign.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.assign/nonmember_swap.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.cons/move.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.cons/pointer.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.cons/string.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.members/close.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.members/open_pointer.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.members/open_string.pass.cpp
libc++ :: std/input.output/file.streams/fstreams/ifstream.members/rdbuf.pass.cpp
libc++ :: std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
libc++ :: std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
Note: One thing to watch out for when using the SSHExecutor for cross-testing is
that you'll also want to specify a TargetInfo object (so that the host's
features aren't used for available-features checks and flags setup).
http://reviews.llvm.org/D7380
llvm-svn: 230592
Summary: Newlib supports ctype differently from other platforms, this patch teaches libc++ about yet another platform that does ctype differently.
Reviewers: jroelofs
Subscribers: cfe-commits, danalbert, EricWF, jvoung, jfb, mclow.lists
Differential Revision: http://reviews.llvm.org/D7888
llvm-svn: 230557
Summary:
GCC emits a pretty amusing warning when there are apostrophes in a #warning:
```warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix]```
Reword the warning to avoid this, and be more consistent with other warnings in libc++.
Reviewers: danalbert
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D7818
llvm-svn: 230298
Summary:
Currently parts of the SFINAE on tuples default constructor always gets evaluated even when the default constructor is never called or instantiated. This can cause a hard compile error when a tuple is created with types that do not have a default constructor. Below is a self contained example using a pair like class. This code will not compile but probably should.
```
#include <type_traits>
template <class T>
struct IllFormedDefaultImp {
IllFormedDefaultImp(T x) : value(x) {}
constexpr IllFormedDefaultImp() {}
T value;
};
typedef IllFormedDefaultImp<int &> IllFormedDefault;
template <class T, class U>
struct pair
{
template <bool Dummy = true,
class = typename std::enable_if<
std::is_default_constructible<T>::value
&& std::is_default_constructible<U>::value
&& Dummy>::type
>
constexpr pair() : first(), second() {}
pair(T const & t, U const & u) : first(t), second(u) {}
T first;
U second;
};
int main()
{
int x = 1;
IllFormedDefault v(x);
pair<IllFormedDefault, IllFormedDefault> p(v, v);
}
```
One way to fix this is to use `Dummy` in a more involved way in the constructor SFINAE. The following patch fixes these sorts of hard compile errors for tuple.
Reviewers: mclow.lists, rsmith, K-ballo, EricWF
Reviewed By: EricWF
Subscribers: ldionne, cfe-commits
Differential Revision: http://reviews.llvm.org/D7569
llvm-svn: 230120
Summary:
libc++abi2.exp should be used whenever `cxxabi.h` defines `_LIBCPPABI_VERSION`. This macro was added to libc++abi in 2012 in r149632. For this reason we should use libc++abi2.exp as default unless otherwise specified.
Also when building against an in-tree libc++abi we definitely want to use libc++abi2.exp.
I would love to know what OSX was the last to use libc++abi.exp but I can only test on 10.9.
Reviewers: danalbert, mclow.lists, EricWF
Reviewed By: EricWF
Subscribers: meadori, cfe-commits
Differential Revision: http://reviews.llvm.org/D7773
llvm-svn: 230119
Summary: No declaration for the type `tuple` is given in c++03 or c++98 modes. Mark all tests that use the actual `tuple` type as UNSUPPORTED.
Reviewers: jroelofs, mclow.lists, danalbert
Reviewed By: danalbert
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D5956
llvm-svn: 229808