Merge to upstream r293197.

Bug: http://b/34740564
Test: make checkbuild && ./run_tests.py  # Tested aosp_sailfish-eng
Change-Id: I33320f72d9170548010c023bd28f03578461b5ff
This commit is contained in:
Dan Albert
2017-01-26 18:55:51 -08:00
3317 changed files with 142487 additions and 23981 deletions

View File

@@ -0,0 +1,167 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcpp-no-exceptions
// <algorithm>
// template <class _Compare> struct __debug_less
// __debug_less checks that a comparator actually provides a strict-weak ordering.
struct DebugException {};
#define _LIBCPP_DEBUG 0
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : throw ::DebugException())
#include <algorithm>
#include <cassert>
template <int ID>
struct MyType {
int value;
explicit MyType(int xvalue = 0) : value(xvalue) {}
};
template <int ID1, int ID2>
bool operator<(MyType<ID1> const& LHS, MyType<ID2> const& RHS) {
return LHS.value < RHS.value;
}
struct CompareBase {
static int called;
static void reset() {
called = 0;
}
};
int CompareBase::called = 0;
template <class ValueType>
struct GoodComparator : public CompareBase {
bool operator()(ValueType const& lhs, ValueType const& rhs) const {
++CompareBase::called;
return lhs < rhs;
}
};
template <class ValueType>
struct BadComparator : public CompareBase {
bool operator()(ValueType const&, ValueType const&) const {
++CompareBase::called;
return true;
}
};
template <class T1, class T2>
struct TwoWayHomoComparator : public CompareBase {
bool operator()(T1 const& lhs, T2 const& rhs) const {
++CompareBase::called;
return lhs < rhs;
}
bool operator()(T2 const& lhs, T1 const& rhs) const {
++CompareBase::called;
return lhs < rhs;
}
};
template <class T1, class T2>
struct OneWayHomoComparator : public CompareBase {
bool operator()(T1 const& lhs, T2 const& rhs) const {
++CompareBase::called;
return lhs < rhs;
}
};
using std::__debug_less;
typedef MyType<0> MT0;
typedef MyType<1> MT1;
void test_passing() {
int& called = CompareBase::called;
called = 0;
MT0 one(1);
MT0 two(2);
MT1 three(3);
MT1 four(4);
{
typedef GoodComparator<MT0> C;
typedef __debug_less<C> D;
C c;
D d(c);
assert(d(one, two) == true);
assert(called == 2);
called = 0;
assert(d(one, one) == false);
assert(called == 1);
called = 0;
assert(d(two, one) == false);
assert(called == 1);
called = 0;
}
{
typedef TwoWayHomoComparator<MT0, MT1> C;
typedef __debug_less<C> D;
C c;
D d(c);
assert(d(one, three) == true);
assert(called == 2);
called = 0;
assert(d(three, one) == false);
assert(called == 1);
called = 0;
}
{
typedef OneWayHomoComparator<MT0, MT1> C;
typedef __debug_less<C> D;
C c;
D d(c);
assert(d(one, three) == true);
assert(called == 1);
called = 0;
}
}
void test_failing() {
int& called = CompareBase::called;
called = 0;
MT0 one(1);
MT0 two(2);
{
typedef BadComparator<MT0> C;
typedef __debug_less<C> D;
C c;
D d(c);
try {
d(one, two);
assert(false);
} catch (DebugException const&) {
}
assert(called == 2);
called = 0;
}
}
int main() {
test_passing();
test_failing();
}

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.
//
//===----------------------------------------------------------------------===//
// <algorithm>
#include <algorithm>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,93 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads, c++98, c++03
// REQUIRES: libatomic
// RUN: %build -latomic
// RUN: %run
//
// GCC currently fails because it needs -fabi-version=6 to fix mangling of
// std::atomic when used with __attribute__((vector(X))).
// XFAIL: gcc
// <atomic>
// Verify that the content of atomic<T> is properly aligned if the type is
// lock-free. This can't be observed through the atomic<T> API. It is
// nonetheless required for correctness of the implementation: lock-free implies
// that ISA instructions are used, and these instructions assume "suitable
// alignment". Supported architectures all require natural alignment for
// lock-freedom (e.g. load-linked / store-conditional, or cmpxchg).
#include <atomic>
#include <cassert>
template <typename T> struct atomic_test : public std::__atomic_base<T> {
atomic_test() {
if (this->is_lock_free())
assert(alignof(this->__a_) >= sizeof(this->__a_) &&
"expected natural alignment for lock-free type");
}
};
int main() {
// structs and unions can't be defined in the template invocation.
// Work around this with a typedef.
#define CHECK_ALIGNMENT(T) \
do { \
typedef T type; \
atomic_test<type> t; \
} while (0)
CHECK_ALIGNMENT(bool);
CHECK_ALIGNMENT(char);
CHECK_ALIGNMENT(signed char);
CHECK_ALIGNMENT(unsigned char);
CHECK_ALIGNMENT(char16_t);
CHECK_ALIGNMENT(char32_t);
CHECK_ALIGNMENT(wchar_t);
CHECK_ALIGNMENT(short);
CHECK_ALIGNMENT(unsigned short);
CHECK_ALIGNMENT(int);
CHECK_ALIGNMENT(unsigned int);
CHECK_ALIGNMENT(long);
CHECK_ALIGNMENT(unsigned long);
CHECK_ALIGNMENT(long long);
CHECK_ALIGNMENT(unsigned long long);
CHECK_ALIGNMENT(std::nullptr_t);
CHECK_ALIGNMENT(void *);
CHECK_ALIGNMENT(float);
CHECK_ALIGNMENT(double);
CHECK_ALIGNMENT(long double);
CHECK_ALIGNMENT(int __attribute__((vector_size(1 * sizeof(int)))));
CHECK_ALIGNMENT(int __attribute__((vector_size(2 * sizeof(int)))));
CHECK_ALIGNMENT(int __attribute__((vector_size(4 * sizeof(int)))));
CHECK_ALIGNMENT(int __attribute__((vector_size(16 * sizeof(int)))));
CHECK_ALIGNMENT(int __attribute__((vector_size(32 * sizeof(int)))));
CHECK_ALIGNMENT(float __attribute__((vector_size(1 * sizeof(float)))));
CHECK_ALIGNMENT(float __attribute__((vector_size(2 * sizeof(float)))));
CHECK_ALIGNMENT(float __attribute__((vector_size(4 * sizeof(float)))));
CHECK_ALIGNMENT(float __attribute__((vector_size(16 * sizeof(float)))));
CHECK_ALIGNMENT(float __attribute__((vector_size(32 * sizeof(float)))));
CHECK_ALIGNMENT(double __attribute__((vector_size(1 * sizeof(double)))));
CHECK_ALIGNMENT(double __attribute__((vector_size(2 * sizeof(double)))));
CHECK_ALIGNMENT(double __attribute__((vector_size(4 * sizeof(double)))));
CHECK_ALIGNMENT(double __attribute__((vector_size(16 * sizeof(double)))));
CHECK_ALIGNMENT(double __attribute__((vector_size(32 * sizeof(double)))));
CHECK_ALIGNMENT(struct Empty {});
CHECK_ALIGNMENT(struct OneInt { int i; });
CHECK_ALIGNMENT(struct IntArr2 { int i[2]; });
CHECK_ALIGNMENT(struct LLIArr2 { long long int i[2]; });
CHECK_ALIGNMENT(struct LLIArr4 { long long int i[4]; });
CHECK_ALIGNMENT(struct LLIArr8 { long long int i[8]; });
CHECK_ALIGNMENT(struct LLIArr16 { long long int i[16]; });
CHECK_ALIGNMENT(struct Padding { char c; /* padding */ long long int i; });
CHECK_ALIGNMENT(union IntFloat { int i; float f; });
}

View File

