Compare commits

..

4 Commits
w64 ... clang

Author SHA1 Message Date
NAKAMURA Takumi
307c285079 Merge remote branch 'llvm.org/master' into clang 2011-05-09 12:27:44 +09:00
Nick Kledzik
d982028b92 change RC_BUILDIT to RC_XBS for detecting Apple build environment
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@130970 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-06 01:13:20 +00:00
Nick Kledzik
ffadfd4c1e add support for setjmp/longjmp based exceptions
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@130938 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-05 18:45:41 +00:00
Nick Kledzik
c6e08d6c44 <rdar://problem/9014045> more support for Apple internal build environments
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@130872 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-04 21:50:46 +00:00
633 changed files with 85263 additions and 444 deletions

View File

@@ -13,13 +13,6 @@
#pragma GCC system_header
#ifdef __MINGW32__
#include <yvals.h>
#undef _STD
#undef _C2
#define _LIBCPP_VISIBILITY_TAG 0
#endif
#define _LIBCPP_VERSION 1000
#define _LIBCPP_ABI_VERSION 1
@@ -54,11 +47,6 @@
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
#endif // __FreeBSD__
#if !defined(_LIBCPP_LITTLE_ENDIAN) && (defined(__i386__) || defined(__x86_64__))
#define _LIBCPP_LITTLE_ENDIAN 1
#define _LIBCPP_BIG_ENDIAN 0
#endif
#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
# include <endian.h>
# if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -110,7 +98,7 @@ typedef __char32_t char32_t;
#endif
#endif
#if !(__has_feature(cxx_exceptions)) || defined(__MINGW32__)
#if !(__has_feature(cxx_exceptions))
#define _LIBCPP_NO_EXCEPTIONS
#endif

View File

@@ -19,21 +19,7 @@
#include <cstdint>
#include <cctype>
#include <locale.h>
#ifdef __MINGW32__
typedef _locale_t locale_t;
#include <xlocinfo.h>
#define LC_COLLATE_MASK _M_COLLATE
#define LC_CTYPE_MASK _M_CTYPE
#define LC_MONETARY_MASK _M_MONETARY
#define LC_NUMERIC_MASK _M_NUMERIC
#define LC_TIME_MASK _M_TIME
#define LC_MESSAGES_MASK _M_MESSAGES
#define LC_ALL_MASK _M_ALL
#else
#include <xlocale.h>
#endif
#pragma GCC system_header
@@ -316,7 +302,7 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
class _LIBCPP_VISIBLE ctype_base
{
public:
typedef std::uint32_t mask;
typedef __uint32_t mask;
#if __APPLE__
static const mask space = _CTYPE_S;
@@ -329,17 +315,6 @@ public:
static const mask punct = _CTYPE_P;
static const mask xdigit = _CTYPE_X;
static const mask blank = _CTYPE_B;
#elif defined(__MINGW32__)
static const mask space = _SPACE;
static const mask print = (_BLANK|_PUNCT|_ALPHA|_DIGIT);
static const mask cntrl = _CONTROL;
static const mask upper = _UPPER;
static const mask lower = _LOWER;
static const mask alpha = _ALPHA;
static const mask digit = _DIGIT;
static const mask punct = _PUNCT;
static const mask xdigit = _HEX;
static const mask blank = _BLANK;
#else // __APPLE__
static const mask space = _ISspace;
static const mask print = _ISprint;
@@ -476,7 +451,7 @@ public:
_LIBCPP_ALWAYS_INLINE
bool is(mask __m, char_type __c) const
{
return isascii(__c) ? (__tab_ ? __tab_[__c] & __m : _isctype(__c, __m)) : false;
return isascii(__c) ? (__tab_ ? __tab_[__c] & __m : isctype(__c, __m)) : false;
}
_LIBCPP_ALWAYS_INLINE

View File

@@ -14,35 +14,7 @@
#include <__config>
#include <chrono>
#include <system_error>
#ifdef __MINGW32__
typedef unsigned pthread_t;
typedef unsigned pthread_mutex_t;
typedef unsigned pthread_mutexattr_t;
typedef unsigned pthread_cond_t;
typedef unsigned pthread_key_t;
#define PTHREAD_MUTEX_INITIALIZER 0
#define PTHREAD_COND_INITIALIZER 0
#define PTHREAD_MUTEX_RECURSIVE 0
#define pthread_mutex_init(a,b) (*(a) = 0, -1)
#define pthread_mutex_destroy(a) (-1)
#define pthread_mutex_lock(a) (-1)
#define pthread_mutex_trylock(a) (-1)
#define pthread_mutex_unlock(a) (-1)
#define pthread_mutexattr_settype(a,b) (*(a) = (b), -1)
#define pthread_mutexattr_init(a) (*(a) = 0, -1)
#define pthread_mutexattr_destroy(a) (-1)
#define pthread_self() (-1)
#define pthread_equal(a,b) (0)
#define pthread_getspecific(a) ((void*)0)
#define pthread_cond_destroy(a) (-1)
#define pthread_cond_signal(a) (-1)
#define pthread_cond_broadcast(a) (-1)
#define pthread_cond_wait(a,b) (-1)
#define pthread_cond_timedwait(a,b,c) (-1)
#define sched_yield() (-1)
#else
#include <pthread.h>
#endif
#pragma GCC system_header

View File

@@ -173,11 +173,6 @@ typedef basic_fstream<wchar_t> wfstream;
#pragma GCC system_header
#ifdef _WIN32
#define fseeko fseek
#define ftello ftell
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits>

View File

@@ -186,10 +186,7 @@ template <class charT> class messages_byname;
#endif
#include <cstdlib>
#include <ctime>
#ifndef _WIN32
#include <nl_types.h>
#endif
#pragma GCC system_header
@@ -306,14 +303,7 @@ __nolocale_asprintf(char** __ret,
{
va_list __ap;
va_start(__ap, __format);
int __result;
#ifdef _WIN32
*__ret = (char*)malloc(4096);
__result = vsprintf(*__ret, __format, __ap);
*__ret = (char*)realloc(*__ret, __result + 1);
#else
__result = vasprintf(__ret, __format, __ap);
#endif
int __result = vasprintf(__ret, __format, __ap);
va_end(__ap);
return __result;
}
@@ -758,12 +748,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end,
int __save_errno = errno;
errno = 0;
char *__p2;
long long __ll;
#ifdef _WIN32
__ll = _strtoi64_l(__a, &__p2, __base, 0);
#else
__ll = strtoll_l(__a, &__p2, __base, 0);
#endif
long long __ll = strtoll_l(__a, &__p2, __base, 0);
int __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
@@ -803,12 +788,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
int __save_errno = errno;
errno = 0;
char *__p2;
unsigned long long __ll;
#ifdef _WIN32
__ll = _strtoui64_l(__a, &__p2, __base, 0);
#else
__ll = strtoull_l(__a, &__p2, __base, 0);
#endif
unsigned long long __ll = strtoull_l(__a, &__p2, __base, 0);
int __current_errno = errno;
if (__current_errno == 0)
errno = __save_errno;
@@ -836,13 +816,7 @@ __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
if (__a != __a_end)
{
char *__p2;
long double __ld;
#ifdef _WIN32
// Win32 does not use "long double".
__ld = _strtod_l(__a, &__p2, 0);
#else
__ld = strtold_l(__a, &__p2, 0);
#endif
long double __ld = strtold_l(__a, &__p2, 0);
if (__p2 != __a_end)
{
__err = ios_base::failbit;
@@ -1702,17 +1676,11 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
template <class _CharT, class _OutputIterator>
_OutputIterator
num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
char_type __fl, long double __lv) const
char_type __fl, long double __v) const
{
// Stage 1 - Get number in narrow char
char __fmt[8] = {'%', 0};
#ifdef _WIN32
const char* __len = "";
double __v = __lv;
#else
const char* __len = "L";
long double __v = __lv;
#endif
bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags());
const unsigned __nbuf = 30;
char __nar[__nbuf];
@@ -3597,14 +3565,10 @@ template <class _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
{
#ifdef __MINGW32__
return -1;
#else
catalog __cat = reinterpret_cast<catalog>(catopen(__nm.c_str(), NL_CAT_LOCALE));
if (__cat != -1)
__cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
return __cat;
#endif
}
template <class _CharT>
@@ -3612,10 +3576,6 @@ typename messages<_CharT>::string_type
messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
const string_type& __dflt) const
{
#ifdef __MINGW32__
string_type __w;
return __w;
#else
string __ndflt;
__narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
__dflt.c_str(),
@@ -3628,19 +3588,16 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
__widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
__n, __n + strlen(__n));
return __w;
#endif
}
template <class _CharT>
void
messages<_CharT>::do_close(catalog __c) const
{
#ifndef __MINGW32__
if (__c != -1)
__c <<= 1;
nl_catd __cat = reinterpret_cast<nl_catd>(__c);
catclose(__cat);
#endif
}
extern template class messages<char>;

