Commit Graph

176 Commits

Author SHA1 Message Date
Marshall Clow
5b1e87e52d Implement deduction guide for basic_string as described in P0433
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324569 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-08 06:34:03 +00:00
Marshall Clow
088e6015b2 Fix PR#31454 - 'basic_string<T>::push_back() crashes if sizeof(T)>sizeof(long long)'. We were mishandling the small-string optimization calculations for very large 'characters'. This may be an ABI change (change the size of) strings of very large 'characters', but since they never worked, I'm not too concerned.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@324531 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-07 21:30:17 +00:00
Marshall Clow
4bbcce7ef8 Add tests to make sure that <string_view> provides std::size/data/empty in C++17 mode. This is LWG#3009, coming up for a vote in JAX - but we already do it, just don't have tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@323719 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-30 00:47:43 +00:00
Marshall Clow
de0811ac71 Fix the definitions of 'reference' and 'pointer' in string_view that no one uses :-). Thanks to K-ballo for the catch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@321188 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-20 16:31:40 +00:00
Stephan T. Lavavej
8148a70b20 [libcxx] [test] Strip trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@319994 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-07 00:50:23 +00:00
Marshall Clow
cd64646026 Ooops. I checked in a test for a bug I haven't fixed yet. Temporrarily commented it out.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@319693 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-04 20:46:38 +00:00
Marshall Clow
46b4ad5400 Implement P0457R2: 'String Prefix and Suffix Checking' for c++2a
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@319687 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-04 20:11:38 +00:00
Billy Robert O'Neal III
7e250fcdc1 Change (void) casts to TEST_IGNORE_NODISCARD, as requested by Eric. Reviewed as https://reviews.llvm.org/D40065
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318804 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-21 21:37:26 +00:00
Marshall Clow
f1729d90b3 More of P0600 - '[[nodiscard]] in the Library' mark empty() as nodiscard in string, string_view, and the free function std::empty(). Removed tabs from <string_view>, which is why the diff is so big.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318328 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 20:02:27 +00:00
Billy Robert O'Neal III
9ae62c79cc Tolerate [[nodiscard]] annotations in the STL. Reviewed as https://reviews.llvm.org/D39033
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318276 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-15 07:40:37 +00:00
Marshall Clow
76929f6825 Mark string_view's constructor from (ptr,len) as noexcept (an extension). Update the tests to check this (and other noexcept bits
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@316456 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24 16:30:06 +00:00
Marshall Clow
66db4e4fdd Mark string_view literals as 'noexcept'. Fixes PR#25054. Thanks to Pavel K for the bug report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@316439 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24 14:06:00 +00:00
Stephan T. Lavavej
5d5bbc45ab [libcxx] [test] Fix unused local typedef warnings.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@314259 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-26 23:08:43 +00:00
Stephan T. Lavavej
a2f0b51b9a [libcxx] [test] Strip trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@314258 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-26 23:08:41 +00:00
Marshall Clow
0b9db07158 Add even more string_view tests. These found some bugs in the default parameter value for rfind/find_last_of/find_last_not_of
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312693 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07 04:19:32 +00:00
Marshall Clow
cd0354ef44 Another missing string_view test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312691 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07 03:03:48 +00:00
Marshall Clow
e942bb000f Add more string_view tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@312690 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07 02:46:09 +00:00
Stephan T. Lavavej
5d91f314f1 [libcxx] [test] Change comments to say C++ instead of c++. NFC.
This makes them consistent (many comments already used uppercase).

The special REQUIRES, UNSUPPORTED, and XFAIL comments are excluded from this change.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309468 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:35 +00:00
Stephan T. Lavavej
25072f0004 [libcxx] [test] Make files consistently end with newlines, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309465 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:22 +00:00
Stephan T. Lavavej
a686caad20 [libcxx] [test] Untabify, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@309464 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-29 00:55:10 +00:00
Billy Robert O'Neal III
90c1331825 Add asserts that the nullptr is maintained in string erase operations.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@303899 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 19:01:14 +00:00
Eric Fiselier
050bf66723 Remove non-standard basic_string_view::clear() member.
This patch removes the clear() member from <string_view>. The
modifier was removed from the TS before it ever landed in the standard.
There is no reason libc++ should be providing this method.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302869 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12 03:35:53 +00:00
Billy Robert O'Neal III
b5a065c209 Fix possible loss of data warnings on amd64
In T_size_size.pass, there is an explicit template argument to std::min to ask
for unsigned, to avoid type deduction errors. However, C1XX' warnings still
hate this use, because a 64 bit value (a size_t) is being passed to a function
accepting an unsigned (a 32 bit value).