@@ -0,0 +1,124 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support, diagnose-if-support
// UNSUPPORTED: libcpp-has-no-threads
// <atomic>
// Test that invalid memory order arguments are diagnosed where possible.
#include <atomic>
int main() {
std::atomic<int> x(42);
volatile std::atomic<int>& vx = x;
int val1 = 1; ((void)val1);
int val2 = 2; ((void)val2);
// load operations
{
x.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
x.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
x.load(std::memory_order_relaxed);
x.load(std::memory_order_consume);
x.load(std::memory_order_acquire);
x.load(std::memory_order_seq_cst);
}
{
std::atomic_load_explicit(&x, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_load_explicit(&x, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_load_explicit(&vx, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_load_explicit(&vx, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
std::atomic_load_explicit(&x, std::memory_order_relaxed);
std::atomic_load_explicit(&x, std::memory_order_consume);
std::atomic_load_explicit(&x, std::memory_order_acquire);
std::atomic_load_explicit(&x, std::memory_order_seq_cst);
}
// store operations
{
x.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
x.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
x.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
x.store(42, std::memory_order_relaxed);
x.store(42, std::memory_order_release);
x.store(42, std::memory_order_seq_cst);
}
{
std::atomic_store_explicit(&x, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_store_explicit(&x, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_store_explicit(&x, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_store_explicit(&vx, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_store_explicit(&vx, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_store_explicit(&vx, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
std::atomic_store_explicit(&x, 42, std::memory_order_relaxed);
std::atomic_store_explicit(&x, 42, std::memory_order_release);
std::atomic_store_explicit(&x, 42, std::memory_order_seq_cst);
}
// compare exchange weak
{
x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
// Test that the cmpxchg overload with only one memory order argument
// does not generate any diagnostics.
x.compare_exchange_weak(val1, val2, std::memory_order_release);
}
{
std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
}
// compare exchange strong
{
x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
// Test that the cmpxchg overload with only one memory order argument
// does not generate any diagnostics.
x.compare_exchange_strong(val1, val2, std::memory_order_release);
}
{
std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
// valid memory orders
std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
}
}

View File

@@ -12,6 +12,7 @@
// Test that including <atomic> fails to compile when _LIBCPP_HAS_NO_THREADS
// is defined.
// MODULES_DEFINES: _LIBCPP_HAS_NO_THREADS
#ifndef _LIBCPP_HAS_NO_THREADS
#define _LIBCPP_HAS_NO_THREADS
#endif

View File

@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// UNSUPPORTED: libcpp-has-no-threads
// <atomic>
#include <atomic>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -7,22 +7,85 @@
#
#===----------------------------------------------------------------------===##
import platform
import os
import lit.util
import libcxx.util
class CXXCompiler(object):
CM_Default = 0
CM_PreProcess = 1
CM_Compile = 2
CM_Link = 3
def __init__(self, path, flags=None, compile_flags=None, link_flags=None,
use_ccache=False):
warning_flags=None, verify_supported=None,
verify_flags=None, use_verify=False,
modules_flags=None, use_modules=False,
use_ccache=False, use_warnings=False, compile_env=None,
cxx_type=None, cxx_version=None):
self.path = path
self.flags = list(flags or [])
self.compile_flags = list(compile_flags or [])
self.link_flags = list(link_flags or [])
self.warning_flags = list(warning_flags or [])
self.verify_supported = verify_supported
self.use_verify = use_verify
self.verify_flags = list(verify_flags or [])
assert not use_verify or verify_supported
assert not use_verify or verify_flags is not None
self.modules_flags = list(modules_flags or [])
self.use_modules = use_modules
assert not use_modules or modules_flags is not None
self.use_ccache = use_ccache
self.type = None
self.version = None
self._initTypeAndVersion()
self.use_warnings = use_warnings
if compile_env is not None:
self.compile_env = dict(compile_env)
else:
self.compile_env = None
self.type = cxx_type
self.version = cxx_version
if self.type is None or self.version is None:
self._initTypeAndVersion()
def copy(self):
new_cxx = CXXCompiler(
self.path, flags=self.flags, compile_flags=self.compile_flags,
link_flags=self.link_flags, warning_flags=self.warning_flags,
verify_supported=self.verify_supported,
verify_flags=self.verify_flags, use_verify=self.use_verify,
modules_flags=self.modules_flags, use_modules=self.use_modules,
use_ccache=self.use_ccache, use_warnings=self.use_warnings,
compile_env=self.compile_env, cxx_type=self.type,
cxx_version=self.version)
return new_cxx
def isVerifySupported(self):
if self.verify_supported is None:
self.verify_supported = self.hasCompileFlag(['-Xclang',
'-verify-ignore-unexpected'])
if self.verify_supported:
self.verify_flags = [
'-Xclang', '-verify',
'-Xclang', '-verify-ignore-unexpected=note',
'-ferror-limit=1024'
]
return self.verify_supported
def useVerify(self, value=True):
self.use_verify = value
assert not self.use_verify or self.verify_flags is not None
def useModules(self, value=True):
self.use_modules = value
assert not self.use_modules or self.modules_flags is not None
def useCCache(self, value=True):
self.use_ccache = value
def useWarnings(self, value=True):
self.use_warnings = value
def _initTypeAndVersion(self):
# Get compiler type and version
@@ -47,9 +110,12 @@ class CXXCompiler(object):
self.type = compiler_type
self.version = (major_ver, minor_ver, patchlevel)
def _basicCmd(self, source_files, out, is_link=False, input_is_cxx=False):
def _basicCmd(self, source_files, out, mode=CM_Default, flags=[],
input_is_cxx=False):
cmd = []
if self.use_ccache and not is_link:
if self.use_ccache \
and not mode == self.CM_Link \
and not mode == self.CM_PreProcess:
cmd += ['ccache']
cmd += [self.path]
if out is not None:
@@ -62,51 +128,69 @@ class CXXCompiler(object):
cmd += [source_files]
else:
raise TypeError('source_files must be a string or list')
if mode == self.CM_PreProcess:
cmd += ['-E']
elif mode == self.CM_Compile:
cmd += ['-c']
cmd += self.flags
if self.use_verify:
cmd += self.verify_flags
assert mode in [self.CM_Default, self.CM_Compile]
if self.use_modules:
cmd += self.modules_flags
if mode != self.CM_Link:
cmd += self.compile_flags
if self.use_warnings:
cmd += self.warning_flags
if mode != self.CM_PreProcess and mode != self.CM_Compile:
cmd += self.link_flags
cmd += flags
return cmd
def preprocessCmd(self, source_files, out=None, flags=[]):
cmd = self._basicCmd(source_files, out, input_is_cxx=True) + ['-E']
cmd += self.flags + self.compile_flags + flags
return cmd
return self._basicCmd(source_files, out, flags=flags,
mode=self.CM_PreProcess,
input_is_cxx=True)
def compileCmd(self, source_files, out=None, flags=[]):
cmd = self._basicCmd(source_files, out, input_is_cxx=True) + ['-c']
cmd += self.flags + self.compile_flags + flags
return cmd
return self._basicCmd(source_files, out, flags=flags,
mode=self.CM_Compile,
input_is_cxx=True) + ['-c']
def linkCmd(self, source_files, out=None, flags=[]):
cmd = self._basicCmd(source_files, out, is_link=True)
cmd += self.flags + self.link_flags + flags
return cmd
return self._basicCmd(source_files, out, flags=flags,
mode=self.CM_Link)
def compileLinkCmd(self, source_files, out=None, flags=[]):
cmd = self._basicCmd(source_files, out, is_link=True)
cmd += self.flags + self.compile_flags + self.link_flags + flags
return cmd
return self._basicCmd(source_files, out, flags=flags)
def preprocess(self, source_files, out=None, flags=[], env=None, cwd=None):
def preprocess(self, source_files, out=None, flags=[], cwd=None):
cmd = self.preprocessCmd(source_files, out, flags)
out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env,
cwd=cwd)
return cmd, out, err, rc
def compile(self, source_files, out=None, flags=[], env=None, cwd=None):
def compile(self, source_files, out=None, flags=[], cwd=None):
cmd = self.compileCmd(source_files, out, flags)
out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env,
cwd=cwd)
return cmd, out, err, rc
def link(self, source_files, out=None, flags=[], env=None, cwd=None):
def link(self, source_files, out=None, flags=[], cwd=None):
cmd = self.linkCmd(source_files, out, flags)
out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env,
cwd=cwd)
return cmd, out, err, rc
def compileLink(self, source_files, out=None, flags=[], env=None,
def compileLink(self, source_files, out=None, flags=[],
cwd=None):
cmd = self.compileLinkCmd(source_files, out, flags)
out, err, rc = lit.util.executeCommand(cmd, env=env, cwd=cwd)
out, err, rc = lit.util.executeCommand(cmd, env=self.compile_env,
cwd=cwd)
return cmd, out, err, rc
def compileLinkTwoSteps(self, source_file, out=None, object_file=None,
flags=[], env=None, cwd=None):
flags=[], cwd=None):
if not isinstance(source_file, str):
raise TypeError('This function only accepts a single input file')
if object_file is None:
@@ -117,21 +201,20 @@ class CXXCompiler(object):
with_fn = lambda: libcxx.util.nullContext(object_file)
with with_fn() as object_file:
cc_cmd, cc_stdout, cc_stderr, rc = self.compile(
source_file, object_file, flags=flags, env=env, cwd=cwd)
source_file, object_file, flags=flags, cwd=cwd)
if rc != 0:
return cc_cmd, cc_stdout, cc_stderr, rc
link_cmd, link_stdout, link_stderr, rc = self.link(
object_file, out=out, flags=flags, env=env, cwd=cwd)
object_file, out=out, flags=flags, cwd=cwd)
return (cc_cmd + ['&&'] + link_cmd, cc_stdout + link_stdout,
cc_stderr + link_stderr, rc)
def dumpMacros(self, source_files=None, flags=[], env=None, cwd=None):
def dumpMacros(self, source_files=None, flags=[], cwd=None):
if source_files is None:
source_files = os.devnull
flags = ['-dM'] + flags
cmd, out, err, rc = self.preprocess(source_files, flags=flags, env=env,
cwd=cwd)
cmd, out, err, rc = self.preprocess(source_files, flags=flags, cwd=cwd)
if rc != 0:
return None
parsed_macros = {}
@@ -155,11 +238,22 @@ class CXXCompiler(object):
# Add -Werror to ensure that an unrecognized flag causes a non-zero
# exit code. -Werror is supported on all known compiler types.
if self.type is not None:
flags += ['-Werror']
flags += ['-Werror', '-fsyntax-only']
cmd, out, err, rc = self.compile(os.devnull, out=os.devnull,
flags=flags)
return rc == 0
def addFlagIfSupported(self, flag):
if isinstance(flag, list):
flags = list(flag)
else:
flags = [flag]
if self.hasCompileFlag(flags):
self.flags += flags
return True
else:
return False
def addCompileFlagIfSupported(self, flag):
if isinstance(flag, list):
flags = list(flag)
@@ -171,27 +265,39 @@ class CXXCompiler(object):
else:
return False
def addWarningFlagIfSupported(self, flag):
def hasWarningFlag(self, flag):
"""
addWarningFlagIfSupported - Add a warning flag if the compiler
supports it. Unlike addCompileFlagIfSupported, this function detects
when "-Wno-<warning>" flags are unsupported. If flag is a
hasWarningFlag - Test if the compiler supports a given warning flag.
Unlike addCompileFlagIfSupported, this function detects when
"-Wno-<warning>" flags are unsupported. If flag is a
"-Wno-<warning>" GCC will not emit an unknown option diagnostic unless
another error is triggered during compilation.
"""
assert isinstance(flag, str)
assert flag.startswith('-W')
if not flag.startswith('-Wno-'):
return self.addCompileFlagIfSupported(flag)
return self.hasCompileFlag(flag)
flags = ['-Werror', flag]
old_use_warnings = self.use_warnings
self.useWarnings(False)
cmd = self.compileCmd('-', os.devnull, flags)
self.useWarnings(old_use_warnings)
# Remove '-v' because it will cause the command line invocation
# to be printed as part of the error output.
# TODO(EricWF): Are there other flags we need to worry about?
if '-v' in cmd:
cmd.remove('-v')
out, err, rc = lit.util.executeCommand(cmd, input='#error\n')
out, err, rc = lit.util.executeCommand(
cmd, input=lit.util.to_bytes('#error\n'))
assert rc != 0
if flag in err:
return False
self.compile_flags += [flag]
return True
def addWarningFlagIfSupported(self, flag):
if self.hasWarningFlag(flag):
if flag not in self.warning_flags:
self.warning_flags += [flag]
return True
return False

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.
//
//===----------------------------------------------------------------------===//
// <map>
#include <map>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// REQUIRES: diagnose-if-support, verify-support
// Test that libc++ generates a warning diagnostic when the container is
// provided a non-const callable comparator.
#include <set>
#include <map>
struct BadCompare {
template <class T, class U>
bool operator()(T const& t, U const& u) {
return t < u;
}
};
int main() {
static_assert(!std::__invokable<BadCompare const&, int const&, int const&>::value, "");
static_assert(std::__invokable<BadCompare&, int const&, int const&>::value, "");
// expected-warning@__tree:* 4 {{the specified comparator type does not provide a const call operator}}
{
using C = std::set<int, BadCompare>;
C s;
}
{
using C = std::multiset<long, BadCompare>;
C s;
}
{
using C = std::map<int, int, BadCompare>;
C s;
}
{
using C = std::multimap<long, int, BadCompare>;
C s;
}
}

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.
//
//===----------------------------------------------------------------------===//
// <set>
#include <set>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -24,6 +24,9 @@ struct Node
Node* __parent_;
bool __is_black_;
Node* __parent_unsafe() const { return __parent_; }
void __set_parent(Node* x) { __parent_ = x;}
Node() : __left_(), __right_(), __parent_(), __is_black_() {}
};

View File

@@ -23,6 +23,9 @@ struct Node
Node* __right_;
Node* __parent_;
Node* __parent_unsafe() const { return __parent_; }
void __set_parent(Node* x) { __parent_ = x;}
Node() : __left_(), __right_(), __parent_() {}
};

View File

@@ -24,6 +24,9 @@ struct Node
Node* __parent_;
bool __is_black_;
Node* __parent_unsafe() const { return __parent_; }
void __set_parent(Node* x) { __parent_ = x;}
Node() : __left_(), __right_(), __parent_(), __is_black_() {}
};

View File

@@ -23,6 +23,9 @@ struct Node
Node* __right_;
Node* __parent_;
Node* __parent_unsafe() const { return __parent_; }
void __set_parent(Node* x) { __parent_ = x;}
Node() : __left_(), __right_(), __parent_() {}
};

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.
//
//===----------------------------------------------------------------------===//
// <queue>
#include <queue>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <stack>
#include <stack>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -7,6 +7,11 @@
//
//===----------------------------------------------------------------------===//
// Prevent emission of the deprecated warning.
#ifdef __clang__
#pragma clang diagnostic ignored "-W#warnings"
#endif
#include <ext/hash_map>
namespace __gnu_cxx {

View File

@@ -7,6 +7,11 @@
//
//===----------------------------------------------------------------------===//
// Prevent emission of the deprecated warning.
#ifdef __clang__
#pragma clang diagnostic ignored "-W#warnings"
#endif
#include <ext/hash_set>
namespace __gnu_cxx {

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.
//
//===----------------------------------------------------------------------===//
// <array>
#include <array>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -12,6 +12,7 @@
// deque()
// deque::iterator()
// MODULES_DEFINES: _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
#include <deque>
#include <cassert>

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.
//
//===----------------------------------------------------------------------===//
// <deque>
#include <deque>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <forward_list>
#include <forward_list>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// list(list&& c);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
std::list<int> l1;
l1.push_back(1); l1.push_back(2); l1.push_back(3);
std::list<int>::iterator i = l1.begin();
std::list<int> l2 = l1;
l2.erase(i);
assert(false);
}

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.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <list>
// list(list&& c);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(1))
#include <list>
#include <cstdlib>
#include <cassert>
#include "MoveOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
int main()
{
std::list<int> l1 = {1, 2, 3};
std::list<int>::iterator i = l1.begin();
std::list<int> l2 = std::move(l1);
assert(*l2.erase(i) == 2);
}

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.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <list>
// template <class... Args> void emplace(const_iterator p, Args&&... args);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
class A
{
int i_;
double d_;
A(const A&);
A& operator=(const A&);
public:
A(int i, double d)
: i_(i), d_(d) {}
int geti() const {return i_;}
double getd() const {return d_;}
};
int main()
{
std::list<A> c1;
std::list<A> c2;
std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
assert(false);
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator position) with end()
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cassert>
#include <cstdlib>
int main()
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int>::const_iterator i = l1.end();
l1.erase(i);
assert(false);
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator position) with iterator from another container
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cassert>
#include <cstdlib>
int main()
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
std::list<int>::const_iterator i = l2.begin();
l1.erase(i);
assert(false);
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with first iterator from another container
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cassert>
#include <cstdlib>
int main()
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
assert(false);
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with second iterator from another container
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cassert>
#include <cstdlib>
int main()
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
assert(false);
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with both iterators from another container
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cassert>
#include <cstdlib>
int main()
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int> l2(a1, a1+3);
std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
assert(false);
}

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.
//
//===----------------------------------------------------------------------===//
// <list>
// Call erase(const_iterator first, const_iterator last); with a bad range
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cassert>
#include <cstdlib>
int main()
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1+3);
std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
assert(false);
}

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.
//
//===----------------------------------------------------------------------===//
// <list>
// template <InputIterator Iter>
// iterator insert(const_iterator position, Iter first, Iter last);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
#include "test_iterators.h"
int main()
{
{
std::list<int> v(100);
std::list<int> v2(100);
int a[] = {1, 2, 3, 4, 5};
const int N = sizeof(a)/sizeof(a[0]);
std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10),
input_iterator<const int*>(a),
input_iterator<const int*>(a+N));
assert(false);
}
}

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.
//
//===----------------------------------------------------------------------===//
// <list>
// iterator insert(const_iterator position, value_type&& x);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
std::list<int> v1(3);
std::list<int> v2(3);
v1.insert(v2.begin(), 4);
assert(false);
}

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.
//
//===----------------------------------------------------------------------===//
// <list>
// iterator insert(const_iterator position, size_type n, const value_type& x);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
std::list<int> c1(100);
std::list<int> c2;
std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
assert(false);
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// iterator insert(const_iterator position, const value_type& x);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
std::list<int> v1(3);
std::list<int> v2(3);
int i = 4;
v1.insert(v2.begin(), i);
assert(false);
}

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.
//
//===----------------------------------------------------------------------===//
// <list>
// void pop_back();
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
int a[] = {1, 2, 3};
std::list<int> c(a, a+3);
c.pop_back();
assert(c == std::list<int>(a, a+2));
c.pop_back();
assert(c == std::list<int>(a, a+1));
c.pop_back();
assert(c.empty());
c.pop_back(); // operation under test
assert(false);
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// void splice(const_iterator position, list& x);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
{
std::list<int> v1(3);
std::list<int> v2(3);
v1.splice(v2.begin(), v2);
assert(false);
}
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
{
std::list<int> v1(3);
std::list<int> v2(3);
v1.splice(v1.begin(), v2, v1.begin());
assert(false);
}
}