View File

@@ -90,18 +90,6 @@ _LIBCPP_VISIBLE new_handler get_new_handler() throw();
} // std
#if __APPLE__
#include <cxxabi.h>
// On Darwin, there are two STL shared libraries and a lower level ABI
// shared libray. The global holding the current new handler is
// in the ABI library and named __cxa_new_handler.
#define __new_handler __cxxabiapple::__cxa_new_handler
#else // __APPLE__
_LIBCPP_BEGIN_NAMESPACE_STD
extern ::std::new_handler __new_handler;
_LIBCPP_END_NAMESPACE_STD
#endif
_LIBCPP_VISIBLE void* operator new(std::size_t) throw(std::bad_alloc);
_LIBCPP_VISIBLE void* operator new(std::size_t, const std::nothrow_t&) throw();
_LIBCPP_VISIBLE void operator delete(void*) throw();

View File

@@ -115,22 +115,22 @@ public:
enum class errc
{
// address_family_not_supported, // EAFNOSUPPORT
// address_in_use, // EADDRINUSE
// address_not_available, // EADDRNOTAVAIL
// already_connected, // EISCONN
address_family_not_supported, // EAFNOSUPPORT
address_in_use, // EADDRINUSE
address_not_available, // EADDRNOTAVAIL
already_connected, // EISCONN
argument_list_too_long, // E2BIG
argument_out_of_domain, // EDOM
bad_address, // EFAULT
bad_file_descriptor, // EBADF
// bad_message, // EBADMSG
bad_message, // EBADMSG
broken_pipe, // EPIPE
// connection_aborted, // ECONNABORTED
// connection_already_in_progress, // EALREADY
// connection_refused, // ECONNREFUSED
// connection_reset, // ECONNRESET
connection_aborted, // ECONNABORTED
connection_already_in_progress, // EALREADY
connection_refused, // ECONNREFUSED
connection_reset, // ECONNRESET
cross_device_link, // EXDEV
// destination_address_required, // EDESTADDRREQ
destination_address_required, // EDESTADDRREQ
device_or_resource_busy, // EBUSY
directory_not_empty, // ENOTEMPTY
executable_format_error, // ENOEXEC
@@ -138,8 +138,8 @@ enum class errc
file_too_large, // EFBIG
filename_too_long, // ENAMETOOLONG
function_not_supported, // ENOSYS
// host_unreachable, // EHOSTUNREACH
// identifier_removed, // EIDRM
host_unreachable, // EHOSTUNREACH
identifier_removed, // EIDRM
illegal_byte_sequence, // EILSEQ
inappropriate_io_control_operation, // ENOTTY
interrupted, // EINTR
@@ -147,16 +147,16 @@ enum class errc
invalid_seek, // ESPIPE
io_error, // EIO
is_a_directory, // EISDIR
// message_size, // EMSGSIZE
// network_down, // ENETDOWN
// network_reset, // ENETRESET
// network_unreachable, // ENETUNREACH
// no_buffer_space, // ENOBUFS
message_size, // EMSGSIZE
network_down, // ENETDOWN
network_reset, // ENETRESET
network_unreachable, // ENETUNREACH
no_buffer_space, // ENOBUFS
no_child_process, // ECHILD
// no_link, // ENOLINK
no_link, // ENOLINK
no_lock_available, // ENOLCK
no_message_available, // ENODATA
// no_message, // ENOMSG
no_message, // ENOMSG
no_protocol_option, // ENOPROTOOPT
no_space_on_device, // ENOSPC
no_stream_resources, // ENOSR
@@ -246,42 +246,22 @@ struct _LIBCPP_VISIBLE is_error_condition_enum
struct errc
{
enum _ {
#ifdef EAFNOSUPPORT
address_family_not_supported = EAFNOSUPPORT,
#endif
#ifdef EADDRINUSE
address_in_use = EADDRINUSE,
#endif
#ifdef EADDRNOTAVAIL
address_not_available = EADDRNOTAVAIL,
#endif
#ifdef EISCONN
already_connected = EISCONN,
#endif
argument_list_too_long = E2BIG,
argument_out_of_domain = EDOM,
bad_address = EFAULT,
bad_file_descriptor = EBADF,
#ifdef EBADMSG
bad_message = EBADMSG,
#endif
broken_pipe = EPIPE,
#ifdef ECONNABORTED
connection_aborted = ECONNABORTED,
#endif
#ifdef EALREADY
connection_already_in_progress = EALREADY,
#endif
#ifdef ECONNREFUSED
connection_refused = ECONNREFUSED,
#endif
#ifdef ECONNRESET
connection_reset = ECONNRESET,
#endif
cross_device_link = EXDEV,
#ifdef EDESTADDRREQ
destination_address_required = EDESTADDRREQ,
#endif
device_or_resource_busy = EBUSY,
directory_not_empty = ENOTEMPTY,
executable_format_error = ENOEXEC,
@@ -289,12 +269,8 @@ enum _ {
file_too_large = EFBIG,
filename_too_long = ENAMETOOLONG,
function_not_supported = ENOSYS,
#ifdef EHOSTUNREACH
host_unreachable = EHOSTUNREACH,
#endif
#ifdef EIDRM
identifier_removed = EIDRM,
#endif
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
interrupted = EINTR,
@@ -302,37 +278,21 @@ enum _ {
invalid_seek = ESPIPE,
io_error = EIO,
is_a_directory = EISDIR,
#ifdef EMSGSIZE
message_size = EMSGSIZE,
#endif
#ifdef ENETDOWN
network_down = ENETDOWN,
#endif
#ifdef ENETRESET
network_reset = ENETRESET,
#endif
#ifdef ENETUNREACH
network_unreachable = ENETUNREACH,
#endif
#ifdef ENOBUFS
no_buffer_space = ENOBUFS,
#endif
no_child_process = ECHILD,
#ifdef ENOLINK
no_link = ENOLINK,
#endif
no_lock_available = ENOLCK,
#ifdef ENOMSG
#ifdef ENODATA
no_message_available = ENODATA,
#else
no_message_available = ENOMSG,
#endif
no_message = ENOMSG,
#endif
#ifdef ENOPROTOOPT,
no_protocol_option = ENOPROTOOPT,
#endif
no_space_on_device = ENOSPC,
#ifdef ENOSR
no_stream_resources = ENOSR,
@@ -344,42 +304,24 @@ enum _ {
no_such_file_or_directory = ENOENT,
no_such_process = ESRCH,
not_a_directory = ENOTDIR,
#ifdef ENOTSOCK
not_a_socket = ENOTSOCK,
#endif
#ifdef ENOSTR
not_a_stream = ENOSTR,
#else
not_a_stream = EINVAL,
#endif
#ifdef ENOTCONN
not_connected = ENOTCONN,
#endif
not_enough_memory = ENOMEM,
#ifdef ENOTSUP
not_supported = ENOTSUP,
#endif
#ifdef ECANCELED
operation_canceled = ECANCELED,
#endif
#ifdef EINPROGRESS
operation_in_progress = EINPROGRESS,
#endif
operation_not_permitted = EPERM,
#ifdef EOPNOTSUPP
operation_not_supported = EOPNOTSUPP,
#endif
#ifdef EWOULDBLOCK
operation_would_block = EWOULDBLOCK,
#endif
owner_dead = EOWNERDEAD,
permission_denied = EACCES,
#ifdef EPROTO
protocol_error = EPROTO,
#endif
#ifdef EPROTONOSUPPORT
protocol_not_supported = EPROTONOSUPPORT,
#endif
read_only_file_system = EROFS,
resource_deadlock_would_occur = EDEADLK,
resource_unavailable_try_again = EAGAIN,
@@ -387,27 +329,17 @@ enum _ {
state_not_recoverable = ENOTRECOVERABLE,
#ifdef ETIME
stream_timeout = ETIME,
#elif defined(ETIMEDOUT)
#else
stream_timeout = ETIMEDOUT,
#endif
#ifdef ETXTBSY
text_file_busy = ETXTBSY,
#endif
#ifdef ETIMEDOUT
timed_out = ETIMEDOUT,
#endif
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
#ifdef ELOOP
too_many_symbolic_link_levels = ELOOP,
#endif
#ifdef EOVERFLOW
value_too_large = EOVERFLOW,
#endif
#ifdef EPROTOTYPE
wrong_protocol_type = EPROTOTYPE,
#endif
wrong_protocol_type = EPROTOTYPE
};
_ __v_;

View File

@@ -95,15 +95,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
#include <system_error>
#include <chrono>
#include <__mutex_base>
#ifdef __MINGW32__
#define pthread_key_delete(a) (-1)
#define pthread_join(a,b) (-1)
#define pthread_detach(a) (-1)
#define nanosleep(a,b) (-1)
#define pthread_key_create(a,b) (-1)
#else
#include <pthread.h>
#endif
#pragma GCC system_header

View File

@@ -32,7 +32,7 @@ append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
target_link_libraries(cxx ${libraries})
# Setup flags.
#append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC)
append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC)
append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
set_target_properties(cxx

View File

@@ -17,6 +17,11 @@ then
CXX=clang++
fi
if [ -z "$CC" ]
then
CC=clang
fi
if [ -z $MACOSX_DEPLOYMENT_TARGET ]
then
MACOSX_DEPLOYMENT_TARGET=10.6
@@ -29,7 +34,7 @@ fi
case $TRIPLE in
*-apple-*)
if [ -z $RC_BUILDIT ]
if [ -z $RC_XBS ]
then
RC_CFLAGS="-arch i386 -arch x86_64"
fi
@@ -45,16 +50,24 @@ case $TRIPLE in
-Wl,-unexported_symbols_list,libc++unexp.exp \
/usr/lib/libSystem.B.dylib"
else
EXTRA_FLAGS="-std=c++0x"
LDSHARED_FLAGS="-o libc++.1.dylib \
EXTRA_FLAGS="-std=c++0x "
RE_EXPORT_FILE="libc++abi.exp"
if [ -n "$SDKROOT" ]
then
EXTRA_FLAGS+="-isysroot ${SDKROOT}"
RE_EXPORT_FILE="libc++sjlj-abi.exp"
CXX=`xcrun -sdk "${SDKROOT}" -find clang++`
CC=`xcrun -sdk "${SDKROOT}" -find clang`
fi
LDSHARED_FLAGS="-o libc++.1.dylib \
-dynamiclib -nodefaultlibs \
-current_version ${RC_ProjectSourceVersion} -compatibility_version 1 \
-install_name /usr/lib/libc++.1.dylib \
${SDKROOT}/usr/lib/libc++abi.dylib \
-lSystem \
-Wl,-unexported_symbols_list,libc++unexp.exp \
-Wl,-reexported_symbols_list,libc++abi.exp \
-Wl,-force_symbols_not_weak_list,notweak.exp"
-Wl,-reexported_symbols_list,${RE_EXPORT_FILE} \
-Wl,-force_symbols_not_weak_list,notweak.exp "
fi
;;
*)
@@ -66,7 +79,7 @@ case $TRIPLE in
;;
esac
if [ -z $RC_BUILDIT ]
if [ -z $RC_XBS ]
then
rm -f libc++.1.$SOEXT*
fi
@@ -78,11 +91,11 @@ for FILE in ../src/*.cpp; do
done
cc *.o $RC_CFLAGS $LDSHARED_FLAGS
$CC *.o $RC_CFLAGS $LDSHARED_FLAGS $EXTRA_FLAGS
#libtool -static -o libc++.a *.o
if [ -z $RC_BUILDIT ]
if [ -z $RC_XBS ]
then
rm *.o
fi

159
lib/libc++sjlj-abi.exp Normal file
View File

@@ -0,0 +1,159 @@
___cxa_allocate_exception
___cxa_end_catch
___cxa_demangle
___cxa_current_exception_type
___cxa_call_unexpected
___cxa_free_exception
___cxa_get_exception_ptr
___cxa_get_globals
___cxa_get_globals_fast
___cxa_guard_abort
___cxa_guard_acquire
___cxa_guard_release
___cxa_rethrow
___cxa_pure_virtual
___cxa_begin_catch
___cxa_throw
___cxa_vec_cctor
___cxa_vec_cleanup
___cxa_vec_ctor
___cxa_vec_delete
___cxa_vec_delete2
___cxa_vec_delete3
___cxa_vec_dtor
___cxa_vec_new
___cxa_vec_new2
___cxa_vec_new3
___dynamic_cast
___gxx_personality_sj0
#__ZTIDi
#__ZTIDn
#__ZTIDs
#__ZTIPDi
#__ZTIPDn
#__ZTIPDs
#__ZTIPKDi
#__ZTIPKDn
#__ZTIPKDs
__ZTSPm
__ZTSPl
__ZTSPj
__ZTSPi
__ZTSPh
__ZTSPf
__ZTSPe
__ZTSPd
__ZTSPc
__ZTSPb
__ZTSPa
__ZTSPKc
__ZTSPKy
__ZTSPKx
__ZTSPKw
__ZTSPKv
__ZTSPKt
__ZTSPKs
__ZTSPKm
__ZTSPKl
__ZTSPKi
__ZTSPKh
__ZTSPs
__ZTSPt
__ZTSPv
__ZTSPw
__ZTSPKa
__ZTSPx
__ZTSPy
__ZTSPKd
__ZTSPKe
__ZTSPKj
__ZTSPKb
__ZTSPKf
__ZTSv
__ZTSt
__ZTSs
__ZTSm
__ZTSl
__ZTSj
__ZTSi
__ZTSh
__ZTSf
__ZTSe
__ZTSd
__ZTSc
__ZTSw
__ZTSx
__ZTSy
__ZTSb
__ZTSa
__ZTIPKh
__ZTIPKf
__ZTIPKe
__ZTIPKd
__ZTIPKc
__ZTIPKb
__ZTIPKa
__ZTIPy
__ZTIPx
__ZTIPw
__ZTIPv
__ZTIPt
__ZTIPs
__ZTIPm
__ZTIPl
__ZTIPj
__ZTIPi
__ZTIPKi
__ZTIPKj
__ZTIPKl
__ZTIPKm
__ZTIPKs
__ZTIPKt
__ZTIPKv
__ZTIPKw
__ZTIPKx
__ZTIPKy
__ZTIPa
__ZTIPb
__ZTIPc
__ZTIPd
__ZTIPe
__ZTIPf
__ZTIPh
__ZTVN10__cxxabiv129__pointer_to_member_type_infoE
__ZTVN10__cxxabiv116__enum_type_infoE
__ZTVN10__cxxabiv117__array_type_infoE
__ZTVN10__cxxabiv117__class_type_infoE
__ZTVN10__cxxabiv117__pbase_type_infoE
__ZTVN10__cxxabiv119__pointer_type_infoE
__ZTVN10__cxxabiv120__function_type_infoE
__ZTVN10__cxxabiv120__si_class_type_infoE
__ZTVN10__cxxabiv121__vmi_class_type_infoE
__ZTVN10__cxxabiv123__fundamental_type_infoE
__ZTIa
__ZTIb
__ZTIc
__ZTId
__ZTIe
__ZTIf
__ZTIh
__ZTIi
__ZTIj
__ZTIl
__ZTIm
__ZTIs
__ZTIt
__ZTSN10__cxxabiv129__pointer_to_member_type_infoE
__ZTSN10__cxxabiv123__fundamental_type_infoE
__ZTSN10__cxxabiv121__vmi_class_type_infoE
__ZTSN10__cxxabiv120__si_class_type_infoE
__ZTSN10__cxxabiv120__function_type_infoE
__ZTSN10__cxxabiv119__pointer_type_infoE
__ZTSN10__cxxabiv117__pbase_type_infoE
__ZTSN10__cxxabiv117__class_type_infoE
__ZTSN10__cxxabiv117__array_type_infoE
__ZTSN10__cxxabiv116__enum_type_infoE
__ZTIy
__ZTIx
__ZTIw
__ZTIv

View File

@@ -116,16 +116,10 @@ steady_clock::now()
steady_clock::time_point
steady_clock::now()
{
#ifdef __MINGW32__
timeval tv;
gettimeofday(&tv, 0);
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
#else
struct timespec tp;
if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
#endif
}
#endif // __APPLE__

View File

@@ -57,10 +57,8 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
ts.tv_sec = static_cast<decltype(ts.tv_sec)>(s.count());
ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
#ifndef __MINGW32__
if (ec != 0 && ec != ETIMEDOUT)
__throw_system_error(ec, "condition_variable timed_wait failed");
#endif
}
void

View File

@@ -77,9 +77,6 @@ std::terminate()
bool std::uncaught_exception() throw()
{
#ifdef _LIBCPP_NO_EXCEPTIONS
return false;
#endif
#if __APPLE__
// on Darwin, there is a helper function so __cxa_get_globals is private
return __cxxabiapple::__cxa_uncaught_exception();

View File

@@ -18,20 +18,7 @@
#include "cstring"
#include "cwctype"
#include "__sso_allocator"
#ifdef __MINGW32__
#define iswctype_l _iswctype_l
#define strcoll_l _strcoll_l
#define strftime_l(a,b,c,d,e) strftime(a,b,c,d)
#define strxfrm_l _strxfrm_l
#define tolower_l _tolower_l
#define toupper_l _toupper_l
#define towlower_l _towlower_l
#define towupper_l _towupper_l
#define wcscoll_l _wcscoll_l
#define wcsxfrm_l _wcsxfrm_l
#else
#include <langinfo.h>
#endif
#include <stdlib.h>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -574,22 +561,6 @@ locale::id::__init()
// template <> class collate_byname<char>
static inline
locale_t newlocale(int m, const char *l, locale_t b) {
#if 0
return _create_locale(LC_ALL, l);
#else
return 0;
#endif
}
static inline
void freelocale(locale_t p) {
#if 0 // why!
_free_locale(p);
#endif
}
collate_byname<char>::collate_byname(const char* n, size_t refs)
: collate<char>(refs),
__l(newlocale(LC_ALL_MASK, n, 0))
@@ -1388,9 +1359,6 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
for (extern_type* p = tmp; n; --n) // write it
*to_nxt++ = *p++;
return ok;
#elif defined(_WIN32)
to_nxt = to;
return noconv;
#else
return error;
#endif

View File

@@ -18,16 +18,110 @@
// in the ABI library and named __cxa_new_handler.
#define __new_handler __cxxabiapple::__cxa_new_handler
#else // __APPLE__
_LIBCPP_BEGIN_NAMESPACE_STD
::std::new_handler __new_handler;
_LIBCPP_END_NAMESPACE_STD
static std::new_handler __new_handler;
#endif
#if 0
// Implement all new and delete operators as weak definitions
// in this shared library, so that they can be overriden by programs
// that define non-weak copies of the functions.
__attribute__((__weak__, __visibility__("default")))
void *
operator new(std::size_t size) throw (std::bad_alloc)
{
if (size == 0)
size = 1;
void* p;
while ((p = ::malloc(size)) == 0)
{
// If malloc fails and there is a new_handler,
// call it to try free up memory.
std::new_handler nh = std::get_new_handler();
if (nh)
nh();
else
#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
#else
break;
#endif
}
return p;
}
__attribute__((__weak__, __visibility__("default")))
void*
operator new(size_t size, const std::nothrow_t&) throw()
{
void* p = 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
p = ::operator new(size);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
#endif // _LIBCPP_NO_EXCEPTIONS
return p;
}
__attribute__((__weak__, __visibility__("default")))
void*
operator new[](size_t size) throw (std::bad_alloc)
{
return ::operator new(size);
}
__attribute__((__weak__, __visibility__("default")))
void*
operator new[](size_t size, const std::nothrow_t& nothrow) throw()
{
void* p = 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
p = ::operator new[](size);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
#endif // _LIBCPP_NO_EXCEPTIONS
return p;
}
__attribute__((__weak__, __visibility__("default")))
void
operator delete(void* ptr) throw ()
{
if (ptr)
::free(ptr);
}
__attribute__((__weak__, __visibility__("default")))
void
operator delete(void* ptr, const std::nothrow_t&) throw ()
{
::operator delete(ptr);
}
__attribute__((__weak__, __visibility__("default")))
void
operator delete[] (void* ptr) throw ()
{
::operator delete (ptr);
}
__attribute__((__weak__, __visibility__("default")))
void
operator delete[] (void* ptr, const std::nothrow_t&) throw ()
{
::operator delete[](ptr);
}
namespace std
{

View File

@@ -1,7 +0,0 @@
#include "new"
void
operator delete[] (void* ptr) throw ()
{
::operator delete (ptr);
}

View File

@@ -1,7 +0,0 @@
#include "new"
void
operator delete[] (void* ptr, const std::nothrow_t&) throw ()
{
::operator delete[](ptr);
}

View File

@@ -1,10 +0,0 @@
#include <stdlib.h>
#include "new"
void
operator delete(void* ptr) throw ()
{
if (ptr)
::free(ptr);
}

View File

@@ -1,7 +0,0 @@
#include "new"
void
operator delete(void* ptr, const std::nothrow_t&) throw ()
{
::operator delete(ptr);
}

View File

@@ -1,7 +0,0 @@
#include "new"
void*
operator new[](size_t size) throw (std::bad_alloc)
{
return ::operator new(size);
}

View File

@@ -1,19 +0,0 @@
#include "new"
void*
operator new[](size_t size, const std::nothrow_t& nothrow) throw()
{
void* p = 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
p = ::operator new[](size);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
#endif // _LIBCPP_NO_EXCEPTIONS
return p;
}

View File

@@ -1,26 +0,0 @@
#include <stdlib.h>
#include "new"
void *
operator new(std::size_t size) throw (std::bad_alloc)
{
if (size == 0)
size = 1;
void* p;
while ((p = ::malloc(size)) == 0)
{
// If malloc fails and there is a new_handler,
// call it to try free up memory.
std::new_handler nh = std::get_new_handler();
if (nh)
nh();
else
#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc();
#else
break;
#endif
}
return p;
}

View File

@@ -1,19 +0,0 @@
#include "new"
void*
operator new(size_t size, const std::nothrow_t&) throw()
{
void* p = 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
p = ::operator new(size);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
#endif // _LIBCPP_NO_EXCEPTIONS
return p;
}

View File

@@ -7,17 +7,11 @@
//
//===----------------------------------------------------------------------===//
#define MINGW_HAS_SECURE_API
#include "string"
#include "cstdlib"
#include "cwchar"
#include "cerrno"
#ifdef _WIN32
#define swprintf swprintf_s
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template class __basic_string_common<true>;

View File

@@ -12,10 +12,7 @@
#include "vector"
#include "future"
#include <sys/types.h>
#ifdef __MINGW32__
#else
#include <sys/sysctl.h>
#endif
_LIBCPP_BEGIN_NAMESPACE_STD

View File

@@ -1,15 +0,0 @@
#include <windows.h>
namespace {
class Win32ctor {
public:
Win32ctor() {
SetErrorMode(SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX);
}
};
static Win32ctor ctor;
}

View File

@@ -0,0 +1,341 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// test <cerrno>
#include <cerrno>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
#ifndef E2BIG
#error E2BIG not defined
#endif
#ifndef EACCES
#error EACCES not defined
#endif
#ifndef EACCES
#error EACCES not defined
#endif
#ifndef EADDRINUSE
#error EADDRINUSE not defined
#endif
#ifndef EADDRNOTAVAIL
#error EADDRNOTAVAIL not defined
#endif
#ifndef EAFNOSUPPORT
#error EAFNOSUPPORT not defined
#endif
#ifndef EAGAIN
#error EAGAIN not defined
#endif
#ifndef EALREADY
#error EALREADY not defined
#endif
#ifndef EBADF
#error EBADF not defined
#endif
#ifndef EBADMSG
#error EBADMSG not defined
#endif
#ifndef EBUSY
#error EBUSY not defined
#endif
#ifndef ECANCELED
#error ECANCELED not defined
#endif
#ifndef ECHILD
#error ECHILD not defined
#endif
#ifndef ECONNABORTED
#error ECONNABORTED not defined
#endif
#ifndef ECONNREFUSED
#error ECONNREFUSED not defined
#endif
#ifndef ECONNRESET
#error ECONNRESET not defined
#endif
#ifndef EDEADLK
#error EDEADLK not defined
#endif
#ifndef EDESTADDRREQ
#error EDESTADDRREQ not defined
#endif
#ifndef EDOM
#error EDOM not defined
#endif
#ifndef EEXIST
#error EEXIST not defined
#endif
#ifndef EFAULT
#error EFAULT not defined
#endif
#ifndef EFBIG
#error EFBIG not defined
#endif
#ifndef EHOSTUNREACH
#error EHOSTUNREACH not defined
#endif
#ifndef EIDRM
#error EIDRM not defined
#endif
#ifndef EILSEQ
#error EILSEQ not defined
#endif
#ifndef EINPROGRESS
#error EINPROGRESS not defined
#endif
#ifndef EINTR
#error EINTR not defined
#endif
#ifndef EINVAL
#error EINVAL not defined
#endif
#ifndef EIO
#error EIO not defined
#endif
#ifndef EISCONN
#error EISCONN not defined
#endif
#ifndef EISDIR
#error EISDIR not defined
#endif
#ifndef ELOOP
#error ELOOP not defined
#endif
#ifndef EMFILE
#error EMFILE not defined
#endif
#ifndef EMLINK
#error EMLINK not defined
#endif
#ifndef EMSGSIZE
#error EMSGSIZE not defined
#endif
#ifndef ENAMETOOLONG
#error ENAMETOOLONG not defined
#endif
#ifndef ENETDOWN
#error ENETDOWN not defined
#endif
#ifndef ENETRESET
#error ENETRESET not defined
#endif
#ifndef ENETUNREACH
#error ENETUNREACH not defined
#endif
#ifndef ENFILE
#error ENFILE not defined
#endif
#ifndef ENOBUFS
#error ENOBUFS not defined
#endif
#ifndef ENODATA
#error ENODATA not defined
#endif
#ifndef ENODEV
#error ENODEV not defined
#endif
#ifndef ENOENT
#error ENOENT not defined
#endif
#ifndef ENOEXEC
#error ENOEXEC not defined
#endif
#ifndef ENOLCK
#error ENOLCK not defined
#endif
#ifndef ENOLINK
#error ENOLINK not defined
#endif
#ifndef ENOMEM
#error ENOMEM not defined
#endif
#ifndef ENOMSG
#error ENOMSG not defined
#endif
#ifndef ENOPROTOOPT
#error ENOPROTOOPT not defined
#endif
#ifndef ENOSPC
#error ENOSPC not defined
#endif
#ifndef ENOSR
#error ENOSR not defined
#endif
#ifndef ENOSTR
#error ENOSTR not defined
#endif
#ifndef ENOSYS
#error ENOSYS not defined
#endif
#ifndef ENOTCONN
#error ENOTCONN not defined
#endif
#ifndef ENOTDIR
#error ENOTDIR not defined
#endif
#ifndef ENOTEMPTY
#error ENOTEMPTY not defined
#endif
#ifndef ENOTRECOVERABLE
#error ENOTRECOVERABLE not defined
#endif
#ifndef ENOTSOCK
#error ENOTSOCK not defined
#endif
#ifndef ENOTSUP
#error ENOTSUP not defined
#endif
#ifndef ENOTTY
#error ENOTTY not defined
#endif
#ifndef ENXIO
#error ENXIO not defined
#endif
#ifndef EOPNOTSUPP
#error EOPNOTSUPP not defined
#endif
#ifndef EOVERFLOW
#error EOVERFLOW not defined
#endif
#ifndef EOWNERDEAD
#error EOWNERDEAD not defined
#endif
#ifndef EPERM
#error EPERM not defined
#endif
#ifndef EPIPE
#error EPIPE not defined
#endif
#ifndef EPROTO
#error EPROTO not defined
#endif
#ifndef EPROTONOSUPPORT
#error EPROTONOSUPPORT not defined
#endif
#ifndef EPROTOTYPE
#error EPROTOTYPE not defined
#endif
#ifndef ERANGE
#error ERANGE not defined
#endif
#ifndef EROFS
#error EROFS not defined
#endif
#ifndef ESPIPE
#error ESPIPE not defined
#endif
#ifndef ESRCH
#error ESRCH not defined
#endif
#ifndef ETIME
#error ETIME not defined
#endif
#ifndef ETIMEDOUT
#error ETIMEDOUT not defined
#endif
#ifndef ETXTBSY
#error ETXTBSY not defined
#endif
#ifndef EWOULDBLOCK
#error EWOULDBLOCK not defined
#endif
#ifndef EXDEV
#error EXDEV not defined
#endif
#ifndef errno
#error errno not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,96 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <system_error>
// enum errc {...}
#include <system_error>
int main()
{
static_assert(std::errc::address_family_not_supported == EAFNOSUPPORT, "");
static_assert(std::errc::address_in_use == EADDRINUSE, "");
static_assert(std::errc::address_not_available == EADDRNOTAVAIL, "");
static_assert(std::errc::already_connected == EISCONN, "");
static_assert(std::errc::argument_list_too_long == E2BIG, "");
static_assert(std::errc::argument_out_of_domain == EDOM, "");
static_assert(std::errc::bad_address == EFAULT, "");
static_assert(std::errc::bad_file_descriptor == EBADF, "");
static_assert(std::errc::bad_message == EBADMSG, "");
static_assert(std::errc::broken_pipe == EPIPE, "");
static_assert(std::errc::connection_aborted == ECONNABORTED, "");
static_assert(std::errc::connection_already_in_progress == EALREADY, "");
static_assert(std::errc::connection_refused == ECONNREFUSED, "");
static_assert(std::errc::connection_reset == ECONNRESET, "");
static_assert(std::errc::cross_device_link == EXDEV, "");
static_assert(std::errc::destination_address_required == EDESTADDRREQ, "");
static_assert(std::errc::device_or_resource_busy == EBUSY, "");
static_assert(std::errc::directory_not_empty == ENOTEMPTY, "");
static_assert(std::errc::executable_format_error == ENOEXEC, "");
static_assert(std::errc::file_exists == EEXIST, "");
static_assert(std::errc::file_too_large == EFBIG, "");
static_assert(std::errc::filename_too_long == ENAMETOOLONG, "");
static_assert(std::errc::function_not_supported == ENOSYS, "");
static_assert(std::errc::host_unreachable == EHOSTUNREACH, "");
static_assert(std::errc::identifier_removed == EIDRM, "");
static_assert(std::errc::illegal_byte_sequence == EILSEQ, "");
static_assert(std::errc::inappropriate_io_control_operation == ENOTTY, "");
static_assert(std::errc::interrupted == EINTR, "");
static_assert(std::errc::invalid_argument == EINVAL, "");
static_assert(std::errc::invalid_seek == ESPIPE, "");
static_assert(std::errc::io_error == EIO, "");
static_assert(std::errc::is_a_directory == EISDIR, "");
static_assert(std::errc::message_size == EMSGSIZE, "");
static_assert(std::errc::network_down == ENETDOWN, "");
static_assert(std::errc::network_reset == ENETRESET, "");
static_assert(std::errc::network_unreachable == ENETUNREACH, "");
static_assert(std::errc::no_buffer_space == ENOBUFS, "");
static_assert(std::errc::no_child_process == ECHILD, "");
static_assert(std::errc::no_link == ENOLINK, "");
static_assert(std::errc::no_lock_available == ENOLCK, "");
static_assert(std::errc::no_message_available == ENODATA, "");
static_assert(std::errc::no_message == ENOMSG, "");
static_assert(std::errc::no_protocol_option == ENOPROTOOPT, "");
static_assert(std::errc::no_space_on_device == ENOSPC, "");
static_assert(std::errc::no_stream_resources == ENOSR, "");
static_assert(std::errc::no_such_device_or_address == ENXIO, "");
static_assert(std::errc::no_such_device == ENODEV, "");
static_assert(std::errc::no_such_file_or_directory == ENOENT, "");
static_assert(std::errc::no_such_process == ESRCH, "");
static_assert(std::errc::not_a_directory == ENOTDIR, "");
static_assert(std::errc::not_a_socket == ENOTSOCK, "");
static_assert(std::errc::not_a_stream == ENOSTR, "");
static_assert(std::errc::not_connected == ENOTCONN, "");
static_assert(std::errc::not_enough_memory == ENOMEM, "");
static_assert(std::errc::not_supported == ENOTSUP, "");
static_assert(std::errc::operation_canceled == ECANCELED, "");
static_assert(std::errc::operation_in_progress == EINPROGRESS, "");
static_assert(std::errc::operation_not_permitted == EPERM, "");
static_assert(std::errc::operation_not_supported == EOPNOTSUPP, "");
static_assert(std::errc::operation_would_block == EWOULDBLOCK, "");
static_assert(std::errc::owner_dead == EOWNERDEAD, "");
static_assert(std::errc::permission_denied == EACCES, "");
static_assert(std::errc::protocol_error == EPROTO, "");
static_assert(std::errc::protocol_not_supported == EPROTONOSUPPORT, "");
static_assert(std::errc::read_only_file_system == EROFS, "");
static_assert(std::errc::resource_deadlock_would_occur == EDEADLK, "");
static_assert(std::errc::resource_unavailable_try_again == EAGAIN, "");
static_assert(std::errc::result_out_of_range == ERANGE, "");
static_assert(std::errc::state_not_recoverable == ENOTRECOVERABLE, "");
static_assert(std::errc::stream_timeout == ETIME, "");
static_assert(std::errc::text_file_busy == ETXTBSY, "");
static_assert(std::errc::timed_out == ETIMEDOUT, "");
static_assert(std::errc::too_many_files_open_in_system == ENFILE, "");
static_assert(std::errc::too_many_files_open == EMFILE, "");
static_assert(std::errc::too_many_links == EMLINK, "");
static_assert(std::errc::too_many_symbolic_link_levels == ELOOP, "");
static_assert(std::errc::value_too_large == EOVERFLOW, "");
static_assert(std::errc::wrong_protocol_type == EPROTOTYPE, "");
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <system_error>
// class error_code
// error_code make_error_code(errc e);
#include <system_error>
#include <cassert>
int main()
{
{
std::error_code ec = make_error_code(std::errc::operation_canceled);
assert(ec.value() == static_cast<int>(std::errc::operation_canceled));
assert(ec.category() == std::generic_category());
}
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <system_error>
// class error_condition
// error_condition make_error_condition(errc e);
#include <system_error>
#include <cassert>
int main()
{
{
const std::error_condition ec1 = std::make_error_condition(std::errc::message_size);
assert(ec1.value() == static_cast<int>(std::errc::message_size));
assert(ec1.category() == std::generic_category());
}
}

View File

@@ -30,11 +30,7 @@ int main()
test<char, std::numeric_limits<char>::is_signed ? 7 : 8>();
test<signed char, 7>();
test<unsigned char, 8>();
#if _WIN32
test<wchar_t, 16>();
#else
test<wchar_t, std::numeric_limits<wchar_t>::is_signed ? 31 : 32>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 16>();
test<char32_t, 32>();

View File

@@ -34,11 +34,7 @@ int main()
test<char, 2>();
test<signed char, 2>();
test<unsigned char, 2>();
#ifdef _WIN32
test<wchar_t, 4>();
#else
test<wchar_t, 9>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 4>();
test<char32_t, 9>();

View File

@@ -63,12 +63,12 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
report += "\n\nExpected compilation to fail!"
return lit.Test.FAIL, report
else:
exec_file = tempfile.NamedTemporaryFile(suffix=".exe")
exec_file = tempfile.NamedTemporaryFile(suffix="exe")
exec_path = exec_file.name
exec_file.close()
try:
compile_cmd = [self.cxx_under_test, 'e:/llvm/libcxx/test/_win32_seterrormode.fail.cpp', '-o', exec_path,
compile_cmd = [self.cxx_under_test, '-o', exec_path,
source_path] + self.cpp_flags + self.ld_flags
cmd = compile_cmd
out, err, exitCode = self.execute_command(cmd)
@@ -155,6 +155,6 @@ if sys.platform == 'linux2':
config.test_format = LibcxxTestFormat(cxx_under_test,
cpp_flags = ['-nostdinc++'] + compile_flags + include_paths,
ld_flags = [''] + library_paths + ['-lc++'] + libraries)
ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries)
config.target_triple = None

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <clocale>
#include <clocale>
#include <type_traits>
#ifndef LC_ALL
#error LC_ALL not defined
#endif
#ifndef LC_COLLATE
#error LC_COLLATE not defined
#endif
#ifndef LC_CTYPE
#error LC_CTYPE not defined
#endif
#ifndef LC_MONETARY
#error LC_MONETARY not defined
#endif
#ifndef LC_NUMERIC
#error LC_NUMERIC not defined
#endif
#ifndef LC_TIME
#error LC_TIME not defined
#endif
#ifndef NULL
#error NULL not defined
#endif
int main()
{
std::lconv lc;
static_assert((std::is_same<__typeof__(std::setlocale(0, "")), char*>::value), "");
static_assert((std::is_same<__typeof__(std::localeconv()), std::lconv*>::value), "");
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <clocale>
#include <clocale>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// Not a portable test
// __scan_keyword
// Scans [__b, __e) until a match is found in the basic_strings range
// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
// __b will be incremented (visibly), consuming CharT until a match is found
// or proved to not exist. A keyword may be "", in which will match anything.
// If one keyword is a prefix of another, and the next CharT in the input
// might match another keyword, the algorithm will attempt to find the longest
// matching keyword. If the longer matching keyword ends up not matching, then
// no keyword match is found. If no keyword match is found, __ke is returned.
// Else an iterator pointing to the matching keyword is found. If more than
// one keyword matches, an iterator to the first matching keyword is returned.
// If on exit __b == __e, eofbit is set in __err. If __case_senstive is false,
// __ct is used to force to lower case before comparing characters.
// Examples:
// Keywords: "a", "abb"
// If the input is "a", the first keyword matches and eofbit is set.
// If the input is "abc", no match is found and "ab" are consumed.
//
// template <class _InputIterator, class _ForwardIterator, class _Ctype>
// _ForwardIterator
// __scan_keyword(_InputIterator& __b, _InputIterator __e,
// _ForwardIterator __kb, _ForwardIterator __ke,
// const _Ctype& __ct, ios_base::iostate& __err,
// bool __case_sensitive = true);
#include <locale>
#include <cassert>
int main()
{
const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic());
std::ios_base::iostate err = std::ios_base::goodbit;
{
const char input[] = "a";
const char* in = input;
std::string keys[] = {"a", "abb"};
err = std::ios_base::goodbit;
std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
keys, keys+sizeof(keys)/sizeof(keys[0]),
ct, err);
assert(k - keys == 0);
assert(in == input+1);
assert(err == std::ios_base::eofbit);
}
{
const char input[] = "abc";
const char* in = input;
std::string keys[] = {"a", "abb"};
err = std::ios_base::goodbit;
std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
keys, keys+sizeof(keys)/sizeof(keys[0]),
ct, err);
assert(k - keys == 2);
assert(in == input+2);
assert(err == std::ios_base::failbit);
}
{
const char input[] = "abb";
const char* in = input;
std::string keys[] = {"a", "abb"};
err = std::ios_base::goodbit;
std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
keys, keys+sizeof(keys)/sizeof(keys[0]),
ct, err);
assert(k - keys == 1);
assert(in == input+3);
assert(err == std::ios_base::eofbit);
}
{
const char input[] = "Tue ";
const char* in = input;
std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
err = std::ios_base::goodbit;
std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
keys, keys+sizeof(keys)/sizeof(keys[0]),
ct, err);
assert(k - keys == 2);
assert(in == input+3);
assert(err == std::ios_base::goodbit);
}
{
const char input[] = "tue ";
const char* in = input;
std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
err = std::ios_base::goodbit;
std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
keys, keys+sizeof(keys)/sizeof(keys[0]),
ct, err);
assert(k - keys == 4);
assert(in == input+0);
assert(err == std::ios_base::failbit);
}
{
const char input[] = "tue ";
const char* in = input;
std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
err = std::ios_base::goodbit;
std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
keys, keys+sizeof(keys)/sizeof(keys[0]),
ct, err, false);
assert(k - keys == 2);
assert(in == input+3);
assert(err == std::ios_base::goodbit);
}
}

View File

@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate_byname
// int compare(const charT* low1, const charT* high1,
// const charT* low2, const charT* high2) const;
// I'm currently unable to confirm that collation based on named locales
// has any difference from "C" collation. But I do believe I'm picking
// up the OS's collation files.
#include <locale>
#include <string>
#include <cassert>
#include <stdio.h>
int main()
{
{
std::locale l("en_US");
{
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
std::string s2("aaaaaaA");
std::string s3("BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
{
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
std::wstring s2(L"aaaaaaA");
std::wstring s3(L"BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
}
{
std::locale l("");
{
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
std::string s2("aaaaaaA");
std::string s3("BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
{
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
std::wstring s2(L"aaaaaaA");
std::wstring s3(L"BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
}
{
std::locale l("C");
{
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
std::string s2("aaaaaaA");
std::string s3("BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
{
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
std::wstring s2(L"aaaaaaA");
std::wstring s3(L"BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
}
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate_byname
// long hash(const charT* low, const charT* high) const;
// This test is not portable
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l("en_US");
{
std::string x1("1234");
std::string x2("12345");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
{
std::wstring x1(L"1234");
std::wstring x2(L"12345");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate_byname
// string_type transform(const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
#include <stdio.h>
int main()
{
{
std::locale l("en_US");
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
}
{
std::locale l("");
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
}
{
std::locale l("C");
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
}
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT>
// class collate_byname
// : public collate<charT>
// {
// public:
// typedef basic_string<charT> string_type;
// explicit collate_byname(const char*, size_t refs = 0);
// explicit collate_byname(const string&, size_t refs = 0);
// protected:
// ~collate_byname();
// };
#include <locale>
#include <string>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l("en_US");
{
assert(std::has_facet<std::collate_byname<char> >(l));
assert(&std::use_facet<std::collate<char> >(l)
== &std::use_facet<std::collate_byname<char> >(l));
}
{
assert(std::has_facet<std::collate_byname<wchar_t> >(l));
assert(&std::use_facet<std::collate<wchar_t> >(l)
== &std::use_facet<std::collate_byname<wchar_t> >(l));
}
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// explicit collate(size_t refs = 0);
#include <locale>
#include <type_traits>
#include <cassert>
template <class C>
class my_facet
: public std::collate<C>
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: std::collate<C>(refs) {++count;}
~my_facet() {--count;}
};
template <class C> int my_facet<C>::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet<char>);
assert(my_facet<char>::count == 1);
}
assert(my_facet<char>::count == 0);
{
my_facet<char> f(1);
assert(my_facet<char>::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet<char>::count == 1);
}
assert(my_facet<char>::count == 1);
}
assert(my_facet<char>::count == 0);
{
std::locale l(std::locale::classic(), new my_facet<wchar_t>);
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 0);
{
my_facet<wchar_t> f(1);
assert(my_facet<wchar_t>::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 0);
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// int compare(const charT* low1, const charT* high1,
// const charT* low2, const charT* high2) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
const char ia[] = "1234";
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
const char ib[] = "123";
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
assert(f.compare(ia, ia+3, ib, ib+3) == 0);
}
{
const wchar_t ia[] = L"1234";
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
const wchar_t ib[] = L"123";
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
assert(f.compare(ia, ia+3, ib, ib+3) == 0);
}
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// long hash(const charT* low, const charT* high) const;
// This test is not portable
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
std::string x1("1234");
std::string x2("12345");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
{
std::wstring x1(L"1234");
std::wstring x2(L"12345");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// string_type transform(const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
}

View File

@@ -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()
{
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT>
// class collate
// : public locale::facet {
// public:
// typedef charT char_type;
// typedef basic_string<charT>string_type;
//
// static locale::id id;
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
assert(std::has_facet<std::collate<char> >(l));
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
{
(void)std::collate<char>::id;
}
static_assert((std::is_same<std::collate<char>::char_type, char>::value), "");
static_assert((std::is_same<std::collate<char>::string_type, std::string>::value), "");
static_assert((std::is_base_of<std::locale::facet, std::collate<char> >::value), "");
}
{
assert(std::has_facet<std::collate<wchar_t> >(l));
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
{
(void)std::collate<wchar_t>::id;
}
static_assert((std::is_same<std::collate<wchar_t>::char_type, wchar_t>::value), "");
static_assert((std::is_same<std::collate<wchar_t>::string_type, std::wstring>::value), "");
static_assert((std::is_base_of<std::locale::facet, std::collate<wchar_t> >::value), "");
}
}

View File

@@ -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()
{
}

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// class ctype_base
// {
// public:
// typedef T mask;
//
// // numeric values are for exposition only.
// static const mask space = 1 << 0;
// static const mask print = 1 << 1;
// static const mask cntrl = 1 << 2;
// static const mask upper = 1 << 3;
// static const mask lower = 1 << 4;
// static const mask alpha = 1 << 5;
// static const mask digit = 1 << 6;
// static const mask punct = 1 << 7;
// static const mask xdigit = 1 << 8;
// static const mask alnum = alpha | digit;
// static const mask graph = alnum | punct;
// };
#include <locale>
#include <cassert>
int main()
{
assert(std::ctype_base::space);
assert(std::ctype_base::print);
assert(std::ctype_base::cntrl);
assert(std::ctype_base::upper);
assert(std::ctype_base::lower);
assert(std::ctype_base::alpha);
assert(std::ctype_base::digit);
assert(std::ctype_base::punct);
assert(std::ctype_base::xdigit);
assert(
( std::ctype_base::space
& std::ctype_base::print
& std::ctype_base::cntrl
& std::ctype_base::upper
& std::ctype_base::lower
& std::ctype_base::alpha
& std::ctype_base::digit
& std::ctype_base::punct
& std::ctype_base::xdigit) == 0);
assert(std::ctype_base::alnum == (std::ctype_base::alpha | std::ctype_base::digit));
assert(std::ctype_base::graph == (std::ctype_base::alnum | std::ctype_base::punct));
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>
// ~ctype();
#include <locale>
#include <cassert>
#include <new>
unsigned delete_called = 0;
void operator delete[](void* p) throw()
{
operator delete(p);
++delete_called;
}
int main()
{
{
delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>);
assert(delete_called == 0);
}
assert(delete_called == 0);
{
std::ctype<char>::mask table[256];
delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>(table));
assert(delete_called == 0);
}
assert(delete_called == 0);
{
delete_called = 0;
std::locale l(std::locale::classic(),
new std::ctype<char>(new std::ctype<char>::mask[256], true));
assert(delete_called == 0);
}
assert(delete_called == 1);
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// explicit ctype(const mask* tbl = 0, bool del = false, size_t refs = 0);
#include <locale>
#include <cassert>
class my_facet
: public std::ctype<char>
{
public:
static int count;
explicit my_facet(const mask* tbl = 0, bool del = false, std::size_t refs = 0)
: std::ctype<char>(tbl, del, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(0, false, 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// bool is(mask m, char c) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.is(F::space, ' '));
assert(!f.is(F::space, 'A'));
assert(f.is(F::print, ' '));
assert(!f.is(F::print, '\x07'));
assert(f.is(F::cntrl, '\x07'));
assert(!f.is(F::cntrl, ' '));
assert(f.is(F::upper, 'A'));
assert(!f.is(F::upper, 'a'));
assert(f.is(F::lower, 'a'));
assert(!f.is(F::lower, 'A'));
assert(f.is(F::alpha, 'a'));
assert(!f.is(F::alpha, '1'));
assert(f.is(F::digit, '1'));
assert(!f.is(F::digit, 'a'));
assert(f.is(F::punct, '.'));
assert(!f.is(F::punct, 'a'));
assert(f.is(F::xdigit, 'a'));
assert(!f.is(F::xdigit, 'g'));
assert(f.is(F::alnum, 'a'));
assert(!f.is(F::alnum, '.'));
assert(f.is(F::graph, '.'));
assert(!f.is(F::graph, '\x07'));
}
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* is(const char* low, const char* high, mask* vec) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
const std::string in(" A\x07.a1");
std::vector<F::mask> m(in.size());
const char* h = f.is(in.data(), in.data() + in.size(), m.data());
assert(h == in.data() + in.size());
// ' '
assert( (m[0] & F::space));
assert( (m[0] & F::print));
assert(!(m[0] & F::cntrl));
assert(!(m[0] & F::upper));
assert(!(m[0] & F::lower));
assert(!(m[0] & F::alpha));
assert(!(m[0] & F::digit));
assert(!(m[0] & F::punct));
assert(!(m[0] & F::xdigit));
assert( (m[0] & F::blank));
assert(!(m[0] & F::alnum));
assert(!(m[0] & F::graph));
// 'A'
assert(!(m[1] & F::space));
assert( (m[1] & F::print));
assert(!(m[1] & F::cntrl));
assert( (m[1] & F::upper));
assert(!(m[1] & F::lower));
assert( (m[1] & F::alpha));
assert(!(m[1] & F::digit));
assert(!(m[1] & F::punct));
assert( (m[1] & F::xdigit));
assert(!(m[1] & F::blank));
assert( (m[1] & F::alnum));
assert( (m[1] & F::graph));
// '\x07'
assert(!(m[2] & F::space));
assert(!(m[2] & F::print));
assert( (m[2] & F::cntrl));
assert(!(m[2] & F::upper));
assert(!(m[2] & F::lower));
assert(!(m[2] & F::alpha));
assert(!(m[2] & F::digit));
assert(!(m[2] & F::punct));
assert(!(m[2] & F::xdigit));
assert(!(m[2] & F::blank));
assert(!(m[2] & F::alnum));
assert(!(m[2] & F::graph));
// '.'
assert(!(m[3] & F::space));
assert( (m[3] & F::print));
assert(!(m[3] & F::cntrl));
assert(!(m[3] & F::upper));
assert(!(m[3] & F::lower));
assert(!(m[3] & F::alpha));
assert(!(m[3] & F::digit));
assert( (m[3] & F::punct));
assert(!(m[3] & F::xdigit));
assert(!(m[3] & F::blank));
assert(!(m[3] & F::alnum));
assert( (m[3] & F::graph));
// 'a'
assert(!(m[4] & F::space));
assert( (m[4] & F::print));
assert(!(m[4] & F::cntrl));
assert(!(m[4] & F::upper));
assert( (m[4] & F::lower));
assert( (m[4] & F::alpha));
assert(!(m[4] & F::digit));
assert(!(m[4] & F::punct));
assert( (m[4] & F::xdigit));
assert(!(m[4] & F::blank));
assert( (m[4] & F::alnum));
assert( (m[4] & F::graph));
// '1'
assert(!(m[5] & F::space));
assert( (m[5] & F::print));
assert(!(m[5] & F::cntrl));
assert(!(m[5] & F::upper));
assert(!(m[5] & F::lower));
assert(!(m[5] & F::alpha));
assert( (m[5] & F::digit));
assert(!(m[5] & F::punct));
assert( (m[5] & F::xdigit));
assert(!(m[5] & F::blank));
assert( (m[5] & F::alnum));
assert( (m[5] & F::graph));
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char narrow(char c, char dfault) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.narrow(' ', '*') == ' ');
assert(f.narrow('A', '*') == 'A');
assert(f.narrow('\x07', '*') == '\x07');
assert(f.narrow('.', '*') == '.');
assert(f.narrow('a', '*') == 'a');
assert(f.narrow('1', '*') == '1');
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* narrow(const char* low, const char*, char dfault, char* to) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
std::vector<char> v(in.size());
assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
assert(v[0] == ' ');
assert(v[1] == 'A');
assert(v[2] == '\x07');
assert(v[3] == '.');
assert(v[4] == 'a');
assert(v[5] == '1');
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* scan_is(mask m, const char* low, const char* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
const std::string in(" A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* scan_not(mask m, const char* low, const char* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
const std::string in(" A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>
// const mask* table() const throw();
#include <locale>
#include <cassert>
int main()
{
typedef std::ctype<char> F;
{
std::locale l(std::locale::classic(), new std::ctype<char>);
const F& f = std::use_facet<F>(l);
assert(f.table() == f.classic_table());
}
{
std::ctype<char>::mask table[256];
std::locale l(std::locale::classic(), new std::ctype<char>(table));
const F& f = std::use_facet<F>(l);
assert(f.table() == table);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char tolower(char) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.tolower(' ') == ' ');
assert(f.tolower('A') == 'a');
assert(f.tolower('\x07') == '\x07');
assert(f.tolower('.') == '.');
assert(f.tolower('a') == 'a');
assert(f.tolower('1') == '1');
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* tolower(char* low, const char* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == ' ');
assert(in[1] == 'a');
assert(in[2] == '\x07');
assert(in[3] == '.');
assert(in[4] == 'a');
assert(in[5] == '1');
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char toupper(char) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.toupper(' ') == ' ');
assert(f.toupper('A') == 'A');
assert(f.toupper('\x07') == '\x07');
assert(f.toupper('.') == '.');
assert(f.toupper('a') == 'A');
assert(f.toupper('1') == '1');
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* toupper(char* low, const char* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == ' ');
assert(in[1] == 'A');
assert(in[2] == '\x07');
assert(in[3] == '.');
assert(in[4] == 'A');
assert(in[5] == '1');
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char widen(char c) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.widen(' ') == ' ');
assert(f.widen('A') == 'A');
assert(f.widen('\x07') == '\x07');
assert(f.widen('.') == '.');
assert(f.widen('a') == 'a');
assert(f.widen('1') == '1');
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* widen(const char* low, const char* high, char* to) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
std::vector<char> v(in.size());
assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
assert(v[0] == ' ');
assert(v[1] == 'A');
assert(v[2] == '\x07');
assert(v[3] == '.');
assert(v[4] == 'a');
assert(v[5] == '1');
}
}

View File

@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>
// static const mask* classic_table() throw();
#include <locale>
#include <cassert>
int main()
{
typedef std::ctype<char> F;
assert(F::classic_table() != 0);
}

View File

@@ -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()
{
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <>
// class ctype<char>
// : public locale::facet,
// public ctype_base
// {
// public:
// typedef char char_type;
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
assert(std::has_facet<std::ctype<char> >(l));
const std::ctype<char>& f = std::use_facet<std::ctype<char> >(l);
{
(void)std::ctype<char>::id;
}
static_assert((std::is_same<std::ctype<char>::char_type, char>::value), "");
static_assert((std::is_base_of<std::ctype_base, std::ctype<char> >::value), "");
static_assert((std::is_base_of<std::locale::facet, std::ctype<char> >::value), "");
}
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<char, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<char, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<char16_t, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<char16_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<char32_t, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<char32_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<wchar_t, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// class codecvt_base
// {
// public:
// enum result {ok, partial, error, noconv};
// };
#include <locale>
#include <cassert>
int main()
{
assert(std::codecvt_base::ok == 0);
assert(std::codecvt_base::partial == 1);
assert(std::codecvt_base::error == 2);
assert(std::codecvt_base::noconv == 3);
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
//#endif
int main()
{
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
//#endif
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
//#endif
int main()
{
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
//#endif
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// bool always_noconv() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(!f.always_noconv());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// int encoding() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.encoding() == 0);
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// result in(stateT& state,
// const externT* from, const externT* from_end, const externT*& from_next,
// internT* to, internT* to_end, internT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const char from[] = "some text";
F::intern_type to[9];
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char* from_next = 0;
F::intern_type* to_next = 0;
assert(f.in(mbs, from, from + 9, from_next,
to, to + 9, to_next) == F::ok);
assert(from_next - from == 9);
assert(to_next - to == 9);
for (unsigned i = 0; i < 9; ++i)
assert(to[i] == from[i]);
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char from[] = "some text";
assert(f.length(mbs, from, from+10, 0) == 0);
assert(f.length(mbs, from, from+10, 8) == 8);
assert(f.length(mbs, from, from+10, 9) == 9);
assert(f.length(mbs, from, from+10, 10) == 10);
assert(f.length(mbs, from, from+10, 100) == 10);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// int max_length() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.max_length() == 4);
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// result out(stateT& state,
// const internT* from, const internT* from_end, const internT*& from_next,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
{
F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
char to[9] = {0};
std::mbstate_t mbs;
const F::intern_type* from_next = 0;
char* to_next = 0;
F::result r = f.out(mbs, from, from + 9, from_next,
to, to + 9, to_next);
assert(r == F::ok);
assert(from_next - from == 9);
assert(to_next - to == 9);
for (unsigned i = 0; i < 9; ++i)
assert(to[i] == from[i]);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// result unshift(stateT& state,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
std::vector<char> to(3);
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
char* to_next = 0;
assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
assert(to_next == to.data());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// bool always_noconv() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(!f.always_noconv());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// int encoding() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.encoding() == 0);
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// result in(stateT& state,
// const externT* from, const externT* from_end, const externT*& from_next,
// internT* to, internT* to_end, internT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const char from[] = "some text";
F::intern_type to[9];
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char* from_next = 0;
F::intern_type* to_next = 0;
assert(f.in(mbs, from, from + 9, from_next,
to, to + 9, to_next) == F::ok);
assert(from_next - from == 9);
assert(to_next - to == 9);
for (unsigned i = 0; i < 9; ++i)
assert(to[i] == from[i]);
}

View File

@@ -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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char from[] = "some text";
assert(f.length(mbs, from, from+10, 0) == 0);
assert(f.length(mbs, from, from+10, 8) == 8);
assert(f.length(mbs, from, from+10, 9) == 9);
assert(f.length(mbs, from, from+10, 10) == 10);
assert(f.length(mbs, from, from+10, 100) == 10);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// int max_length() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.max_length() == 4);
}

Some files were not shown because too many files have changed in this diff Show More