Instead, change the tests to pass around std::size_t instances, and explicitly
narrow when constructing the string type under test. This also allows
removal of explicit template arguments to std::min.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302473 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-08 21:54:53 +00:00
Mehdi Amini
907c1196a7 Add markup for libc++ dylib availability
Libc++ is used as a system library on macOS and iOS (amongst others). In order
for users to be able to compile a binary that is intended to be deployed to an
older version of the platform, clang provides the
availability attribute <https://clang.llvm.org/docs/AttributeReference.html#availability>_
that can be placed on declarations to describe the lifecycle of a symbol in the
library.

See docs/DesignDocs/AvailabilityMarkup.rst for more information.

Differential Revision: https://reviews.llvm.org/D31739

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@302172 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-04 17:08:54 +00:00
Billy Robert O'Neal III
aa22e515ac Resolve unused local typedef warning in test.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300937 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21 01:10:04 +00:00
Eric Fiselier
3e92897754 Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the string library.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300633 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 00:28:44 +00:00
Eric Fiselier
622c7d5846 Fix PR32642 - string::insert and string::append don't work with move_iterator.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@300397 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15 06:49:02 +00:00
Marshall Clow
af552ba05a Implement P0599: 'noexcept for hash functions'. Fix a couple of hash functions (optional<T> and unique_ptr<T>) which were mistakenly marked as 'noexcept'. Reviewed as https://reviews.llvm.org/D31234
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298573 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 02:40:28 +00:00
Marshall Clow
2d4c3fa48a Implement LWG#2761: 'basic_string should require that charT match traits::char_type'. Tests for string_view, too
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@297872 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-15 18:41:11 +00:00
Mehdi Amini
e807cbcd5b Add deployment knobs to tests (for Apple platforms)
The tests for libc++ specify -target on the command-line to the
compiler, but this is problematic for a few reasons.

Firstly, the -target option isn't supported on Apple platforms. Parts
of the triple get dropped and ignored. Instead, software should be
compiled with a combination of the -arch and -m<name>-version-min
options.

Secondly, the generic "darwin" target references a kernel version
instead of a platform version. Each platform has its own independent
versions (with different versions of libc++.1.dylib), independent of the
version of the Darwin kernel.

This commit adds support to the LIT infrastructure for testing against
Apple platforms using -arch and -platform options.