View File

@@ -0,0 +1,29 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// void splice(const_iterator position, list& x, iterator first, iterator last);
#define _LIBCPP_DEBUG 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <list>
#include <cstdlib>
#include <cassert>
int main()
{
{
std::list<int> v1(3);
std::list<int> v2(3);
v1.splice(v1.begin(), v2, v2.begin(), v1.end());
assert(false);
}
}

View File

@@ -1,59 +0,0 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <list>
// template <class T, class Alloc>
// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
#if _LIBCPP_DEBUG >= 1
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#endif
#include <list>
#include <cassert>
#include <__debug>
#include "min_allocator.h"
int main()
{
#if _LIBCPP_DEBUG >= 1
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
std::list<int>::iterator i1 = c1.begin();
std::list<int>::iterator i2 = c2.begin();
swap(c1, c2);
c1.erase(i2);
c2.erase(i1);
std::list<int>::iterator j = i1;
c1.erase(i1);
assert(false);
}
#if __cplusplus >= 201103L
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
std::list<int, min_allocator<int>>::iterator i1 = c1.begin();
std::list<int, min_allocator<int>>::iterator i2 = c2.begin();
swap(c1, c2);
c1.erase(i2);
c2.erase(i1);
std::list<int, min_allocator<int>>::iterator j = i1;
c1.erase(i1);
assert(false);
}
#endif
#endif
}

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.
//
//===----------------------------------------------------------------------===//
// <list>
#include <list>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -38,7 +38,8 @@ int main()
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
C c(std::begin(t), std::end(t));
c.reserve(2*c.size());
T foo = c[c.size()]; // bad, but not caught by ASAN
volatile T foo = c[c.size()]; // bad, but not caught by ASAN
((void)foo);
}
#endif
@@ -61,9 +62,10 @@ int main()
C c(std::begin(t), std::end(t));
c.reserve(2*c.size());
assert(is_contiguous_container_asan_correct(c));
assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity()));
T foo = c[c.size()]; // should trigger ASAN
assert(!__sanitizer_verify_contiguous_container( c.data(), c.data() + 1, c.data() + c.capacity()));
volatile T foo = c[c.size()]; // should trigger ASAN. Use volatile to prevent being optimized away.
assert(false); // if we got here, ASAN didn't trigger
((void)foo);
}
}
#else

View File

@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// UNSUPPORTED: libcpp-no-exceptions
// Test asan vector annotations with a class that throws in a CTOR.
#include <vector>
@@ -41,7 +41,7 @@ private:
class ThrowOnCopy {
public:
ThrowOnCopy() : should_throw(false) {}
explicit ThrowOnCopy(bool should_throw) : should_throw(should_throw) {}
explicit ThrowOnCopy(bool xshould_throw) : should_throw(xshould_throw) {}
ThrowOnCopy(ThrowOnCopy const & other)
: should_throw(other.should_throw)

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.
//
//===----------------------------------------------------------------------===//
// <vector>
#include <vector>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// REQUIRES: diagnose-if-support, verify-support
// Test that libc++ generates a warning diagnostic when the container is
// provided a non-const callable comparator.
#include <unordered_set>
#include <unordered_map>
struct BadHash {
template <class T>
size_t operator()(T const& t) {
return std::hash<T>{}(t);
}
};
struct BadEqual {
template <class T, class U>
bool operator()(T const& t, U const& u) {
return t == u;
}
};
int main() {
static_assert(!std::__invokable<BadEqual const&, int const&, int const&>::value, "");
static_assert(std::__invokable<BadEqual&, int const&, int const&>::value, "");
// expected-warning@__hash_table:* 4 {{the specified comparator type does not provide a const call operator}}
// expected-warning@__hash_table:* 4 {{the specified hash functor does not provide a const call operator}}
{
using C = std::unordered_set<int, BadHash, BadEqual>;
C s;
}
{
using C = std::unordered_multiset<long, BadHash, BadEqual>;
C s;
}
{
using C = std::unordered_map<int, int, BadHash, BadEqual>;
C s;
}
{
using C = std::unordered_multimap<long, int, BadHash, BadEqual>;
C s;
}
}

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.
//
//===----------------------------------------------------------------------===//
// <unordered_map>
#include <unordered_map>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <unordered_set>
#include <unordered_set>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
// test container debugging
#define _LIBCPP_DEBUG 1
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
#include <map>
#include <set>
#include <utility>
#include <cassert>
#include "debug_mode_helper.h"
using namespace IteratorDebugChecks;
template <class Container, ContainerType CT>
struct AssociativeContainerChecks : BasicContainerChecks<Container, CT> {
using Base = BasicContainerChecks<Container, CT>;
using value_type = typename Container::value_type;
using iterator = typename Container::iterator;
using const_iterator = typename Container::const_iterator;
using traits = std::iterator_traits<iterator>;
using category = typename traits::iterator_category;
using Base::makeContainer;
public:
static void run() {
Base::run();
try {
// FIXME Add tests
} catch (...) {
assert(false && "uncaught debug exception");
}
}
private:
// FIXME Add tests here
};
int main()
{
using SetAlloc = test_allocator<int>;
using MapAlloc = test_allocator<std::pair<const int, int>>;
// FIXME: Add debug mode to these containers
if ((false)) {
AssociativeContainerChecks<
std::set<int, std::less<int>, SetAlloc>, CT_Set>::run();
AssociativeContainerChecks<
std::multiset<int, std::less<int>, SetAlloc>, CT_MultiSet>::run();
AssociativeContainerChecks<
std::map<int, int, std::less<int>, MapAlloc>, CT_Map>::run();
AssociativeContainerChecks<
std::multimap<int, int, std::less<int>, MapAlloc>, CT_MultiMap>::run();
}
}

View File

@@ -0,0 +1,265 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
// test container debugging
#define _LIBCPP_DEBUG 1
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
#include <forward_list>
#include <list>
#include <vector>
#include <deque>
#include "debug_mode_helper.h"
using namespace IteratorDebugChecks;
template <class Container, ContainerType CT>
struct SequenceContainerChecks : BasicContainerChecks<Container, CT> {
using Base = BasicContainerChecks<Container, CT>;
using value_type = typename Container::value_type;
using allocator_type = typename Container::allocator_type;
using iterator = typename Container::iterator;
using const_iterator = typename Container::const_iterator;
using Base::makeContainer;
using Base::makeValueType;
public:
static void run() {
Base::run();
try {
FrontOnEmptyContainer();
if constexpr (CT != CT_ForwardList) {
AssignInvalidates();
BackOnEmptyContainer();
InsertIterValue();
InsertIterSizeValue();
InsertIterIterIter();
EmplaceIterValue();
EraseIterIter();
}
if constexpr (CT == CT_Vector || CT == CT_Deque || CT == CT_List) {
PopBack();
}
if constexpr (CT == CT_List || CT == CT_Deque) {
PopFront(); // FIXME: Run with forward list as well
}
} catch (...) {
assert(false && "uncaught debug exception");
}
}
private:
static void AssignInvalidates() {
CHECKPOINT("assign(Size, Value)");
Container C(allocator_type{});
iterator it1, it2, it3;
auto reset = [&]() {
C = makeContainer(3);
it1 = C.begin();
it2 = ++C.begin();
it3 = C.end();
};
auto check = [&]() {
CHECK_DEBUG_THROWS( C.erase(it1) );
CHECK_DEBUG_THROWS( C.erase(it2) );
CHECK_DEBUG_THROWS( C.erase(it3, C.end()) );
};
reset();
C.assign(2, makeValueType(4));
check();
reset();
CHECKPOINT("assign(Iter, Iter)");
std::vector<value_type> V = {
makeValueType(1),
makeValueType(2),
makeValueType(3)
};
C.assign(V.begin(), V.end());
check();
reset();
CHECKPOINT("assign(initializer_list)");
C.assign({makeValueType(1), makeValueType(2), makeValueType(3)});
check();
}
static void BackOnEmptyContainer() {
CHECKPOINT("testing back on empty");
Container C = makeContainer(1);
Container const& CC = C;
(void)C.back();
(void)CC.back();
C.clear();
CHECK_DEBUG_THROWS( C.back() );
CHECK_DEBUG_THROWS( CC.back() );
}
static void FrontOnEmptyContainer() {
CHECKPOINT("testing front on empty");
Container C = makeContainer(1);
Container const& CC = C;
(void)C.front();
(void)CC.front();
C.clear();
CHECK_DEBUG_THROWS( C.front() );
CHECK_DEBUG_THROWS( CC.front() );
}
static void EraseIterIter() {
CHECKPOINT("testing erase iter iter invalidation");
Container C1 = makeContainer(3);
iterator it1 = C1.begin();
iterator it1_next = ++C1.begin();
iterator it1_after_next = ++C1.begin();
++it1_after_next;
iterator it1_back = --C1.end();
assert(it1_next != it1_back);
if (CT == CT_Vector) {
CHECK_DEBUG_THROWS( C1.erase(it1_next, it1) ); // bad range
}
C1.erase(it1, it1_after_next);
CHECK_DEBUG_THROWS( C1.erase(it1) );
CHECK_DEBUG_THROWS( C1.erase(it1_next) );
if (CT == CT_List) {
C1.erase(it1_back);
} else {
CHECK_DEBUG_THROWS( C1.erase(it1_back) );
}
}
static void PopBack() {
CHECKPOINT("testing pop_back() invalidation");
Container C1 = makeContainer(2);
iterator it1 = C1.end();
--it1;
C1.pop_back();
CHECK_DEBUG_THROWS( C1.erase(it1) );
C1.erase(C1.begin());
assert(C1.size() == 0);
CHECK_DEBUG_THROWS( C1.pop_back() );
}
static void PopFront() {
CHECKPOINT("testing pop_front() invalidation");
Container C1 = makeContainer(2);
iterator it1 = C1.begin();
C1.pop_front();
CHECK_DEBUG_THROWS( C1.erase(it1) );
C1.erase(C1.begin());
assert(C1.size() == 0);
CHECK_DEBUG_THROWS( C1.pop_front() );
}
static void InsertIterValue() {
CHECKPOINT("testing insert(iter, value)");
Container C1 = makeContainer(2);
iterator it1 = C1.begin();
iterator it1_next = it1;
++it1_next;
Container C2 = C1;
const value_type value = makeValueType(3);
value_type rvalue = makeValueType(3);
CHECK_DEBUG_THROWS( C2.insert(it1, value) ); // wrong container
CHECK_DEBUG_THROWS( C2.insert(it1, std::move(rvalue)) ); // wrong container
C1.insert(it1_next, value);
if (CT == CT_List) {
C1.insert(it1_next, value);
C1.insert(it1, value);
C1.insert(it1_next, std::move(rvalue));
C1.insert(it1, std::move(rvalue));
} else {
CHECK_DEBUG_THROWS( C1.insert(it1_next, value) ); // invalidated iterator
CHECK_DEBUG_THROWS( C1.insert(it1, value) ); // invalidated iterator
CHECK_DEBUG_THROWS( C1.insert(it1_next, std::move(rvalue)) ); // invalidated iterator
CHECK_DEBUG_THROWS( C1.insert(it1, std::move(rvalue)) ); // invalidated iterator
}
}
static void EmplaceIterValue() {
CHECKPOINT("testing emplace(iter, value)");
Container C1 = makeContainer(2);
iterator it1 = C1.begin();
iterator it1_next = it1;
++it1_next;
Container C2 = C1;
const value_type value = makeValueType(3);
CHECK_DEBUG_THROWS( C2.emplace(it1, value) ); // wrong container
CHECK_DEBUG_THROWS( C2.emplace(it1, makeValueType(4)) ); // wrong container
C1.emplace(it1_next, value);
if (CT == CT_List) {
C1.emplace(it1_next, value);
C1.emplace(it1, value);
} else {
CHECK_DEBUG_THROWS( C1.emplace(it1_next, value) ); // invalidated iterator
CHECK_DEBUG_THROWS( C1.emplace(it1, value) ); // invalidated iterator
}
}
static void InsertIterSizeValue() {
CHECKPOINT("testing insert(iter, size, value)");
Container C1 = makeContainer(2);
iterator it1 = C1.begin();
iterator it1_next = it1;
++it1_next;
Container C2 = C1;
const value_type value = makeValueType(3);
CHECK_DEBUG_THROWS( C2.insert(it1, 1, value) ); // wrong container
C1.insert(it1_next, 2, value);
if (CT == CT_List) {
C1.insert(it1_next, 3, value);
C1.insert(it1, 1, value);
} else {
CHECK_DEBUG_THROWS( C1.insert(it1_next, 1, value) ); // invalidated iterator
CHECK_DEBUG_THROWS( C1.insert(it1, 1, value) ); // invalidated iterator
}
}
static void InsertIterIterIter() {
CHECKPOINT("testing insert(iter, iter, iter)");
Container C1 = makeContainer(2);
iterator it1 = C1.begin();
iterator it1_next = it1;
++it1_next;
Container C2 = C1;
std::vector<value_type> V = {
makeValueType(1),
makeValueType(2),
makeValueType(3)
};
CHECK_DEBUG_THROWS( C2.insert(it1, V.begin(), V.end()) ); // wrong container
C1.insert(it1_next, V.begin(), V.end());
if (CT == CT_List) {
C1.insert(it1_next, V.begin(), V.end());
C1.insert(it1, V.begin(), V.end());
} else {
CHECK_DEBUG_THROWS( C1.insert(it1_next, V.begin(), V.end()) ); // invalidated iterator
CHECK_DEBUG_THROWS( C1.insert(it1, V.begin(), V.end()) ); // invalidated iterator
}
}
};
int main()
{
using Alloc = test_allocator<int>;
{
SequenceContainerChecks<std::list<int, Alloc>, CT_List>::run();
SequenceContainerChecks<std::vector<int, Alloc>, CT_Vector>::run();
}
// FIXME these containers don't support iterator debugging
if ((false)) {
SequenceContainerChecks<
std::vector<bool, test_allocator<bool>>, CT_VectorBool>::run();
SequenceContainerChecks<
std::forward_list<int, Alloc>, CT_ForwardList>::run();
SequenceContainerChecks<
std::deque<int, Alloc>, CT_Deque>::run();
}
}

View File

@@ -0,0 +1,95 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
// test container debugging
#define _LIBCPP_DEBUG 1
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
#include <string>
#include <vector>
#include "test_macros.h"
#include "debug_mode_helper.h"
using namespace IteratorDebugChecks;
typedef std::basic_string<char, std::char_traits<char>, test_allocator<char>> StringType;
template <class Container = StringType, ContainerType CT = CT_String>
struct StringContainerChecks : BasicContainerChecks<Container, CT> {
using Base = BasicContainerChecks<Container, CT_String>;
using value_type = typename Container::value_type;
using allocator_type = typename Container::allocator_type;
using iterator = typename Container::iterator;
using const_iterator = typename Container::const_iterator;
using Base::makeContainer;
using Base::makeValueType;
public:
static void run() {
Base::run_iterator_tests();
Base::run_allocator_aware_tests();
try {
for (int N : {3, 128}) {
FrontOnEmptyContainer(N);
BackOnEmptyContainer(N);
PopBack(N);
}
} catch (...) {
assert(false && "uncaught debug exception");
}
}
private:
static void BackOnEmptyContainer(int N) {
CHECKPOINT("testing back on empty");
Container C = makeContainer(N);
Container const& CC = C;
iterator it = --C.end();
(void)C.back();
(void)CC.back();
C.pop_back();
CHECK_DEBUG_THROWS( C.erase(it) );
C.clear();
CHECK_DEBUG_THROWS( C.back() );
CHECK_DEBUG_THROWS( CC.back() );
}
static void FrontOnEmptyContainer(int N) {
CHECKPOINT("testing front on empty");
Container C = makeContainer(N);
Container const& CC = C;
(void)C.front();
(void)CC.front();
C.clear();
CHECK_DEBUG_THROWS( C.front() );
CHECK_DEBUG_THROWS( CC.front() );
}
static void PopBack(int N) {
CHECKPOINT("testing pop_back() invalidation");
Container C1 = makeContainer(N);
iterator it1 = C1.end();
--it1;
C1.pop_back();
CHECK_DEBUG_THROWS( C1.erase(it1) );
C1.erase(C1.begin(), C1.end());
assert(C1.size() == 0);
CHECK_DEBUG_THROWS( C1.pop_back() );
}
};
int main()
{
StringContainerChecks<>::run();
}

View File

@@ -0,0 +1,66 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
// test container debugging
#define _LIBCPP_DEBUG 1
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <cassert>
#include "debug_mode_helper.h"
using namespace IteratorDebugChecks;
template <class Container, ContainerType CT>
struct UnorderedContainerChecks : BasicContainerChecks<Container, CT> {
using Base = BasicContainerChecks<Container, CT>;
using value_type = typename Container::value_type;
using iterator = typename Container::iterator;
using const_iterator = typename Container::const_iterator;
using traits = std::iterator_traits<iterator>;
using category = typename traits::iterator_category;
using Base::makeContainer;
public:
static void run() {
Base::run();
try {
// FIXME
} catch (...) {
assert(false && "uncaught debug exception");
}
}
private:
};
int main()
{
using SetAlloc = test_allocator<int>;
using MapAlloc = test_allocator<std::pair<const int, int>>;
{
UnorderedContainerChecks<
std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
CT_UnorderedMap>::run();
UnorderedContainerChecks<
std::unordered_set<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
CT_UnorderedSet>::run();
UnorderedContainerChecks<
std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, MapAlloc>,
CT_UnorderedMultiMap>::run();
UnorderedContainerChecks<
std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, SetAlloc>,
CT_UnorderedMultiSet>::run();
}
}

View File

@@ -0,0 +1,30 @@
// -*- 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 that the default debug handler aborts the program.
#define _LIBCPP_DEBUG 0
#include <csignal>
#include <cstdlib>
#include <__debug>
void signal_handler(int signal)
{
if (signal == SIGABRT)
std::_Exit(EXIT_SUCCESS);
std::_Exit(EXIT_FAILURE);
}
int main()
{
if (std::signal(SIGABRT, signal_handler) != SIG_ERR)
_LIBCPP_ASSERT(false, "foo");
return EXIT_FAILURE;
}

View File

@@ -0,0 +1,36 @@
// -*- 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.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcpp-no-exceptions
// Test that the default debug handler can be overridden and test the
// throwing debug handler.
#define _LIBCPP_DEBUG 0
#include <cstdlib>
#include <exception>
#include <type_traits>
#include <__debug>
int main()
{
{
std::__libcpp_debug_function = std::__libcpp_throw_debug_function;
try {
_LIBCPP_ASSERT(false, "foo");
} catch (std::__libcpp_debug_exception const&) {}
}
{
// test that the libc++ exception type derives from std::exception
static_assert((std::is_base_of<std::exception,
std::__libcpp_debug_exception
>::value), "must be an exception");
}
}

View File

@@ -0,0 +1,30 @@
// -*- 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.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: libcpp-no-exceptions
// Test that defining _LIBCPP_DEBUG_USE_EXCEPTIONS causes _LIBCPP_ASSERT
// to throw on failure.
#define _LIBCPP_DEBUG 1
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
#include <cstdlib>
#include <exception>
#include <type_traits>
#include <__debug>
#include <cassert>
int main()
{
try {
_LIBCPP_ASSERT(false, "foo");
assert(false);
} catch (...) {}
}

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.
//
//===----------------------------------------------------------------------===//
// <memory>
// template <class X>
// class auto_ptr;
//
// In C++17, auto_ptr has been removed.
// However, for backwards compatibility, if _LIBCPP_NO_REMOVE_AUTOPTR
// is defined before including <memory>, then auto_ptr will be restored.
#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
#include <memory>
#include <type_traits>
int main()
{
std::auto_ptr<int> p;
}

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.
//
//===----------------------------------------------------------------------===//
// <ciso646>
#include <ciso646>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <complex.h>
#include <complex.h>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
std::complex<double> d;
}

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.
//
//===----------------------------------------------------------------------===//
// <locale.h>
#include <locale.h>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <tgmath.h>
#include <tgmath.h>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
std::complex<double> cd;
double x = sin(1.0);
(void)x; // to placate scan-build
}

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.
//
//===----------------------------------------------------------------------===//
// <strstream>
#include <strstream>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// test <cassert>
#include <cassert>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,19 @@
// -*- 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
int main() {}

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.
//
//===----------------------------------------------------------------------===//
// <stdexcept>
#include <stdexcept>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <system_error>
#include <system_error>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -15,14 +15,18 @@
// RUN: %cxx -o %t.exe %t.first.o %t.second.o %flags %link_flags
// RUN: %run
// Prevent <ext/hash_map> from generating deprecated warnings for this test.
#if defined(__DEPRECATED)
#undef __DEPRECATED
#endif
// Top level headers
#include <algorithm>
#include <any>
#include <array>
#ifndef _LIBCPP_HAS_NO_THREADS
#include <atomic>
#endif
#include <bitset>
#include <cassert>
#include <ccomplex>
@@ -51,25 +55,21 @@
#include <cstring>
#include <ctgmath>
#include <ctime>
#include <ctype.h>
#include <cwchar>
#include <cwctype>
#include <deque>
#include <errno.h>
#include <exception>
#include <experimental/algorithm>
#include <experimental/any>
#include <experimental/chrono>
#include <experimental/dynarray>
#include <experimental/optional>
#include <experimental/string_view>
#include <experimental/system_error>
#include <experimental/type_traits>
#include <experimental/utility>
#include <ext/hash_map>
#include <ext/hash_set>
#include <float.h>
#include <forward_list>
#include <fstream>
#include <functional>
#ifndef _LIBCPP_HAS_NO_THREADS
#include <future>
#endif
#include <initializer_list>
#include <inttypes.h>
#include <iomanip>
#include <ios>
#include <iosfwd>
@@ -77,12 +77,19 @@
#include <istream>
#include <iterator>
#include <limits>
#include <limits.h>
#include <list>
#include <locale>
#include <locale.h>
#include <map>
#include <math.h>
#include <memory>
#ifndef _LIBCPP_HAS_NO_THREADS
#include <mutex>
#endif
#include <new>
#include <numeric>
#include <optional>
#include <ostream>
#include <queue>
#include <random>
@@ -90,14 +97,28 @@
#include <regex>
#include <scoped_allocator>
#include <set>
#include <setjmp.h>
#ifndef _LIBCPP_HAS_NO_THREADS
#include <shared_mutex>
#endif
#include <sstream>
#include <stack>
#include <stdbool.h>
#include <stddef.h>
#include <stdexcept>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <streambuf>
#include <string>
#include <string.h>
#include <string_view>
#include <strstream>
#include <system_error>
#include <tgmath.h>
#ifndef _LIBCPP_HAS_NO_THREADS
#include <thread>
#endif
#include <tuple>
#include <typeindex>
#include <typeinfo>
@@ -106,15 +127,45 @@
#include <unordered_set>
#include <utility>
#include <valarray>
#include <variant>
#include <vector>
#include <wchar.h>
#include <wctype.h>
#ifndef _LIBCPP_HAS_NO_THREADS
#include <atomic>
#include <future>
#include <mutex>
#include <shared_mutex>
#include <thread>
#endif
// experimental headers
#if __cplusplus >= 201103L
#include <experimental/algorithm>
#include <experimental/any>
#include <experimental/chrono>
#include <experimental/deque>
#include <experimental/dynarray>
#include <experimental/filesystem>
#include <experimental/forward_list>
#include <experimental/functional>
#include <experimental/iterator>
#include <experimental/list>
#include <experimental/map>
#include <experimental/memory_resource>
#include <experimental/numeric>
#include <experimental/optional>
#include <experimental/propagate_const>
#include <experimental/ratio>
#include <experimental/regex>
#include <experimental/set>
#include <experimental/string>
#include <experimental/string_view>
#include <experimental/system_error>
#include <experimental/tuple>
#include <experimental/type_traits>
#include <experimental/unordered_map>
#include <experimental/unordered_set>
#include <experimental/utility>
#include <experimental/vector>
#endif // __cplusplus >= 201103L
// extended headers
#include <ext/hash_map>
#include <ext/hash_set>
#if defined(WITH_MAIN)
int main() {}