If the host is not on OS X, or the compiler type is not clang or apple-clang, then this commit has NFC.
If the host is on OS X and --param=target_triple=... is specified, then a warning is emitted to use arch and platform instead. Besides the warning, there's NFC.
If the host is on OS X and *no* target-triple is specified, then use the new deployment target logic. This uses two new lit parameters, --param=arch=<arch> and --param=platform=<platform>. <platform> has the form <name>[<version>].
By default, arch is auto-detected from clang -dumpmachine, and platform is "macosx".
If the platform doesn't have a version:
For "macosx", the version is auto-detected from the host system using sw_vers. This may give a different version than the SDK, since new SDKs can be installed on older hosts.
Otherwise, the version is auto-detected from the SDK version using xcrun --show-sdk-path.
-arch <arch> -m<name>-version-min=<version> is added to the compiler flags.
The target triple is computed as <arch>-apple-<platform>. It is *not* passed to clang, but it is available for XFAIL and UNSUPPORTED (as is with_system_cxx_lib=<target>).
For convenience, apple-darwin and <arch>-apple-darwin are added to the set of available features.
There were a number of tests marked to XFAIL on x86_64-apple-darwin11
and x86_64-apple-darwin12. I updated these to
x86_64-apple-macosx10.7 and x86_64-apple-macosx10.8.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@297798 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-15 00:59:54 +00:00
Eric Fiselier
778ec30428 Work around test failure on 32 bit OS X
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@296840 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-02 23:18:40 +00:00
Steven Wu
244033db8b Remove XFAIL in implicit_deduction_guides tests
The clang assertion causing these tests failing with sanitizer is fixed
in r295794. All the bots running libcxx tests should be upgraded and
running the compiler with the fix.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@296385 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-27 21:10:41 +00:00
Eric Fiselier
8c9af4d299 Remove dead code in test
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@295423 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 07:00:04 +00:00
Eric Fiselier
836ae8fa96 add implicit deduction guide tests for string_view
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@295422 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 06:59:11 +00:00
Eric Fiselier
224dbbb3d6 Work around Clang assertion when testing C++17 deduction guides with '-g'.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@295417 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 05:04:09 +00:00
Eric Fiselier
0eaf2e8474 [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.
Summary:
This patch fixes http://llvm.org/PR31938. The description below is copy/pasted from the bug:

The standard says:

template<class charT, class traits = char_traits<charT>,
         class Allocator = allocator<charT>>
class basic_string {
  using value_type = typename traits::char_type;
  // ...
  basic_string(const charT* s, const Allocator& a = Allocator());
};

libc++ actually chooses to declare the constructor as

  basic_string(const value_type* s, const Allocator& a = Allocator());

The implicit deduction guides from class template argument deduction make what was previously an implementation detail visible:

std::basic_string s = "foo"; // error, can't deduce charT.

The constructor in question is in the libc++ DSO, but fortunately it looks like fixing this will not result in an ABI break.


@rsmith How does this look? I did more than just the constructors mentioned in the PR, but IDK how far to take it.


Reviewers: mclow.lists, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, rsmith

Differential Revision: https://reviews.llvm.org/D29863

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@295393 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 01:17:10 +00:00
Stephan T. Lavavej
fdbd18ff71 [libcxx] [test] Strip trailing whitespace.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294161 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:48:27 +00:00
Stephan T. Lavavej
0eb6bb8d2d [libcxx] [test] Fix Clang -Wunused-local-typedef, part 3/3.
test/std/strings/string.classes/typedefs.pass.cpp
Actually test what basic_string's typedefs stand for.

test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
NotDerived and ND were completely unused.

test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp
P2 was mistakenly not being used. Yes, that's
right: -Wunused-local-typedef CAUGHT A MISTAKE! AMAZING!

Fixes D29137.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294156 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:47:54 +00:00
Stephan T. Lavavej
939607910d [libcxx] [test] Fix Clang -Wunused-local-typedef, part 2/3.
These typedefs were completely unused.

Fixes D29136.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294155 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:47:41 +00:00
Stephan T. Lavavej
5597800045 [libcxx] [test] Fix Clang -Wunused-local-typedef, part 1/3.
Guard typedefs and static_asserts with _LIBCPP_VERSION.

test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
Additionally deal with conditional compilation.

test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
Additionally deal with typedefs used by other typedefs.

Fixes D29135.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@294154 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-05 22:47:09 +00:00
Marshall Clow
90b3732f7a Fix up some no-exception compile failures
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@293623 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31 13:12:32 +00:00
Alex Lorenz
cb14d02f6d Workaround new -Wshadow warning introduced by r293599
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@293619 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31 12:37:48 +00:00
Marshall Clow
9247fd2f79 Fix PR#31779: basic_string::operator= isn't exception safe.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@293599 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-31 03:40:52 +00:00
Marshall Clow
b08183bc1f A couple more tests for constexpr stuff in string_view. No changes other than test code.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292943 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 16:28:02 +00:00
Marshall Clow
fbe68a68ab Implement LWG#2778: basic_string_view is missing constexpr.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292823 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-23 19:53:28 +00:00
Eric Fiselier
952eaecfc6 Implement P0513R0 - "Poisoning the Hash"
Summary:
Exactly what the title says.

This patch also adds a `std::hash<nullptr_t>` specialization in C++17, but it was not added by this paper and I can't find the actual paper that adds it.

See http://wg21.link/P0513R0 for more info.

If there are no comments in the next couple of days I'll commit this

Reviewers: mclow.lists, K-ballo, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D28938

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292684 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-21 00:02:12 +00:00
Stephan T. Lavavej
16e2ba19df [libcxx] [test] Fix comment typos, strip trailing whitespace.
No functional change, no code review.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292434 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-18 20:10:25 +00:00
Eric Fiselier
37b2be9c58 Fix std::string assignment ambiguity from braced initializer lists.
When support for `basic_string_view` was added to string it also
added new assignment operators from `basic_string_view`. These caused
ambiguity when assigning from a braced initializer. This patch fixes
that regression by making the basic_string_view assignment operator
rank lower in overload resolution by making it a template.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292276 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 22:10:32 +00:00
Marshall Clow
ce921fa962 Implement P0426: Constexpr for std::char_traits
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291741 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-12 04:37:14 +00:00
Marshall Clow
6b78198fc5 Added XFAIL for the apple versions of clang as well
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291475 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-09 20:29:28 +00:00