View File

@@ -14,7 +14,7 @@
// Check that the size and alignment of any are what we expect.
#include <experimental/any>
#include "any_helpers.h"
#include "experimental_any_helpers.h"
constexpr std::size_t BufferSize = (sizeof(void*) * 3);
constexpr std::size_t BufferAlignment = alignof(void*);

View File

@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.cons
// template <class Alloc>
@@ -20,10 +21,8 @@
// ~dynarray();
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -44,7 +43,7 @@ void check_allocator ( const dynarray<T> &dyn, const Allocator &alloc ) {
template <class T, class Allocator>
void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
typedef dynarray<T> dynA;
dynA d1 ( vals, alloc );
assert ( d1.size () == vals.size() );
assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
@@ -55,7 +54,7 @@ void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
template <class T, class Allocator>
void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
typedef dynarray<T> dynA;
dynA d1 ( 4, alloc1 );
assert ( d1.size () == 4 );
assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
@@ -68,19 +67,17 @@ void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
dynA d3 ( d2, alloc2 );
assert ( d3.size () == 7 );
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
check_allocator ( d3, alloc2 );
}
int main()
{
// This test is waiting on the resolution of LWG issue #2235
// This test is waiting on the resolution of LWG issue #2235
// typedef test_allocator<char> Alloc;
// typedef std::basic_string<char, std::char_traits<char>, Alloc> nstr;
//
//
// test ( nstr("fourteen"), Alloc(3), Alloc(4) );
// test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6));
}
#else
int main() {}
#endif

View File

@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.cons
@@ -29,13 +28,15 @@
#include <new>
#include <string>
#include "test_macros.h"
using std::experimental::dynarray;
template <class T>
void testInitList( const std::initializer_list<T> &vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
assert ( d1.size () == vals.size() );
assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
@@ -45,7 +46,7 @@ void testInitList( const std::initializer_list<T> &vals ) {
template <class T>
void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
assert ( d1.size () == 4 );
if (!DefaultValueIsIndeterminate) {
@@ -58,15 +59,17 @@ void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
dynA d3 ( d2 );
assert ( d3.size () == 7 );
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
}
#ifndef TEST_HAS_NO_EXCEPTIONS
void test_bad_length () {
try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
catch ( std::bad_array_length & ) { return ; }
catch (...) { assert(false); }
assert ( false );
}
#endif
int main()
@@ -76,16 +79,18 @@ int main()
test<double> ( 14.0, true );
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
testInitList( { 1, 1, 2, 3, 5, 8 } );
testInitList( { 1., 1., 2., 3., 5., 8. } );
testInitList( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
// Make sure we don't pick up the Allocator version here
dynarray<long> d1 ( 20, 3 );
assert ( d1.size() == 20 );
assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));
#ifndef TEST_HAS_NO_EXCEPTIONS
test_bad_length ();
#endif
}

View File

@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// UNSUPPORTED: libcpp-no-exceptions
// dynarray.cons
// explicit dynarray(size_type c);

View File

@@ -42,7 +42,7 @@ void dyn_test( dynarray<T> &dyn, bool CheckEquals = true) {
}
}
template <class T>
void test(const T &val, bool DefaultValueIsIndeterminate = false) {
@@ -53,7 +53,7 @@ void test(const T &val, bool DefaultValueIsIndeterminate = false) {
dynA d1(4);
dyn_test(d1, CheckDefaultValues);
dyn_test_const(d1, CheckDefaultValues);
dynA d2 (7, val);
dyn_test ( d2 );
dyn_test_const ( d2 );

View File

@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.data
// void fill(const T& v);
// const T* data() const noexcept;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -29,11 +28,11 @@ using std::experimental::dynarray;
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
d1.fill ( val );
assert ( std::all_of ( d1.begin (), d1.end (),
[&val]( const T &item ){ return item == val; } ));
assert ( std::all_of ( d1.begin (), d1.end (),
[&val]( const T &item ){ return item == val; } ));
}
int main()
@@ -43,6 +42,4 @@ int main()
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
#else
int main() {}
#endif

View File

@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// UNSUPPORTED: c++98, c++03, c++11
// UNSUPPORTED: libcpp-no-exceptions
// dynarray.overview
// const_reference at(size_type n) const;
// reference at(size_type n);
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -73,7 +72,7 @@ void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
dyn_test ( d1, vals );
dyn_test_const ( d1, vals );
@@ -83,13 +82,11 @@ int main()
{
test ( { 1, 1, 2, 3, 5, 8 } );
test ( { 1., 1., 2., 3., 5., 8. } );
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
#else
int main() {}
#endif

View File

@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.overview
@@ -16,7 +17,7 @@
// iterator end() noexcept;
// const_iterator end() const noexcept;
// const_iterator cend() const noexcept;
//
//
// reverse_iterator rbegin() noexcept;
// const_reverse_iterator rbegin() const noexcept;
// const_reverse_iterator crbegin() const noexcept;
@@ -24,12 +25,11 @@
// const_reverse_iterator rend() const noexcept;
// const_reverse_iterator crend() const noexcept;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cstddef>
#include <cassert>
#include <algorithm>
@@ -47,10 +47,11 @@ void dyn_test_const ( const dynarray<T> &dyn ) {
assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
std::ptrdiff_t ds = static_cast<std::ptrdiff_t>(dyn.size());
assert (ds == std::distance ( dyn.begin(), dyn.end()));
assert (ds == std::distance ( dyn.cbegin(), dyn.cend()));
assert (ds == std::distance ( dyn.rbegin(), dyn.rend()));
assert (ds == std::distance ( dyn.crbegin(), dyn.crend()));
assert ( dyn.begin () == dyn.cbegin ());
assert ( &*dyn.begin () == &*dyn.cbegin ());
@@ -69,10 +70,11 @@ void dyn_test ( dynarray<T> &dyn ) {
assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
std::ptrdiff_t ds = static_cast<std::ptrdiff_t>(dyn.size());
assert (ds == std::distance ( dyn.begin(), dyn.end()));
assert (ds == std::distance ( dyn.cbegin(), dyn.cend()));
assert (ds == std::distance ( dyn.rbegin(), dyn.rend()));
assert (ds == std::distance ( dyn.crbegin(), dyn.crend()));
assert ( dyn.begin () == dyn.cbegin ());
assert ( &*dyn.begin () == &*dyn.cbegin ());
@@ -86,11 +88,11 @@ void dyn_test ( dynarray<T> &dyn ) {
template <class T>
void test ( const T &val ) {
typedef dynarray<T> dynA;
dynA d1 ( 4 );
dyn_test ( d1 );
dyn_test_const ( d1 );
dynA d2 ( 7, val );
dyn_test ( d2 );
dyn_test_const ( d2 );
@@ -103,6 +105,4 @@ int main()
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
#else
int main() {}
#endif

View File

@@ -7,16 +7,15 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.overview
// size_type size() const noexcept;
// size_type max_size() const noexcept;
// bool empty() const noexcept;
// bool empty() const noexcept;
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
@@ -36,7 +35,7 @@ void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
dyn_test ( d1, vals.size ());
}
@@ -45,13 +44,11 @@ int main()
{
test ( { 1, 1, 2, 3, 5, 8 } );
test ( { 1., 1., 2., 3., 5., 8. } );
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
#else
int main() {}
#endif

View File

@@ -58,7 +58,7 @@ void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
dynA d1 ( 4 );
dyn_test ( d1, CheckDefaultValues );
dyn_test_const ( d1, CheckDefaultValues );
dynA d2 ( 7, val );
dyn_test ( d2 );
dyn_test_const ( d2 );

View File

@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.overview
// const_reference at(size_type n) const;
// reference at(size_type n);
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -49,7 +48,7 @@ void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
template <class T>
void test ( std::initializer_list<T> vals ) {
typedef dynarray<T> dynA;
dynA d1 ( vals );
dyn_test ( d1, vals );
dyn_test_const ( d1, vals );
@@ -59,13 +58,11 @@ int main()
{
test ( { 1, 1, 2, 3, 5, 8 } );
test ( { 1., 1., 2., 3., 5., 8. } );
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
std::string("5"), std::string("8")} );
test<int> ( {} );
test<std::complex<double>> ( {} );
test<std::string> ( {} );
}
#else
int main() {}
#endif

View File

@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.data
// template <class Type, class Alloc>
// struct uses_allocator<dynarray<Type>, Alloc> : true_type { };
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__config>
#include <experimental/dynarray>
#include "test_allocator.h"
@@ -26,6 +25,4 @@ int main()
{
static_assert ( std::uses_allocator<dynarray<int>, test_allocator<int>>::value, "" );
}
#else
int main() {}
#endif

View File

@@ -7,18 +7,17 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// dynarray.zero
// dynarray shall provide support for the special case of construction with a size of zero.
// In the case that the size is zero, begin() == end() == unique value.
// The return value of data() is unspecified.
// In the case that the size is zero, begin() == end() == unique value.
// The return value of data() is unspecified.
// The effect of calling front() or back() for a zero-sized dynarray is undefined.
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__config>
#include <experimental/dynarray>
#include <cassert>
@@ -32,7 +31,7 @@ using std::experimental::dynarray;
template <class T>
void test ( ) {
typedef dynarray<T> dynA;
dynA d1 ( 0 );
assert ( d1.size() == 0 );
assert ( d1.begin() == d1.end ());
@@ -45,6 +44,4 @@ int main()
test<std::complex<double>> ();
test<std::string> ();
}
#else
int main() {}
#endif

View File

@@ -0,0 +1,74 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// UNSUPPORTED: libcpp-no-exceptions
// <experimental/filesystem>
// class path
#define _LIBCPP_DEBUG 0
#define _LIBCPP_ASSERT(cond, msg) ((cond) ? ((void)0) : throw 42)
#include <experimental/filesystem>
#include <iterator>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "filesystem_test_helper.hpp"
namespace fs = std::experimental::filesystem;
int main() {
using namespace fs;
// Test incrementing/decrementing a singular iterator
{
path::iterator singular;
try {
++singular;
assert(false);
} catch (int) {}
try {
--singular;
assert(false);
} catch (int) {}
}
// Test decrementing the begin iterator
{
path p("foo/bar");
auto it = p.begin();
try {
--it;
assert(false);
} catch (int) {}
++it;
++it;
try {
++it;
assert(false);
} catch (int) {}
}
// Test incrementing the end iterator
{
path p("foo/bar");
auto it = p.end();
try {
++it;
assert(false);
} catch (int) {}
--it;
--it;
try {
--it;
assert(false);
} catch (int) {}
}
}

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.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
// class path
// path& operator/=(path const&)
// path operator/(path const&, path const&)
#define _LIBCPP_DEBUG 0
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
int AssertCount = 0;
#include <experimental/filesystem>
#include <type_traits>
#include <string_view>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
#include "count_new.hpp"
#include "filesystem_test_helper.hpp"
namespace fs = std::experimental::filesystem;
int main()
{
using namespace fs;
{
path lhs("//foo");
path rhs("/bar");
assert(AssertCount == 0);
lhs /= rhs;
assert(AssertCount == 0);
}
{
path lhs("//foo");
path rhs("/bar");
assert(AssertCount == 0);
(void)(lhs / rhs);
assert(AssertCount == 0);
}
{
path lhs("//foo");
path rhs("//bar");
assert(AssertCount == 0);
lhs /= rhs;
assert(AssertCount == 1);
AssertCount = 0;
}
{
path lhs("//foo");
path rhs("//bar");
assert(AssertCount == 0);
(void)(lhs / rhs);
assert(AssertCount == 1);
}
// FIXME The same error is not diagnosed for the append(Source) and
// append(It, It) overloads.
}

View File

@@ -0,0 +1,106 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
// template <class Tp> struct __is_pathable
// [path.req]
// In addition to the requirements (5), function template parameters named
// `Source` shall be one of:
// * basic_string<_ECharT, _Traits, _Alloc>
// * InputIterator with a value_type of _ECharT
// * A character array, which points to a NTCTS after array-to-pointer decay.
#include <experimental/filesystem>
#include <type_traits>
#include <cassert>
#include "test_macros.h"
#include "test_iterators.h"
#include "min_allocator.h"
#include "constexpr_char_traits.hpp"
namespace fs = std::experimental::filesystem;
using fs::__is_pathable;
template <class Tp>
struct Identity { typedef Tp type; };
template <class Source>
Identity<Source> CheckSourceType(Source const&);
template <class Tp>
using GetSourceType = typename decltype(CheckSourceType(std::declval<Tp>()))::type;
template <class Tp, class Exp,
class ExpQual = typename std::remove_const<Exp>::type>
using CheckPass = std::is_same<ExpQual, GetSourceType<Tp>>;
template <class Source>
using CheckPassSource = std::integral_constant<bool,
CheckPass<Source&, Source>::value &&
CheckPass<Source const&, Source>::value &&
CheckPass<Source&&, Source>::value &&
CheckPass<Source const&&, Source>::value
>;
template <class CharT>
struct MakeTestType {
using value_type = CharT;
using string_type = std::basic_string<CharT>;
using string_type2 = std::basic_string<CharT, std::char_traits<CharT>, min_allocator<CharT>>;
using string_view_type = std::basic_string_view<CharT>;
using string_view_type2 = std::basic_string_view<CharT, constexpr_char_traits<CharT>>;
using cstr_type = CharT* const;
using const_cstr_type = const CharT*;
using array_type = CharT[25];
using const_array_type = const CharT[25];
using iter_type = input_iterator<CharT*>;
using bad_iter_type = input_iterator<signed char*>;
template <class TestT>
static void AssertPathable() {
static_assert(__is_pathable<TestT>::value, "");
static_assert(CheckPassSource<TestT>::value, "cannot pass as Source const&");
ASSERT_SAME_TYPE(CharT, typename __is_pathable<TestT>::__char_type);
}
template <class TestT>
static void AssertNotPathable() {
static_assert(!__is_pathable<TestT>::value, "");
}
static void Test() {
AssertPathable<string_type>();
AssertPathable<string_type2>();
AssertPathable<string_view_type>();
AssertPathable<string_view_type2>();
AssertPathable<cstr_type>();
AssertPathable<const_cstr_type>();
AssertPathable<array_type>();
AssertPathable<const_array_type>();
AssertPathable<iter_type>();
AssertNotPathable<CharT>();
AssertNotPathable<bad_iter_type>();
AssertNotPathable<signed char*>();
}
};
int main() {
MakeTestType<char>::Test();
MakeTestType<wchar_t>::Test();
MakeTestType<char16_t>::Test();
MakeTestType<char32_t>::Test();
}

View File

@@ -0,0 +1,3 @@
# Disable all of the filesystem tests if the correct feature is not available.
if 'c++filesystem' not in config.available_features:
config.unsupported = True

View File

@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <experimental/filesystem>
#include <experimental/filesystem>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <optional>
#include <experimental/optional>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <experimental/type_traits>
#include <experimental/type_traits>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -7,16 +7,15 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/ratio>
// Test that <ratio> is included.
#include <experimental/ratio>
#if _LIBCPP_STD_VER > 11
# ifndef _LIBCPP_RATIO
# error " <experimental/ratio> must include <ratio>"
# endif
#ifndef _LIBCPP_RATIO
# error " <experimental/ratio> must include <ratio>"
#endif
int main()

View File

@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/system_error>
#include <experimental/system_error>
#if _LIBCPP_STD_VER > 11
# ifndef _LIBCPP_SYSTEM_ERROR
# error "<experimental/system_error> must include <system_error>"
# endif
#ifndef _LIBCPP_SYSTEM_ERROR
# error "<experimental/system_error> must include <system_error>"
#endif
int main()

View File

@@ -7,14 +7,13 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/chrono>
#include <experimental/chrono>
#if _LIBCPP_STD_VER > 11
# ifndef _LIBCPP_CHRONO
# error "<experimental/chrono> must include <chrono>"
# endif
#ifndef _LIBCPP_CHRONO
# error "<experimental/chrono> must include <chrono>"
#endif
int main()

View File

@@ -7,15 +7,14 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/tuple>
#include <experimental/tuple>
int main()
{
#if _LIBCPP_STD_VER > 11
# ifndef _LIBCPP_TUPLE
# error "<experimental/tuple> must include <tuple>"
# endif
#endif /* _LIBCPP_STD_VER > 11 */
#ifndef _LIBCPP_TUPLE
# error "<experimental/tuple> must include <tuple>"
#endif
}

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.
//
//===----------------------------------------------------------------------===//
// <experimental/utility>
#include <experimental/utility>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <cstdio>
#include <cstdio>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <cinttypes>
#include <cinttypes>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <fstream>
#include <fstream>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <istream>
#include <istream>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <ostream>
#include <ostream>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <iomanip>
#include <iomanip>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <iosfwd>
#include <iosfwd>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <iostream>
#include <iostream>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <ios>
#include <ios>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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.
//
//===----------------------------------------------------------------------===//
// <streambuf>
#include <streambuf>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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