mirror of
https://github.com/AntelopeIO/cdt-libcxx.git
synced 2026-07-21 13:53:36 +00:00
delete unneeded directories
This commit is contained in:
@@ -1,156 +0,0 @@
|
|||||||
include(ExternalProject)
|
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
|
|
||||||
#==============================================================================
|
|
||||||
# Build Google Benchmark for libc++
|
|
||||||
#==============================================================================
|
|
||||||
|
|
||||||
set(BENCHMARK_LIBCXX_COMPILE_FLAGS
|
|
||||||
-Wno-unused-command-line-argument
|
|
||||||
-nostdinc++
|
|
||||||
-isystem ${LIBCXX_SOURCE_DIR}/include
|
|
||||||
-L${LIBCXX_LIBRARY_DIR}
|
|
||||||
-Wl,-rpath,${LIBCXX_LIBRARY_DIR}
|
|
||||||
)
|
|
||||||
if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
|
|
||||||
list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS
|
|
||||||
-L${LIBCXX_CXX_ABI_LIBRARY_PATH}
|
|
||||||
-Wl,-rpath,${LIBCXX_CXX_ABI_LIBRARY_PATH})
|
|
||||||
endif()
|
|
||||||
split_list(BENCHMARK_LIBCXX_COMPILE_FLAGS)
|
|
||||||
|
|
||||||
ExternalProject_Add(google-benchmark-libcxx
|
|
||||||
EXCLUDE_FROM_ALL ON
|
|
||||||
DEPENDS cxx
|
|
||||||
PREFIX benchmark-libcxx
|
|
||||||
SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark
|
|
||||||
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx
|
|
||||||
CMAKE_CACHE_ARGS
|
|
||||||
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
|
|
||||||
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=RELEASE
|
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
|
||||||
-DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBCXX_COMPILE_FLAGS}
|
|
||||||
-DBENCHMARK_USE_LIBCXX:BOOL=ON
|
|
||||||
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
|
|
||||||
|
|
||||||
#==============================================================================
|
|
||||||
# Build Google Benchmark for the native stdlib
|
|
||||||
#==============================================================================
|
|
||||||
set(BENCHMARK_NATIVE_TARGET_FLAGS)
|
|
||||||
if (LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN)
|
|
||||||
set(BENCHMARK_NATIVE_TARGET_FLAGS
|
|
||||||
-gcc-toolchain ${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN})
|
|
||||||
endif()
|
|
||||||
split_list(BENCHMARK_NATIVE_TARGET_FLAGS)
|
|
||||||
|
|
||||||
if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
|
|
||||||
ExternalProject_Add(google-benchmark-native
|
|
||||||
EXCLUDE_FROM_ALL ON
|
|
||||||
PREFIX benchmark-native
|
|
||||||
SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark
|
|
||||||
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native
|
|
||||||
CMAKE_CACHE_ARGS
|
|
||||||
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
|
|
||||||
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
|
|
||||||
-DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_NATIVE_TARGET_FLAGS}
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=RELEASE
|
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
|
|
||||||
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#==============================================================================
|
|
||||||
# Benchmark tests configuration
|
|
||||||
#==============================================================================
|
|
||||||
add_custom_target(cxx-benchmarks)
|
|
||||||
set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx)
|
|
||||||
set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native)
|
|
||||||
set(BENCHMARK_TEST_COMPILE_FLAGS
|
|
||||||
-std=c++14 -O2
|
|
||||||
-I${BENCHMARK_LIBCXX_INSTALL}/include
|
|
||||||
-I${LIBCXX_SOURCE_DIR}/test/support
|
|
||||||
)
|
|
||||||
set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
|
|
||||||
-nostdinc++
|
|
||||||
-isystem ${LIBCXX_SOURCE_DIR}/include
|
|
||||||
${BENCHMARK_TEST_COMPILE_FLAGS}
|
|
||||||
-Wno-user-defined-literals
|
|
||||||
)
|
|
||||||
set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS
|
|
||||||
-nodefaultlibs
|
|
||||||
-L${BENCHMARK_LIBCXX_INSTALL}/lib/
|
|
||||||
)
|
|
||||||
set(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS
|
|
||||||
${BENCHMARK_NATIVE_TARGET_FLAGS}
|
|
||||||
${BENCHMARK_TEST_COMPILE_FLAGS}
|
|
||||||
)
|
|
||||||
set(BENCHMARK_TEST_NATIVE_LINK_FLAGS
|
|
||||||
${BENCHMARK_NATIVE_TARGET_FLAGS}
|
|
||||||
-L${BENCHMARK_NATIVE_INSTALL}/lib
|
|
||||||
)
|
|
||||||
split_list(BENCHMARK_TEST_COMPILE_FLAGS)
|
|
||||||
split_list(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS)
|
|
||||||
split_list(BENCHMARK_TEST_LIBCXX_LINK_FLAGS)
|
|
||||||
split_list(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS)
|
|
||||||
split_list(BENCHMARK_TEST_NATIVE_LINK_FLAGS)
|
|
||||||
macro(add_benchmark_test name source_file)
|
|
||||||
set(libcxx_target ${name}_libcxx)
|
|
||||||
add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file})
|
|
||||||
add_dependencies(${libcxx_target} cxx google-benchmark-libcxx)
|
|
||||||
add_dependencies(cxx-benchmarks ${libcxx_target})
|
|
||||||
if (LIBCXX_ENABLE_SHARED)
|
|
||||||
target_link_libraries(${libcxx_target} cxx_shared)
|
|
||||||
else()
|
|
||||||
target_link_libraries(${libcxx_target} cxx_static)
|
|
||||||
endif()
|
|
||||||
if (TARGET cxx_experimental)
|
|
||||||
target_link_libraries(${libcxx_target} cxx_experimental)
|
|
||||||
endif()
|
|
||||||
target_link_libraries(${libcxx_target} -lbenchmark)
|
|
||||||
set_target_properties(${libcxx_target}
|
|
||||||
PROPERTIES
|
|
||||||
OUTPUT_NAME "${name}.libcxx.out"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}"
|
|
||||||
COMPILE_FLAGS "${BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS}"
|
|
||||||
LINK_FLAGS "${BENCHMARK_TEST_LIBCXX_LINK_FLAGS}")
|
|
||||||
if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
|
|
||||||
set(native_target ${name}_native)
|
|
||||||
add_executable(${native_target} EXCLUDE_FROM_ALL ${source_file})
|
|
||||||
add_dependencies(${native_target} google-benchmark-native
|
|
||||||
google-benchmark-libcxx)
|
|
||||||
target_link_libraries(${native_target} -lbenchmark)
|
|
||||||
if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")
|
|
||||||
target_link_libraries(${native_target} -lstdc++fs)
|
|
||||||
elseif (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++")
|
|
||||||
target_link_libraries(${native_target} -lc++experimental)
|
|
||||||
endif()
|
|
||||||
if (LIBCXX_HAS_PTHREAD_LIB)
|
|
||||||
target_link_libraries(${native_target} -pthread)
|
|
||||||
endif()
|
|
||||||
add_dependencies(cxx-benchmarks ${native_target})
|
|
||||||
set_target_properties(${native_target}
|
|
||||||
PROPERTIES
|
|
||||||
OUTPUT_NAME "${name}.native.out"
|
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}"
|
|
||||||
INCLUDE_DIRECTORIES ""
|
|
||||||
COMPILE_FLAGS "${BENCHMARK_TEST_NATIVE_COMPILE_FLAGS}"
|
|
||||||
LINK_FLAGS "${BENCHMARK_TEST_NATIVE_LINK_FLAGS}")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
|
|
||||||
#==============================================================================
|
|
||||||
# Register Benchmark tests
|
|
||||||
#==============================================================================
|
|
||||||
file(GLOB BENCHMARK_TESTS "*.bench.cpp")
|
|
||||||
foreach(test_path ${BENCHMARK_TESTS})
|
|
||||||
get_filename_component(test_file "${test_path}" NAME)
|
|
||||||
string(REPLACE ".bench.cpp" "" test_name "${test_file}")
|
|
||||||
if (NOT DEFINED ${test_name}_REPORTED)
|
|
||||||
message(STATUS "Adding Benchmark: ${test_file}")
|
|
||||||
# Only report the adding of the benchmark once.
|
|
||||||
set(${test_name}_REPORTED ON CACHE INTERNAL "")
|
|
||||||
endif()
|
|
||||||
add_benchmark_test(${test_name} ${test_file})
|
|
||||||
endforeach()
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
#ifndef BENCHMARK_CONTAINER_BENCHMARKS_HPP
|
|
||||||
#define BENCHMARK_CONTAINER_BENCHMARKS_HPP
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
|
|
||||||
namespace ContainerBenchmarks {
|
|
||||||
|
|
||||||
|
|
||||||
template <class Container, class GenInputs>
|
|
||||||
void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) {
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
const auto begin = in.begin();
|
|
||||||
const auto end = in.end();
|
|
||||||
benchmark::DoNotOptimize(&in);
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
Container c(begin, end);
|
|
||||||
benchmark::DoNotOptimize(c.data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Container, class GenInputs>
|
|
||||||
void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) {
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
const auto end = in.end();
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
c.clear();
|
|
||||||
for (auto it = in.begin(); it != end; ++it) {
|
|
||||||
benchmark::DoNotOptimize(&(*c.insert(*it).first));
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Container, class GenInputs>
|
|
||||||
void BM_InsertValueRehash(benchmark::State& st, Container c, GenInputs gen) {
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
const auto end = in.end();
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
c.clear();
|
|
||||||
c.rehash(16);
|
|
||||||
for (auto it = in.begin(); it != end; ++it) {
|
|
||||||
benchmark::DoNotOptimize(&(*c.insert(*it).first));
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <class Container, class GenInputs>
|
|
||||||
void BM_InsertDuplicate(benchmark::State& st, Container c, GenInputs gen) {
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
const auto end = in.end();
|
|
||||||
c.insert(in.begin(), in.end());
|
|
||||||
benchmark::DoNotOptimize(&c);
|
|
||||||
benchmark::DoNotOptimize(&in);
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
for (auto it = in.begin(); it != end; ++it) {
|
|
||||||
benchmark::DoNotOptimize(&(*c.insert(*it).first));
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <class Container, class GenInputs>
|
|
||||||
void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) {
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
const auto end = in.end();
|
|
||||||
c.insert(in.begin(), in.end());
|
|
||||||
benchmark::DoNotOptimize(&c);
|
|
||||||
benchmark::DoNotOptimize(&in);
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
for (auto it = in.begin(); it != end; ++it) {
|
|
||||||
benchmark::DoNotOptimize(&(*c.emplace(*it).first));
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Container, class GenInputs>
|
|
||||||
static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
c.insert(in.begin(), in.end());
|
|
||||||
benchmark::DoNotOptimize(&(*c.begin()));
|
|
||||||
const auto end = in.data() + in.size();
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
for (auto it = in.data(); it != end; ++it) {
|
|
||||||
benchmark::DoNotOptimize(&(*c.find(*it)));
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Container, class GenInputs>
|
|
||||||
static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
|
|
||||||
c.rehash(8);
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
c.insert(in.begin(), in.end());
|
|
||||||
benchmark::DoNotOptimize(&(*c.begin()));
|
|
||||||
const auto end = in.data() + in.size();
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
for (auto it = in.data(); it != end; ++it) {
|
|
||||||
benchmark::DoNotOptimize(&(*c.find(*it)));
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace ContainerBenchmarks
|
|
||||||
|
|
||||||
#endif // BENCHMARK_CONTAINER_BENCHMARKS_HPP
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
#ifndef BENCHMARK_GENERATE_INPUT_HPP
|
|
||||||
#define BENCHMARK_GENERATE_INPUT_HPP
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <random>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <climits>
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
static const char Letters[] = {
|
|
||||||
'0','1','2','3','4',
|
|
||||||
'5','6','7','8','9',
|
|
||||||
'A','B','C','D','E','F',
|
|
||||||
'G','H','I','J','K',
|
|
||||||
'L','M','N','O','P',
|
|
||||||
'Q','R','S','T','U',
|
|
||||||
'V','W','X','Y','Z',
|
|
||||||
'a','b','c','d','e','f',
|
|
||||||
'g','h','i','j','k',
|
|
||||||
'l','m','n','o','p',
|
|
||||||
'q','r','s','t','u',
|
|
||||||
'v','w','x','y','z'
|
|
||||||
};
|
|
||||||
static const std::size_t LettersSize = sizeof(Letters);
|
|
||||||
|
|
||||||
inline std::default_random_engine& getRandomEngine() {
|
|
||||||
static std::default_random_engine RandEngine(std::random_device{}());
|
|
||||||
return RandEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline char getRandomChar() {
|
|
||||||
std::uniform_int_distribution<> LettersDist(0, LettersSize-1);
|
|
||||||
return Letters[LettersDist(getRandomEngine())];
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
inline IntT getRandomInteger() {
|
|
||||||
std::uniform_int_distribution<IntT> dist;
|
|
||||||
return dist(getRandomEngine());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string getRandomString(std::size_t Len) {
|
|
||||||
std::string str(Len, 0);
|
|
||||||
std::generate_n(str.begin(), Len, &getRandomChar);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
inline std::vector<IntT> getDuplicateIntegerInputs(size_t N) {
|
|
||||||
std::vector<IntT> inputs(N, static_cast<IntT>(-1));
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
inline std::vector<IntT> getSortedIntegerInputs(size_t N) {
|
|
||||||
std::vector<IntT> inputs;
|
|
||||||
for (size_t i=0; i < N; i += 1)
|
|
||||||
inputs.push_back(i);
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
std::vector<IntT> getSortedLargeIntegerInputs(size_t N) {
|
|
||||||
std::vector<IntT> inputs;
|
|
||||||
for (size_t i=0; i < N; ++i) {
|
|
||||||
inputs.push_back(i + N);
|
|
||||||
}
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
std::vector<IntT> getSortedTopBitsIntegerInputs(size_t N) {
|
|
||||||
std::vector<IntT> inputs = getSortedIntegerInputs<IntT>(N);
|
|
||||||
for (auto& E : inputs) E <<= ((sizeof(IntT) / 2) * CHAR_BIT);
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
inline std::vector<IntT> getReverseSortedIntegerInputs(size_t N) {
|
|
||||||
std::vector<IntT> inputs;
|
|
||||||
std::size_t i = N;
|
|
||||||
while (i > 0) {
|
|
||||||
--i;
|
|
||||||
inputs.push_back(i);
|
|
||||||
}
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
std::vector<IntT> getPipeOrganIntegerInputs(size_t N) {
|
|
||||||
std::vector<IntT> v; v.reserve(N);
|
|
||||||
for (size_t i = 0; i < N/2; ++i) v.push_back(i);
|
|
||||||
for (size_t i = N/2; i < N; ++i) v.push_back(N - i);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <class IntT>
|
|
||||||
std::vector<IntT> getRandomIntegerInputs(size_t N) {
|
|
||||||
std::vector<IntT> inputs;
|
|
||||||
for (size_t i=0; i < N; ++i) {
|
|
||||||
inputs.push_back(getRandomInteger<IntT>());
|
|
||||||
}
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<std::string> getDuplicateStringInputs(size_t N) {
|
|
||||||
std::vector<std::string> inputs(N, getRandomString(1024));
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<std::string> getRandomStringInputs(size_t N) {
|
|
||||||
std::vector<std::string> inputs;
|
|
||||||
for (size_t i=0; i < N; ++i) {
|
|
||||||
inputs.push_back(getRandomString(1024));
|
|
||||||
}
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<std::string> getSortedStringInputs(size_t N) {
|
|
||||||
std::vector<std::string> inputs = getRandomStringInputs(N);
|
|
||||||
std::sort(inputs.begin(), inputs.end());
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<std::string> getReverseSortedStringInputs(size_t N) {
|
|
||||||
std::vector<std::string> inputs = getSortedStringInputs(N);
|
|
||||||
std::reverse(inputs.begin(), inputs.end());
|
|
||||||
return inputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::vector<const char*> getRandomCStringInputs(size_t N) {
|
|
||||||
static std::vector<std::string> inputs = getRandomStringInputs(N);
|
|
||||||
std::vector<const char*> cinputs;
|
|
||||||
for (auto const& str : inputs)
|
|
||||||
cinputs.push_back(str.c_str());
|
|
||||||
return cinputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // BENCHMARK_GENERATE_INPUT_HPP
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
#include <unordered_set>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
#include "GenerateInput.hpp"
|
|
||||||
|
|
||||||
constexpr std::size_t TestNumInputs = 1024;
|
|
||||||
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_Sort(benchmark::State& st, GenInputs gen) {
|
|
||||||
using ValueType = typename decltype(gen(0))::value_type;
|
|
||||||
const auto in = gen(st.range(0));
|
|
||||||
std::vector<ValueType> inputs[5];
|
|
||||||
auto reset_inputs = [&]() {
|
|
||||||
for (auto& C : inputs) {
|
|
||||||
C = in;
|
|
||||||
benchmark::DoNotOptimize(C.data());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reset_inputs();
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
for (auto& I : inputs) {
|
|
||||||
std::sort(I.data(), I.data() + I.size());
|
|
||||||
benchmark::DoNotOptimize(I.data());
|
|
||||||
}
|
|
||||||
st.PauseTiming();
|
|
||||||
reset_inputs();
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
st.ResumeTiming();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, random_uint32,
|
|
||||||
getRandomIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, sorted_ascending_uint32,
|
|
||||||
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, sorted_descending_uint32,
|
|
||||||
getReverseSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, single_element_uint32,
|
|
||||||
getDuplicateIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, pipe_organ_uint32,
|
|
||||||
getPipeOrganIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, random_strings,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, sorted_ascending_strings,
|
|
||||||
getSortedStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, sorted_descending_strings,
|
|
||||||
getReverseSortedStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Sort, single_element_strings,
|
|
||||||
getDuplicateStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
BENCHMARK_MAIN()
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
#include <experimental/filesystem>
|
|
||||||
|
|
||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
#include "GenerateInput.hpp"
|
|
||||||
#include "test_iterators.h"
|
|
||||||
|
|
||||||
namespace fs = std::experimental::filesystem;
|
|
||||||
|
|
||||||
static const size_t TestNumInputs = 1024;
|
|
||||||
|
|
||||||
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_PathConstructString(benchmark::State &st, GenInputs gen) {
|
|
||||||
using namespace fs;
|
|
||||||
const auto in = gen(st.range(0));
|
|
||||||
path PP;
|
|
||||||
for (auto& Part : in)
|
|
||||||
PP /= Part;
|
|
||||||
benchmark::DoNotOptimize(PP.native().data());
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
const path P(PP.native());
|
|
||||||
benchmark::DoNotOptimize(P.native().data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK_CAPTURE(BM_PathConstructString, large_string,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_PathConstructCStr(benchmark::State &st, GenInputs gen) {
|
|
||||||
using namespace fs;
|
|
||||||
const auto in = gen(st.range(0));
|
|
||||||
path PP;
|
|
||||||
for (auto& Part : in)
|
|
||||||
PP /= Part;
|
|
||||||
benchmark::DoNotOptimize(PP.native().data());
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
const path P(PP.native().c_str());
|
|
||||||
benchmark::DoNotOptimize(P.native().data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
template <template <class...> class ItType, class GenInputs>
|
|
||||||
void BM_PathConstructIter(benchmark::State &st, GenInputs gen) {
|
|
||||||
using namespace fs;
|
|
||||||
using Iter = ItType<std::string::const_iterator>;
|
|
||||||
const auto in = gen(st.range(0));
|
|
||||||
path PP;
|
|
||||||
for (auto& Part : in)
|
|
||||||
PP /= Part;
|
|
||||||
auto Start = Iter(PP.native().begin());
|
|
||||||
auto End = Iter(PP.native().end());
|
|
||||||
benchmark::DoNotOptimize(PP.native().data());
|
|
||||||
benchmark::DoNotOptimize(Start);
|
|
||||||
benchmark::DoNotOptimize(End);
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
const path P(Start, End);
|
|
||||||
benchmark::DoNotOptimize(P.native().data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_PathConstructInputIter(benchmark::State &st, GenInputs gen) {
|
|
||||||
BM_PathConstructIter<input_iterator>(st, gen);
|
|
||||||
}
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_PathConstructForwardIter(benchmark::State &st, GenInputs gen) {
|
|
||||||
BM_PathConstructIter<forward_iterator>(st, gen);
|
|
||||||
}
|
|
||||||
BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_PathIterateMultipleTimes(benchmark::State &st, GenInputs gen) {
|
|
||||||
using namespace fs;
|
|
||||||
const auto in = gen(st.range(0));
|
|
||||||
path PP;
|
|
||||||
for (auto& Part : in)
|
|
||||||
PP /= Part;
|
|
||||||
benchmark::DoNotOptimize(PP.native().data());
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
for (auto &E : PP) {
|
|
||||||
benchmark::DoNotOptimize(E.native().data());
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_PathIterateOnce(benchmark::State &st, GenInputs gen) {
|
|
||||||
using namespace fs;
|
|
||||||
const auto in = gen(st.range(0));
|
|
||||||
path PP;
|
|
||||||
for (auto& Part : in)
|
|
||||||
PP /= Part;
|
|
||||||
benchmark::DoNotOptimize(PP.native().data());
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
const path P = PP.native();
|
|
||||||
for (auto &E : P) {
|
|
||||||
benchmark::DoNotOptimize(E.native().data());
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
template <class GenInputs>
|
|
||||||
void BM_PathIterateOnceBackwards(benchmark::State &st, GenInputs gen) {
|
|
||||||
using namespace fs;
|
|
||||||
const auto in = gen(st.range(0));
|
|
||||||
path PP;
|
|
||||||
for (auto& Part : in)
|
|
||||||
PP /= Part;
|
|
||||||
benchmark::DoNotOptimize(PP.native().data());
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
const path P = PP.native();
|
|
||||||
const auto B = P.begin();
|
|
||||||
auto I = P.end();
|
|
||||||
while (I != B) {
|
|
||||||
--I;
|
|
||||||
benchmark::DoNotOptimize(*I);
|
|
||||||
}
|
|
||||||
benchmark::DoNotOptimize(*I);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK_CAPTURE(BM_PathIterateOnceBackwards, iterate_elements,
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_MAIN()
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#include <unordered_set>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
#include "GenerateInput.hpp"
|
|
||||||
|
|
||||||
constexpr std::size_t MAX_STRING_LEN = 8 << 14;
|
|
||||||
|
|
||||||
// Benchmark when there is no match.
|
|
||||||
static void BM_StringFindNoMatch(benchmark::State &state) {
|
|
||||||
std::string s1(state.range(0), '-');
|
|
||||||
std::string s2(8, '*');
|
|
||||||
while (state.KeepRunning())
|
|
||||||
benchmark::DoNotOptimize(s1.find(s2));
|
|
||||||
}
|
|
||||||
BENCHMARK(BM_StringFindNoMatch)->Range(10, MAX_STRING_LEN);
|
|
||||||
|
|
||||||
// Benchmark when the string matches first time.
|
|
||||||
static void BM_StringFindAllMatch(benchmark::State &state) {
|
|
||||||
std::string s1(MAX_STRING_LEN, '-');
|
|
||||||
std::string s2(state.range(0), '-');
|
|
||||||
while (state.KeepRunning())
|
|
||||||
benchmark::DoNotOptimize(s1.find(s2));
|
|
||||||
}
|
|
||||||
BENCHMARK(BM_StringFindAllMatch)->Range(1, MAX_STRING_LEN);
|
|
||||||
|
|
||||||
// Benchmark when the string matches somewhere in the end.
|
|
||||||
static void BM_StringFindMatch1(benchmark::State &state) {
|
|
||||||
std::string s1(MAX_STRING_LEN / 2, '*');
|
|
||||||
s1 += std::string(state.range(0), '-');
|
|
||||||
std::string s2(state.range(0), '-');
|
|
||||||
while (state.KeepRunning())
|
|
||||||
benchmark::DoNotOptimize(s1.find(s2));
|
|
||||||
}
|
|
||||||
BENCHMARK(BM_StringFindMatch1)->Range(1, MAX_STRING_LEN / 4);
|
|
||||||
|
|
||||||
// Benchmark when the string matches somewhere from middle to the end.
|
|
||||||
static void BM_StringFindMatch2(benchmark::State &state) {
|
|
||||||
std::string s1(MAX_STRING_LEN / 2, '*');
|
|
||||||
s1 += std::string(state.range(0), '-');
|
|
||||||
s1 += std::string(state.range(0), '*');
|
|
||||||
std::string s2(state.range(0), '-');
|
|
||||||
while (state.KeepRunning())
|
|
||||||
benchmark::DoNotOptimize(s1.find(s2));
|
|
||||||
}
|
|
||||||
BENCHMARK(BM_StringFindMatch2)->Range(1, MAX_STRING_LEN / 4);
|
|
||||||
|
|
||||||
BENCHMARK_MAIN()
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
double __attribute__((noinline)) istream_numbers();
|
|
||||||
|
|
||||||
double istream_numbers() {
|
|
||||||
const char *a[] = {
|
|
||||||
"-6 69 -71 2.4882e-02 -100 101 -2.00005 5000000 -50000000",
|
|
||||||
"-25 71 7 -9.3262e+01 -100 101 -2.00005 5000000 -50000000",
|
|
||||||
"-14 53 46 -6.7026e-02 -100 101 -2.00005 5000000 -50000000"
|
|
||||||
};
|
|
||||||
|
|
||||||
int a1, a2, a3, a4, a5, a6, a7;
|
|
||||||
double f1 = 0.0, f2 = 0.0, q = 0.0;
|
|
||||||
for (int i=0; i < 3; i++) {
|
|
||||||
std::istringstream s(a[i]);
|
|
||||||
s >> a1
|
|
||||||
>> a2
|
|
||||||
>> a3
|
|
||||||
>> f1
|
|
||||||
>> a4
|
|
||||||
>> a5
|
|
||||||
>> f2
|
|
||||||
>> a6
|
|
||||||
>> a7;
|
|
||||||
q += (a1 + a2 + a3 + a4 + a5 + a6 + a7 + f1 + f2)/1000000;
|
|
||||||
}
|
|
||||||
return q;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void BM_Istream_numbers(benchmark::State &state) {
|
|
||||||
double i = 0;
|
|
||||||
while (state.KeepRunning())
|
|
||||||
benchmark::DoNotOptimize(i += istream_numbers());
|
|
||||||
}
|
|
||||||
|
|
||||||
BENCHMARK(BM_Istream_numbers)->RangeMultiplier(2)->Range(1024, 4096);
|
|
||||||
BENCHMARK_MAIN()
|
|
||||||
@@ -1,306 +0,0 @@
|
|||||||
#include <unordered_set>
|
|
||||||
#include <vector>
|
|
||||||
#include <functional>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
|
|
||||||
#include "ContainerBenchmarks.hpp"
|
|
||||||
#include "GenerateInput.hpp"
|
|
||||||
|
|
||||||
using namespace ContainerBenchmarks;
|
|
||||||
|
|
||||||
constexpr std::size_t TestNumInputs = 1024;
|
|
||||||
|
|
||||||
template <class _Size>
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
_Size loadword(const void* __p) {
|
|
||||||
_Size __r;
|
|
||||||
std::memcpy(&__r, __p, sizeof(__r));
|
|
||||||
return __r;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t rotate_by_at_least_1(std::size_t __val, int __shift) {
|
|
||||||
return (__val >> __shift) | (__val << (64 - __shift));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t hash_len_16(std::size_t __u, std::size_t __v) {
|
|
||||||
const std::size_t __mul = 0x9ddfea08eb382d69ULL;
|
|
||||||
std::size_t __a = (__u ^ __v) * __mul;
|
|
||||||
__a ^= (__a >> 47);
|
|
||||||
std::size_t __b = (__v ^ __a) * __mul;
|
|
||||||
__b ^= (__b >> 47);
|
|
||||||
__b *= __mul;
|
|
||||||
return __b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <std::size_t _Len>
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t hash_len_0_to_8(const char* __s) {
|
|
||||||
static_assert(_Len == 4 || _Len == 8, "");
|
|
||||||
const uint64_t __a = loadword<uint32_t>(__s);
|
|
||||||
const uint64_t __b = loadword<uint32_t>(__s + _Len - 4);
|
|
||||||
return hash_len_16(_Len + (__a << 3), __b);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct UInt32Hash {
|
|
||||||
UInt32Hash() = default;
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t operator()(uint32_t data) const {
|
|
||||||
return hash_len_0_to_8<4>(reinterpret_cast<const char*>(&data));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UInt64Hash {
|
|
||||||
UInt64Hash() = default;
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t operator()(uint64_t data) const {
|
|
||||||
return hash_len_0_to_8<8>(reinterpret_cast<const char*>(&data));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UInt128Hash {
|
|
||||||
UInt128Hash() = default;
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t operator()(__uint128_t data) const {
|
|
||||||
const __uint128_t __mask = static_cast<std::size_t>(-1);
|
|
||||||
const std::size_t __a = (std::size_t)(data & __mask);
|
|
||||||
const std::size_t __b = (std::size_t)((data & (__mask << 64)) >> 64);
|
|
||||||
return hash_len_16(__a, rotate_by_at_least_1(__b + 16, 16)) ^ __b;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UInt32Hash2 {
|
|
||||||
UInt32Hash2() = default;
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t operator()(uint32_t data) const {
|
|
||||||
const uint32_t __m = 0x5bd1e995;
|
|
||||||
const uint32_t __r = 24;
|
|
||||||
uint32_t __h = 4;
|
|
||||||
uint32_t __k = data;
|
|
||||||
__k *= __m;
|
|
||||||
__k ^= __k >> __r;
|
|
||||||
__k *= __m;
|
|
||||||
__h *= __m;
|
|
||||||
__h ^= __k;
|
|
||||||
__h ^= __h >> 13;
|
|
||||||
__h *= __m;
|
|
||||||
__h ^= __h >> 15;
|
|
||||||
return __h;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct UInt64Hash2 {
|
|
||||||
UInt64Hash2() = default;
|
|
||||||
inline __attribute__((__always_inline__))
|
|
||||||
std::size_t operator()(uint64_t data) const {
|
|
||||||
return hash_len_0_to_8<8>(reinterpret_cast<const char*>(&data));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
|
||||||
// BM_Hash
|
|
||||||
// ---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
template <class HashFn, class GenInputs>
|
|
||||||
void BM_Hash(benchmark::State& st, HashFn fn, GenInputs gen) {
|
|
||||||
auto in = gen(st.range(0));
|
|
||||||
const auto end = in.data() + in.size();
|
|
||||||
std::size_t last_hash = 0;
|
|
||||||
benchmark::DoNotOptimize(&last_hash);
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
for (auto it = in.data(); it != end; ++it) {
|
|
||||||
benchmark::DoNotOptimize(last_hash += fn(*it));
|
|
||||||
}
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Hash,
|
|
||||||
uint32_random_std_hash,
|
|
||||||
std::hash<uint32_t>{},
|
|
||||||
getRandomIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Hash,
|
|
||||||
uint32_random_custom_hash,
|
|
||||||
UInt32Hash{},
|
|
||||||
getRandomIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Hash,
|
|
||||||
uint32_top_std_hash,
|
|
||||||
std::hash<uint32_t>{},
|
|
||||||
getSortedTopBitsIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_Hash,
|
|
||||||
uint32_top_custom_hash,
|
|
||||||
UInt32Hash{},
|
|
||||||
getSortedTopBitsIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
|
||||||
// BM_InsertValue
|
|
||||||
// ---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
|
|
||||||
// Sorted Assending //
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertValue,
|
|
||||||
unordered_set_uint32,
|
|
||||||
std::unordered_set<uint32_t>{},
|
|
||||||
getRandomIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertValue,
|
|
||||||
unordered_set_uint32_sorted,
|
|
||||||
std::unordered_set<uint32_t>{},
|
|
||||||
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
// Top Bytes //
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertValue,
|
|
||||||
unordered_set_top_bits_uint32,
|
|
||||||
std::unordered_set<uint32_t>{},
|
|
||||||
getSortedTopBitsIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertValueRehash,
|
|
||||||
unordered_set_top_bits_uint32,
|
|
||||||
std::unordered_set<uint32_t, UInt32Hash>{},
|
|
||||||
getSortedTopBitsIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
// String //
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertValue,
|
|
||||||
unordered_set_string,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertValueRehash,
|
|
||||||
unordered_set_string,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
|
||||||
// BM_Find
|
|
||||||
// ---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
// Random //
|
|
||||||
BENCHMARK_CAPTURE(BM_Find,
|
|
||||||
unordered_set_random_uint64,
|
|
||||||
std::unordered_set<uint64_t>{},
|
|
||||||
getRandomIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_FindRehash,
|
|
||||||
unordered_set_random_uint64,
|
|
||||||
std::unordered_set<uint64_t, UInt64Hash>{},
|
|
||||||
getRandomIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
// Sorted //
|
|
||||||
BENCHMARK_CAPTURE(BM_Find,
|
|
||||||
unordered_set_sorted_uint64,
|
|
||||||
std::unordered_set<uint64_t>{},
|
|
||||||
getSortedIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_FindRehash,
|
|
||||||
unordered_set_sorted_uint64,
|
|
||||||
std::unordered_set<uint64_t, UInt64Hash>{},
|
|
||||||
getSortedIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
// Sorted //
|
|
||||||
#if 1
|
|
||||||
BENCHMARK_CAPTURE(BM_Find,
|
|
||||||
unordered_set_sorted_uint128,
|
|
||||||
std::unordered_set<__uint128_t, UInt128Hash>{},
|
|
||||||
getSortedTopBitsIntegerInputs<__uint128_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_FindRehash,
|
|
||||||
unordered_set_sorted_uint128,
|
|
||||||
std::unordered_set<__uint128_t, UInt128Hash>{},
|
|
||||||
getSortedTopBitsIntegerInputs<__uint128_t>)->Arg(TestNumInputs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Sorted //
|
|
||||||
BENCHMARK_CAPTURE(BM_Find,
|
|
||||||
unordered_set_sorted_uint32,
|
|
||||||
std::unordered_set<uint32_t>{},
|
|
||||||
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_FindRehash,
|
|
||||||
unordered_set_sorted_uint32,
|
|
||||||
std::unordered_set<uint32_t, UInt32Hash2>{},
|
|
||||||
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
// Sorted Ascending //
|
|
||||||
BENCHMARK_CAPTURE(BM_Find,
|
|
||||||
unordered_set_sorted_large_uint64,
|
|
||||||
std::unordered_set<uint64_t>{},
|
|
||||||
getSortedLargeIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_FindRehash,
|
|
||||||
unordered_set_sorted_large_uint64,
|
|
||||||
std::unordered_set<uint64_t, UInt64Hash>{},
|
|
||||||
getSortedLargeIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
// Top Bits //
|
|
||||||
BENCHMARK_CAPTURE(BM_Find,
|
|
||||||
unordered_set_top_bits_uint64,
|
|
||||||
std::unordered_set<uint64_t>{},
|
|
||||||
getSortedTopBitsIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_FindRehash,
|
|
||||||
unordered_set_top_bits_uint64,
|
|
||||||
std::unordered_set<uint64_t, UInt64Hash>{},
|
|
||||||
getSortedTopBitsIntegerInputs<uint64_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
// String //
|
|
||||||
BENCHMARK_CAPTURE(BM_Find,
|
|
||||||
unordered_set_string,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_FindRehash,
|
|
||||||
unordered_set_string,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertDuplicate,
|
|
||||||
unordered_set_int,
|
|
||||||
std::unordered_set<int>{},
|
|
||||||
getRandomIntegerInputs<int>)->Arg(TestNumInputs);
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertDuplicate,
|
|
||||||
unordered_set_string,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
|
|
||||||
unordered_set_int,
|
|
||||||
std::unordered_set<int>{},
|
|
||||||
getRandomIntegerInputs<int>)->Arg(TestNumInputs);
|
|
||||||
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
|
|
||||||
unordered_set_string,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertDuplicate,
|
|
||||||
unordered_set_int_insert_arg,
|
|
||||||
std::unordered_set<int>{},
|
|
||||||
getRandomIntegerInputs<int>)->Arg(TestNumInputs);
|
|
||||||
BENCHMARK_CAPTURE(BM_InsertDuplicate,
|
|
||||||
unordered_set_string_insert_arg,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
|
|
||||||
unordered_set_int_insert_arg,
|
|
||||||
std::unordered_set<int>{},
|
|
||||||
getRandomIntegerInputs<unsigned>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
|
|
||||||
unordered_set_string_arg,
|
|
||||||
std::unordered_set<std::string>{},
|
|
||||||
getRandomCStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_MAIN()
|
|
||||||
@@ -1,42 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
|
|
||||||
static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
auto sp = std::make_shared<int>(42);
|
|
||||||
benchmark::DoNotOptimize(sp.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK(BM_SharedPtrCreateDestroy);
|
|
||||||
|
|
||||||
static void BM_SharedPtrIncDecRef(benchmark::State& st) {
|
|
||||||
auto sp = std::make_shared<int>(42);
|
|
||||||
benchmark::DoNotOptimize(sp.get());
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
std::shared_ptr<int> sp2(sp);
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK(BM_SharedPtrIncDecRef);
|
|
||||||
|
|
||||||
static void BM_WeakPtrIncDecRef(benchmark::State& st) {
|
|
||||||
auto sp = std::make_shared<int>(42);
|
|
||||||
benchmark::DoNotOptimize(sp.get());
|
|
||||||
while (st.KeepRunning()) {
|
|
||||||
std::weak_ptr<int> wp(sp);
|
|
||||||
benchmark::ClobberMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BENCHMARK(BM_WeakPtrIncDecRef);
|
|
||||||
|
|
||||||
BENCHMARK_MAIN()
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#include <vector>
|
|
||||||
#include <functional>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#include "benchmark/benchmark_api.h"
|
|
||||||
|
|
||||||
#include "ContainerBenchmarks.hpp"
|
|
||||||
#include "GenerateInput.hpp"
|
|
||||||
|
|
||||||
using namespace ContainerBenchmarks;
|
|
||||||
|
|
||||||
constexpr std::size_t TestNumInputs = 1024;
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_ConstructIterIter,
|
|
||||||
vector_char,
|
|
||||||
std::vector<char>{},
|
|
||||||
getRandomIntegerInputs<char>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_ConstructIterIter,
|
|
||||||
vector_size_t,
|
|
||||||
std::vector<size_t>{},
|
|
||||||
getRandomIntegerInputs<size_t>)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
BENCHMARK_CAPTURE(BM_ConstructIterIter,
|
|
||||||
vector_string,
|
|
||||||
std::vector<std::string>{},
|
|
||||||
getRandomStringInputs)->Arg(TestNumInputs);
|
|
||||||
|
|
||||||
|
|
||||||
BENCHMARK_MAIN()
|
|
||||||
@@ -1,502 +0,0 @@
|
|||||||
.. _BuildingLibcxx:
|
|
||||||
|
|
||||||
===============
|
|
||||||
Building libc++
|
|
||||||
===============
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
.. _build instructions:
|
|
||||||
|
|
||||||
Getting Started
|
|
||||||
===============
|
|
||||||
|
|
||||||
On Mac OS 10.7 (Lion) and later, the easiest way to get this library is to install
|
|
||||||
Xcode 4.2 or later. However if you want to install tip-of-trunk from here
|
|
||||||
(getting the bleeding edge), read on.
|
|
||||||
|
|
||||||
The basic steps needed to build libc++ are:
|
|
||||||
|
|
||||||
#. Checkout LLVM:
|
|
||||||
|
|
||||||
* ``cd where-you-want-llvm-to-live``
|
|
||||||
* ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm``
|
|
||||||
|
|
||||||
#. Checkout libc++:
|
|
||||||
|
|
||||||
* ``cd where-you-want-llvm-to-live``
|
|
||||||
* ``cd llvm/projects``
|
|
||||||
* ``svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx``
|
|
||||||
|
|
||||||
#. Checkout libc++abi:
|
|
||||||
|
|
||||||
* ``cd where-you-want-llvm-to-live``
|
|
||||||
* ``cd llvm/projects``
|
|
||||||
* ``svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi``
|
|
||||||
|
|
||||||
#. Configure and build libc++ with libc++abi:
|
|
||||||
|
|
||||||
CMake is the only supported configuration system.
|
|
||||||
|
|
||||||
Clang is the preferred compiler when building and using libc++.
|
|
||||||
|
|
||||||
* ``cd where you want to build llvm``
|
|
||||||
* ``mkdir build``
|
|
||||||
* ``cd build``
|
|
||||||
* ``cmake -G <generator> [options] <path to llvm sources>``
|
|
||||||
|
|
||||||
For more information about configuring libc++ see :ref:`CMake Options`.
|
|
||||||
|
|
||||||
* ``make cxx`` --- will build libc++ and libc++abi.
|
|
||||||
* ``make check-cxx check-cxxabi`` --- will run the test suites.
|
|
||||||
|
|
||||||
Shared libraries for libc++ and libc++ abi should now be present in llvm/build/lib.
|
|
||||||
See :ref:`using an alternate libc++ installation <alternate libcxx>`
|
|
||||||
|
|
||||||
#. **Optional**: Install libc++ and libc++abi
|
|
||||||
|
|
||||||
If your system already provides a libc++ installation it is important to be
|
|
||||||
careful not to replace it. Remember Use the CMake option ``CMAKE_INSTALL_PREFIX`` to
|
|
||||||
select a safe place to install libc++.
|
|
||||||
|
|
||||||
* ``make install-cxx install-cxxabi`` --- Will install the libraries and the headers
|
|
||||||
|
|
||||||
.. warning::
|
|
||||||
* Replacing your systems libc++ installation could render the system non-functional.
|
|
||||||
* Mac OS X will not boot without a valid copy of ``libc++.1.dylib`` in ``/usr/lib``.
|
|
||||||
|
|
||||||
|
|
||||||
The instructions are for building libc++ on
|
|
||||||
FreeBSD, Linux, or Mac using `libc++abi`_ as the C++ ABI library.
|
|
||||||
On Linux, it is also possible to use :ref:`libsupc++ <libsupcxx>` or libcxxrt.
|
|
||||||
|
|
||||||
It is sometimes beneficial to build outside of the LLVM tree. An out-of-tree
|
|
||||||
build would look like this:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ cd where-you-want-libcxx-to-live
|
|
||||||
$ # Check out llvm, libc++ and libc++abi.
|
|
||||||
$ ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm``
|
|
||||||
$ ``svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx``
|
|
||||||
$ ``svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi``
|
|
||||||
$ cd where-you-want-to-build
|
|
||||||
$ mkdir build && cd build
|
|
||||||
$ export CC=clang CXX=clang++
|
|
||||||
$ cmake -DLLVM_PATH=path/to/llvm \
|
|
||||||
-DLIBCXX_CXX_ABI=libcxxabi \
|
|
||||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxabi/include \
|
|
||||||
path/to/libcxx
|
|
||||||
$ make
|
|
||||||
$ make check-libcxx # optional
|
|
||||||
|
|
||||||
|
|
||||||
Experimental Support for Windows
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
The Windows support requires building with clang-cl as cl does not support one
|
|
||||||
required extension: `#include_next`. Furthermore, VS 2015 or newer (19.00) is
|
|
||||||
required. In the case of clang-cl, we need to specify the "MS Compatibility
|
|
||||||
Version" as it defaults to 2014 (18.00).
|
|
||||||
|
|
||||||
CMake + Visual Studio
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Building with Visual Studio currently does not permit running tests. However,
|
|
||||||
it is the simplest way to build.
|
|
||||||
|
|
||||||
.. code-block:: batch
|
|
||||||
|
|
||||||
> cmake -G "Visual Studio 14 2015" ^
|
|
||||||
-T "LLVM-vs2014" ^
|
|
||||||
-DLIBCXX_ENABLE_SHARED=YES ^
|
|
||||||
-DLIBCXX_ENABLE_STATIC=NO ^
|
|
||||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^
|
|
||||||
\path\to\libcxx
|
|
||||||
> cmake --build .
|
|
||||||
|
|
||||||
CMake + ninja
|
|
||||||
~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Building with ninja is required for development to enable tests.
|
|
||||||
Unfortunately, doing so requires additional configuration as we cannot
|
|
||||||
just specify a toolset.
|
|
||||||
|
|
||||||
.. code-block:: batch
|
|
||||||
|
|
||||||
> cmake -G Ninja ^
|
|
||||||
-DCMAKE_MAKE_PROGRAM=/path/to/ninja ^
|
|
||||||
-DCMAKE_SYSTEM_NAME=Windows ^
|
|
||||||
-DCMAKE_C_COMPILER=clang-cl ^
|
|
||||||
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^
|
|
||||||
-DCMAKE_CXX_COMPILER=clang-c ^
|
|
||||||
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^
|
|
||||||
-DLLVM_PATH=/path/to/llvm/tree ^
|
|
||||||
-DLIBCXX_ENABLE_SHARED=YES ^
|
|
||||||
-DLIBCXX_ENABLE_STATIC=NO ^
|
|
||||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^
|
|
||||||
\path\to\libcxx
|
|
||||||
> /path/to/ninja cxx
|
|
||||||
> /path/to/ninja check-cxx
|
|
||||||
|
|
||||||
Note that the paths specified with backward slashes must use the `\\` as the
|
|
||||||
directory separator as clang-cl may otherwise parse the path as an argument.
|
|
||||||
|
|
||||||
.. _`libc++abi`: http://libcxxabi.llvm.org/
|
|
||||||
|
|
||||||
|
|
||||||
.. _CMake Options:
|
|
||||||
|
|
||||||
CMake Options
|
|
||||||
=============
|
|
||||||
|
|
||||||
Here are some of the CMake variables that are used often, along with a
|
|
||||||
brief explanation and LLVM-specific notes. For full documentation, check the
|
|
||||||
CMake docs or execute ``cmake --help-variable VARIABLE_NAME``.
|
|
||||||
|
|
||||||
**CMAKE_BUILD_TYPE**:STRING
|
|
||||||
Sets the build type for ``make`` based generators. Possible values are
|
|
||||||
Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio
|
|
||||||
the user sets the build type with the IDE settings.
|
|
||||||
|
|
||||||
**CMAKE_INSTALL_PREFIX**:PATH
|
|
||||||
Path where LLVM will be installed if "make install" is invoked or the
|
|
||||||
"INSTALL" target is built.
|
|
||||||
|
|
||||||
**CMAKE_CXX_COMPILER**:STRING
|
|
||||||
The C++ compiler to use when building and testing libc++.
|
|
||||||
|
|
||||||
|
|
||||||
.. _libcxx-specific options:
|
|
||||||
|
|
||||||
libc++ specific options
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
.. option:: LIBCXX_INSTALL_LIBRARY:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Toggle the installation of the library portion of libc++.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_INSTALL_HEADERS:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Toggle the installation of the libc++ headers.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_ASSERTIONS:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Build libc++ with assertions enabled.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_BUILD_32_BITS:BOOL
|
|
||||||
|
|
||||||
**Default**: ``OFF``
|
|
||||||
|
|
||||||
Build libc++ as a 32 bit library. Also see `LLVM_BUILD_32_BITS`.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_SHARED:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Build libc++ as a shared library. Either `LIBCXX_ENABLE_SHARED` or
|
|
||||||
`LIBCXX_ENABLE_STATIC` has to be enabled.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_STATIC:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Build libc++ as a static library. Either `LIBCXX_ENABLE_SHARED` or
|
|
||||||
`LIBCXX_ENABLE_STATIC` has to be enabled.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_LIBDIR_SUFFIX:STRING
|
|
||||||
|
|
||||||
Extra suffix to append to the directory where libraries are to be installed.
|
|
||||||
This option overrides `LLVM_LIBDIR_SUFFIX`.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_INSTALL_PREFIX:STRING
|
|
||||||
|
|
||||||
**Default**: ``""``
|
|
||||||
|
|
||||||
Define libc++ destination prefix.
|
|
||||||
|
|
||||||
.. _libc++experimental options:
|
|
||||||
|
|
||||||
libc++experimental Specific Options
|
|
||||||
------------------------------------
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Build and test libc++experimental.a.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL
|
|
||||||
|
|
||||||
**Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY AND LIBCXX_INSTALL_LIBRARY``
|
|
||||||
|
|
||||||
Install libc++experimental.a alongside libc++.
|
|
||||||
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL
|
|
||||||
|
|
||||||
**Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY``
|
|
||||||
|
|
||||||
Build filesystem as part of libc++experimental.a. This allows filesystem
|
|
||||||
to be disabled without turning off the entire experimental library.
|
|
||||||
|
|
||||||
|
|
||||||
.. _ABI Library Specific Options:
|
|
||||||
|
|
||||||
ABI Library Specific Options
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
.. option:: LIBCXX_CXX_ABI:STRING
|
|
||||||
|
|
||||||
**Values**: ``none``, ``libcxxabi``, ``libcxxrt``, ``libstdc++``, ``libsupc++``.
|
|
||||||
|
|
||||||
Select the ABI library to build libc++ against.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_CXX_ABI_INCLUDE_PATHS:PATHS
|
|
||||||
|
|
||||||
Provide additional search paths for the ABI library headers.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_CXX_ABI_LIBRARY_PATH:PATH
|
|
||||||
|
|
||||||
Provide the path to the ABI library that libc++ should link against.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_STATIC_ABI_LIBRARY:BOOL
|
|
||||||
|
|
||||||
**Default**: ``OFF``
|
|
||||||
|
|
||||||
If this option is enabled, libc++ will try and link the selected ABI library
|
|
||||||
statically.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_ABI_LINKER_SCRIPT:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON`` by default on UNIX platforms other than Apple unless
|
|
||||||
'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' is ON. Otherwise the default value is ``OFF``.
|
|
||||||
|
|
||||||
This option generate and installs a linker script as ``libc++.so`` which
|
|
||||||
links the correct ABI library.
|
|
||||||
|
|
||||||
.. option:: LIBCXXABI_USE_LLVM_UNWINDER:BOOL
|
|
||||||
|
|
||||||
**Default**: ``OFF``
|
|
||||||
|
|
||||||
Build and use the LLVM unwinder. Note: This option can only be used when
|
|
||||||
libc++abi is the C++ ABI library used.
|
|
||||||
|
|
||||||
|
|
||||||
libc++ Feature Options
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_EXCEPTIONS:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Build libc++ with exception support.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ENABLE_RTTI:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Build libc++ with run time type information.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_INCLUDE_BENCHMARKS:BOOL
|
|
||||||
|
|
||||||
**Default**: ``ON``
|
|
||||||
|
|
||||||
Build the libc++ benchmark tests and the Google Benchmark library needed
|
|
||||||
to support them.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_BENCHMARK_NATIVE_STDLIB:STRING
|
|
||||||
|
|
||||||
**Default**:: ``""``
|
|
||||||
|
|
||||||
**Values**:: ``libc++``, ``libstdc++``
|
|
||||||
|
|
||||||
Build the libc++ benchmark tests and Google Benchmark library against the
|
|
||||||
specified standard library on the platform. On linux this can be used to
|
|
||||||
compare libc++ to libstdc++ by building the benchmark tests against both
|
|
||||||
standard libraries.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN:STRING
|
|
||||||
|
|
||||||
Use the specified GCC toolchain and standard library when building the native
|
|
||||||
stdlib benchmark tests.
|
|
||||||
|
|
||||||
|
|
||||||
libc++ ABI Feature Options
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
The following options allow building libc++ for a different ABI version.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ABI_VERSION:STRING
|
|
||||||
|
|
||||||
**Default**: ``1``
|
|
||||||
|
|
||||||
Defines the target ABI version of libc++.
|
|
||||||
|
|
||||||
.. option:: LIBCXX_ABI_UNSTABLE:BOOL
|
|
||||||
|
|
||||||
**Default**: ``OFF``
|
|
||||||
|
|
||||||
Build the "unstable" ABI version of libc++. Includes all ABI changing features
|
|
||||||
on top of the current stable version.
|
|
||||||
|
|
||||||
.. _LLVM-specific variables:
|
|
||||||
|
|
||||||
LLVM-specific options
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
.. option:: LLVM_LIBDIR_SUFFIX:STRING
|
|
||||||
|
|
||||||
Extra suffix to append to the directory where libraries are to be
|
|
||||||
installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64``
|
|
||||||
to install libraries to ``/usr/lib64``.
|
|
||||||
|
|
||||||
.. option:: LLVM_BUILD_32_BITS:BOOL
|
|
||||||
|
|
||||||
Build 32-bits executables and libraries on 64-bits systems. This option is
|
|
||||||
available only on some 64-bits unix systems. Defaults to OFF.
|
|
||||||
|
|
||||||
.. option:: LLVM_LIT_ARGS:STRING
|
|
||||||
|
|
||||||
Arguments given to lit. ``make check`` and ``make clang-test`` are affected.
|
|
||||||
By default, ``'-sv --no-progress-bar'`` on Visual C++ and Xcode, ``'-sv'`` on
|
|
||||||
others.
|
|
||||||
|
|
||||||
|
|
||||||
Using Alternate ABI libraries
|
|
||||||
=============================
|
|
||||||
|
|
||||||
|
|
||||||
.. _libsupcxx:
|
|
||||||
|
|
||||||
Using libsupc++ on Linux
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
You will need libstdc++ in order to provide libsupc++.
|
|
||||||
|
|
||||||
Figure out where the libsupc++ headers are on your system. On Ubuntu this
|
|
||||||
is ``/usr/include/c++/<version>`` and ``/usr/include/c++/<version>/<target-triple>``
|
|
||||||
|
|
||||||
You can also figure this out by running
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ echo | g++ -Wp,-v -x c++ - -fsyntax-only
|
|
||||||
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
|
|
||||||
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
|
|
||||||
#include "..." search starts here:
|
|
||||||
#include <...> search starts here:
|
|
||||||
/usr/include/c++/4.7
|
|
||||||
/usr/include/c++/4.7/x86_64-linux-gnu
|
|
||||||
/usr/include/c++/4.7/backward
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/4.7/include
|
|
||||||
/usr/local/include
|
|
||||||
/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
|
|
||||||
/usr/include/x86_64-linux-gnu
|
|
||||||
/usr/include
|
|
||||||
End of search list.
|
|
||||||
|
|
||||||
Note that the first two entries happen to be what we are looking for. This
|
|
||||||
may not be correct on other platforms.
|
|
||||||
|
|
||||||
We can now run CMake:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ CC=clang CXX=clang++ cmake -G "Unix Makefiles" \
|
|
||||||
-DLIBCXX_CXX_ABI=libstdc++ \
|
|
||||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/" \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \
|
|
||||||
<libc++-source-dir>
|
|
||||||
|
|
||||||
|
|
||||||
You can also substitute ``-DLIBCXX_CXX_ABI=libsupc++``
|
|
||||||
above, which will cause the library to be linked to libsupc++ instead
|
|
||||||
of libstdc++, but this is only recommended if you know that you will
|
|
||||||
never need to link against libstdc++ in the same executable as libc++.
|
|
||||||
GCC ships libsupc++ separately but only as a static library. If a
|
|
||||||
program also needs to link against libstdc++, it will provide its
|
|
||||||
own copy of libsupc++ and this can lead to subtle problems.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ make cxx
|
|
||||||
$ make install
|
|
||||||
|
|
||||||
You can now run clang with -stdlib=libc++.
|
|
||||||
|
|
||||||
|
|
||||||
.. _libcxxrt_ref:
|
|
||||||
|
|
||||||
Using libcxxrt on Linux
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
You will need to keep the source tree of `libcxxrt`_ available
|
|
||||||
on your build machine and your copy of the libcxxrt shared library must
|
|
||||||
be placed where your linker will find it.
|
|
||||||
|
|
||||||
We can now run CMake like:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ CC=clang CXX=clang++ cmake -G "Unix Makefiles" \
|
|
||||||
-DLIBCXX_CXX_ABI=libcxxrt \
|
|
||||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
|
||||||
<libc++-source-directory>
|
|
||||||
$ make cxx
|
|
||||||
$ make install
|
|
||||||
|
|
||||||
Unfortunately you can't simply run clang with "-stdlib=libc++" at this point, as
|
|
||||||
clang is set up to link for libc++ linked to libsupc++. To get around this
|
|
||||||
you'll have to set up your linker yourself (or patch clang). For example,
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -stdlib=libc++ helloworld.cpp \
|
|
||||||
-nodefaultlibs -lc++ -lcxxrt -lm -lc -lgcc_s -lgcc
|
|
||||||
|
|
||||||
Alternately, you could just add libcxxrt to your libraries list, which in most
|
|
||||||
situations will give the same result:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -stdlib=libc++ helloworld.cpp -lcxxrt
|
|
||||||
|
|
||||||
.. _`libcxxrt`: https://github.com/pathscale/libcxxrt/
|
|
||||||
|
|
||||||
|
|
||||||
Using a local ABI library installation
|
|
||||||
---------------------------------------
|
|
||||||
|
|
||||||
.. warning::
|
|
||||||
This is not recommended in almost all cases.
|
|
||||||
|
|
||||||
These instructions should only be used when you can't install your ABI library.
|
|
||||||
|
|
||||||
Normally you must link libc++ against a ABI shared library that the
|
|
||||||
linker can find. If you want to build and test libc++ against an ABI
|
|
||||||
library not in the linker's path you needq to set
|
|
||||||
``-DLIBCXX_CXX_ABI_LIBRARY_PATH=/path/to/abi/lib`` when configuring CMake.
|
|
||||||
|
|
||||||
An example build using libc++abi would look like:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ CC=clang CXX=clang++ cmake \
|
|
||||||
-DLIBCXX_CXX_ABI=libc++abi \
|
|
||||||
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="/path/to/libcxxabi/include" \
|
|
||||||
-DLIBCXX_CXX_ABI_LIBRARY_PATH="/path/to/libcxxabi-build/lib" \
|
|
||||||
path/to/libcxx
|
|
||||||
$ make
|
|
||||||
|
|
||||||
When testing libc++ LIT will automatically link against the proper ABI
|
|
||||||
library.
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
if (LLVM_ENABLE_SPHINX)
|
|
||||||
include(AddSphinxTarget)
|
|
||||||
if (SPHINX_FOUND)
|
|
||||||
if (${SPHINX_OUTPUT_HTML})
|
|
||||||
add_sphinx_target(html libcxx)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
====================
|
|
||||||
Libc++ ABI stability
|
|
||||||
====================
|
|
||||||
|
|
||||||
Libc++ aims to preserve stable ABI to avoid subtle bugs when code built to the old ABI
|
|
||||||
is linked with the code build to the new ABI. At the same time, libc++ allows ABI-breaking
|
|
||||||
improvements and bugfixes for the scenarios when ABI change is not a issue.
|
|
||||||
|
|
||||||
To support both cases, libc++ allows specifying the ABI version at the
|
|
||||||
build time. The version is defined with a cmake option
|
|
||||||
LIBCXX_ABI_VERSION. Another option LIBCXX_ABI_UNSTABLE can be used to
|
|
||||||
include all present ABI breaking features. These options translate
|
|
||||||
into C++ macro definitions _LIBCPP_ABI_VERSION, _LIBCPP_ABI_UNSTABLE.
|
|
||||||
|
|
||||||
Any ABI-changing feature is placed under it's own macro, _LIBCPP_ABI_XXX, which is enabled
|
|
||||||
based on the value of _LIBCPP_ABI_VERSION. _LIBCPP_ABI_UNSTABLE, if set, enables all features at once.
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
===================
|
|
||||||
Availability Markup
|
|
||||||
===================
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Overview
|
|
||||||
========
|
|
||||||
|
|
||||||
Libc++ is used as a system library on macOS and iOS (amongst others). In order
|
|
||||||
for users to be able to compile a binary that is intended to be deployed to an
|
|
||||||
older version of the platform, clang provides the
|
|
||||||
`availability attribute <https://clang.llvm.org/docs/AttributeReference.html#availability>`_
|
|
||||||
that can be placed on declarations to describe the lifecycle of a symbol in the
|
|
||||||
library.
|
|
||||||
|
|
||||||
Design
|
|
||||||
======
|
|
||||||
|
|
||||||
When a new feature is introduced that requires dylib support, a macro should be
|
|
||||||
created in include/__config to mark this feature as unavailable for all the
|
|
||||||
systems. For example::
|
|
||||||
|
|
||||||
// Define availability macros.
|
|
||||||
#if defined(_LIBCPP_USE_AVAILABILITY_APPLE)
|
|
||||||
#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
|
|
||||||
#else if defined(_LIBCPP_USE_AVAILABILITY_SOME_OTHER_VENDOR)
|
|
||||||
#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
|
|
||||||
#else
|
|
||||||
#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
When the library is updated by the platform vendor, the markup can be updated.
|
|
||||||
For example::
|
|
||||||
|
|
||||||
#define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
|
|
||||||
__attribute__((availability(macosx,strict,introduced=10.12))) \
|
|
||||||
__attribute__((availability(ios,strict,introduced=10.0))) \
|
|
||||||
__attribute__((availability(tvos,strict,introduced=10.0))) \
|
|
||||||
__attribute__((availability(watchos,strict,introduced=3.0)))
|
|
||||||
|
|
||||||
In the source code, the macro can be added on a class if the full class requires
|
|
||||||
type info from the library for example::
|
|
||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
|
|
||||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
|
|
||||||
: public std::logic_error {
|
|
||||||
|
|
||||||
or on a particular symbol:
|
|
||||||
|
|
||||||
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
|
|
||||||
|
|
||||||
|
|
||||||
Testing
|
|
||||||
=======
|
|
||||||
|
|
||||||
Some parameters can be passed to lit to run the test-suite and exercising the
|
|
||||||
availability.
|
|
||||||
|
|
||||||
* The `platform` parameter controls the deployement target. For example lit can
|
|
||||||
be invoked with `--param=platform=macosx10.8`. Default is the current host.
|
|
||||||
* The `use_system_cxx_lib` parameter indicates to use another library than the
|
|
||||||
just built one. Invoking lit with `--param=use_system_cxx_lib=true` will run
|
|
||||||
the test-suite against the host system library. Alternatively a path to the
|
|
||||||
directory containing a specific prebuilt libc++ can be used, for example:
|
|
||||||
`--param=use_system_cxx_lib=/path/to/macOS/10.8/`.
|
|
||||||
* The `with_availability` boolean parameter enables the availability markup.
|
|
||||||
|
|
||||||
Tests can be marked as XFAIL based on multiple features made available by lit:
|
|
||||||
|
|
||||||
|
|
||||||
* if either `use_system_cxx_lib` or `with_availability` is passed to lit,
|
|
||||||
assuming `--param=platform=macosx10.8` is passed as well the following
|
|
||||||
features will be available:
|
|
||||||
|
|
||||||
- availability
|
|
||||||
- availability=x86_64
|
|
||||||
- availability=macosx
|
|
||||||
- availability=x86_64-macosx
|
|
||||||
- availability=x86_64-apple-macosx10.8
|
|
||||||
- availability=macosx10.8
|
|
||||||
|
|
||||||
This feature is used to XFAIL a test that *is* using a class of a method marked
|
|
||||||
as unavailable *and* that is expected to *fail* if deployed on an older system.
|
|
||||||
|
|
||||||
* if `use_system_cxx_lib` is passed to lit, the following features will also
|
|
||||||
be available:
|
|
||||||
|
|
||||||
- with_system_cxx_lib
|
|
||||||
- with_system_cxx_lib=x86_64
|
|
||||||
- with_system_cxx_lib=macosx
|
|
||||||
- with_system_cxx_lib=x86_64-macosx
|
|
||||||
- with_system_cxx_lib=x86_64-apple-macosx10.8
|
|
||||||
- with_system_cxx_lib=macosx10.8
|
|
||||||
|
|
||||||
This feature is used to XFAIL a test that is *not* using a class of a method
|
|
||||||
marked as unavailable *but* that is expected to fail if deployed on an older
|
|
||||||
system. For example if we know that it exhibits a but in the libc on a
|
|
||||||
particular system version.
|
|
||||||
|
|
||||||
* if `with_availability` is passed to lit, the following features will also
|
|
||||||
be available:
|
|
||||||
|
|
||||||
- availability_markup
|
|
||||||
- availability_markup=x86_64
|
|
||||||
- availability_markup=macosx
|
|
||||||
- availability_markup=x86_64-macosx
|
|
||||||
- availability_markup=x86_64-apple-macosx10.8
|
|
||||||
- availability_markup=macosx10.8
|
|
||||||
|
|
||||||
This feature is used to XFAIL a test that *is* using a class of a method
|
|
||||||
marked as unavailable *but* that is expected to *pass* if deployed on an older
|
|
||||||
system. For example if it is using a symbol in a statically evaluated context.
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
=======================================================
|
|
||||||
Capturing configuration information during installation
|
|
||||||
=======================================================
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
The Problem
|
|
||||||
===========
|
|
||||||
|
|
||||||
Currently the libc++ supports building the library with a number of different
|
|
||||||
configuration options. Unfortunately all of that configuration information is
|
|
||||||
lost when libc++ is installed. In order to support "persistent"
|
|
||||||
configurations libc++ needs a mechanism to capture the configuration options
|
|
||||||
in the INSTALLED headers.
|
|
||||||
|
|
||||||
|
|
||||||
Design Goals
|
|
||||||
============
|
|
||||||
|
|
||||||
* The solution should not INSTALL any additional headers. We don't want an extra
|
|
||||||
#include slowing everybody down.
|
|
||||||
|
|
||||||
* The solution should not unduly affect libc++ developers. The problem is limited
|
|
||||||
to installed versions of libc++ and the solution should be as well.
|
|
||||||
|
|
||||||
* The solution should not modify any existing headers EXCEPT during installation.
|
|
||||||
It makes developers lives harder if they have to regenerate the libc++ headers
|
|
||||||
every time they are modified.
|
|
||||||
|
|
||||||
* The solution should not make any of the libc++ headers dependant on
|
|
||||||
files generated by the build system. The headers should be able to compile
|
|
||||||
out of the box without any modification.
|
|
||||||
|
|
||||||
* The solution should not have ANY effect on users who don't need special
|
|
||||||
configuration options. The vast majority of users will never need this so it
|
|
||||||
shouldn't cost them.
|
|
||||||
|
|
||||||
|
|
||||||
The Solution
|
|
||||||
============
|
|
||||||
|
|
||||||
When you first configure libc++ using CMake we check to see if we need to
|
|
||||||
capture any options. If we haven't been given any "persistent" options then
|
|
||||||
we do NOTHING.
|
|
||||||
|
|
||||||
Otherwise we create a custom installation rule that modifies the installed __config
|
|
||||||
header. The rule first generates a dummy "__config_site" header containing the required
|
|
||||||
#defines. The contents of the dummy header are then prependend to the installed
|
|
||||||
__config header. By manually prepending the files we avoid the cost of an
|
|
||||||
extra #include and we allow the __config header to be ignorant of the extra
|
|
||||||
configuration all together. An example "__config" header generated when
|
|
||||||
-DLIBCXX_ENABLE_THREADS=OFF is given to CMake would look something like:
|
|
||||||
|
|
||||||
.. code-block:: cpp
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_CONFIG_SITE
|
|
||||||
#define _LIBCPP_CONFIG_SITE
|
|
||||||
|
|
||||||
/* #undef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE */
|
|
||||||
/* #undef _LIBCPP_HAS_NO_STDIN */
|
|
||||||
/* #undef _LIBCPP_HAS_NO_STDOUT */
|
|
||||||
#define _LIBCPP_HAS_NO_THREADS
|
|
||||||
/* #undef _LIBCPP_HAS_NO_MONOTONIC_CLOCK */
|
|
||||||
/* #undef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// -*- C++ -*-
|
|
||||||
//===--------------------------- __config ---------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_CONFIG
|
|
||||||
#define _LIBCPP_CONFIG
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
==========
|
|
||||||
Debug Mode
|
|
||||||
==========
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
.. _using-debug-mode:
|
|
||||||
|
|
||||||
Using Debug Mode
|
|
||||||
================
|
|
||||||
|
|
||||||
Libc++ provides a debug mode that enables assertions meant to detect incorrect
|
|
||||||
usage of the standard library. By default these assertions are disabled but
|
|
||||||
they can be enabled using the ``_LIBCPP_DEBUG`` macro.
|
|
||||||
|
|
||||||
**_LIBCPP_DEBUG** Macro
|
|
||||||
-----------------------
|
|
||||||
|
|
||||||
**_LIBCPP_DEBUG**:
|
|
||||||
This macro is used to enable assertions and iterator debugging checks within
|
|
||||||
libc++. By default it is undefined.
|
|
||||||
|
|
||||||
**Values**: ``0``, ``1``
|
|
||||||
|
|
||||||
Defining ``_LIBCPP_DEBUG`` to ``0`` or greater enables most of libc++'s
|
|
||||||
assertions. Defining ``_LIBCPP_DEBUG`` to ``1`` enables "iterator debugging"
|
|
||||||
which provides additional assertions about the validity of iterators used by
|
|
||||||
the program.
|
|
||||||
|
|
||||||
Note that this option has no effect on libc++'s ABI
|
|
||||||
|
|
||||||
**_LIBCPP_DEBUG_USE_EXCEPTIONS**:
|
|
||||||
When this macro is defined ``_LIBCPP_ASSERT`` failures throw
|
|
||||||
``__libcpp_debug_exception`` instead of aborting. Additionally this macro
|
|
||||||
disables exception specifications on functions containing ``_LIBCPP_ASSERT``
|
|
||||||
checks. This allows assertion failures to correctly throw through these
|
|
||||||
functions.
|
|
||||||
|
|
||||||
Handling Assertion Failures
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
When a debug assertion fails the assertion handler is called via the
|
|
||||||
``std::__libcpp_debug_function`` function pointer. It is possible to override
|
|
||||||
this function pointer using a different handler function. Libc++ provides two
|
|
||||||
different assertion handlers, the default handler
|
|
||||||
``std::__libcpp_abort_debug_handler`` which aborts the program, and
|
|
||||||
``std::__libcpp_throw_debug_handler`` which throws an instance of
|
|
||||||
``std::__libcpp_debug_exception``. Libc++ can be changed to use the throwing
|
|
||||||
assertion handler as follows:
|
|
||||||
|
|
||||||
.. code-block:: cpp
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#include <string>
|
|
||||||
int main() {
|
|
||||||
std::__libcpp_debug_function = std::__libcpp_throw_debug_function;
|
|
||||||
try {
|
|
||||||
std::string::iterator bad_it;
|
|
||||||
std::string str("hello world");
|
|
||||||
str.insert(bad_it, '!'); // causes debug assertion
|
|
||||||
} catch (std::__libcpp_debug_exception const&) {
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug Mode Checks
|
|
||||||
=================
|
|
||||||
|
|
||||||
Libc++'s debug mode offers two levels of checking. The first enables various
|
|
||||||
precondition checks throughout libc++. The second additionally enables
|
|
||||||
"iterator debugging" which checks the validity of iterators used by the program.
|
|
||||||
|
|
||||||
Basic Checks
|
|
||||||
============
|
|
||||||
|
|
||||||
These checks are enabled when ``_LIBCPP_DEBUG`` is defined to either 0 or 1.
|
|
||||||
|
|
||||||
The following checks are enabled by ``_LIBCPP_DEBUG``:
|
|
||||||
|
|
||||||
* FIXME: Update this list
|
|
||||||
|
|
||||||
Iterator Debugging Checks
|
|
||||||
=========================
|
|
||||||
|
|
||||||
These checks are enabled when ``_LIBCPP_DEBUG`` is defined to 1.
|
|
||||||
|
|
||||||
The following containers and STL classes support iterator debugging:
|
|
||||||
|
|
||||||
* ``std::string``
|
|
||||||
* ``std::vector<T>`` (``T != bool``)
|
|
||||||
* ``std::list``
|
|
||||||
* ``std::unordered_map``
|
|
||||||
* ``std::unordered_multimap``
|
|
||||||
* ``std::unordered_set``
|
|
||||||
* ``std::unordered_multiset``
|
|
||||||
|
|
||||||
The remaining containers do not currently support iterator debugging.
|
|
||||||
Patches welcome.
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
=====================
|
|
||||||
Threading Support API
|
|
||||||
=====================
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Overview
|
|
||||||
========
|
|
||||||
|
|
||||||
Libc++ supports using multiple different threading models and configurations
|
|
||||||
to implement the threading parts of libc++, including ``<thread>`` and ``<mutex>``.
|
|
||||||
These different models provide entirely different interfaces from each
|
|
||||||
other. To address this libc++ wraps the underlying threading API in a new and
|
|
||||||
consistent API, which it uses internally to implement threading primitives.
|
|
||||||
|
|
||||||
The ``<__threading_support>`` header is where libc++ defines its internal
|
|
||||||
threading interface. It contains forward declarations of the internal threading
|
|
||||||
interface as well as definitions for the interface.
|
|
||||||
|
|
||||||
External Threading API and the ``<__external_threading>`` header
|
|
||||||
================================================================
|
|
||||||
|
|
||||||
In order to support vendors with custom threading API's libc++ allows the
|
|
||||||
entire internal threading interface to be provided by an external,
|
|
||||||
vendor provided, header.
|
|
||||||
|
|
||||||
When ``_LIBCPP_HAS_THREAD_API_EXTERNAL`` is defined the ``<__threading_support>``
|
|
||||||
header simply forwards to the ``<__external_threading>`` header (which must exist).
|
|
||||||
It is expected that the ``<__external_threading>`` header provide the exact
|
|
||||||
interface normally provided by ``<__threading_support>``.
|
|
||||||
|
|
||||||
External Threading Library
|
|
||||||
==========================
|
|
||||||
|
|
||||||
libc++ can be compiled with its internal threading API delegating to an external
|
|
||||||
library. Such a configuration is useful for library vendors who wish to
|
|
||||||
distribute a thread-agnostic libc++ library, where the users of the library are
|
|
||||||
expected to provide the implementation of the libc++ internal threading API.
|
|
||||||
|
|
||||||
On a production setting, this would be achieved through a custom
|
|
||||||
``<__external_threading>`` header, which declares the libc++ internal threading
|
|
||||||
API but leaves out the implementation.
|
|
||||||
|
|
||||||
The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
|
|
||||||
such a configuration while allowing it to be tested on a platform that supports
|
|
||||||
any of the threading systems (e.g. pthread) supported in ``__threading_support``
|
|
||||||
header. Therefore, the main purpose of this option is to allow testing of this
|
|
||||||
particular configuration of the library without being tied to a vendor-specific
|
|
||||||
threading system. This option is only meant to be used by libc++ library
|
|
||||||
developers.
|
|
||||||
|
|
||||||
Threading Configuration Macros
|
|
||||||
==============================
|
|
||||||
|
|
||||||
**_LIBCPP_HAS_NO_THREADS**
|
|
||||||
This macro is defined when libc++ is built without threading support. It
|
|
||||||
should not be manually defined by the user.
|
|
||||||
|
|
||||||
**_LIBCPP_HAS_THREAD_API_EXTERNAL**
|
|
||||||
This macro is defined when libc++ should use the ``<__external_threading>``
|
|
||||||
header to provide the internal threading API. This macro overrides
|
|
||||||
``_LIBCPP_HAS_THREAD_API_PTHREAD``.
|
|
||||||
|
|
||||||
**_LIBCPP_HAS_THREAD_API_PTHREAD**
|
|
||||||
This macro is defined when libc++ should use POSIX threads to implement the
|
|
||||||
internal threading API.
|
|
||||||
|
|
||||||
**_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL**
|
|
||||||
This macro is defined when libc++ expects the definitions of the internal
|
|
||||||
threading API to be provided by an external library. When defined
|
|
||||||
``<__threading_support>`` will only provide the forward declarations and
|
|
||||||
typedefs for the internal threading API.
|
|
||||||
|
|
||||||
**_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL**
|
|
||||||
This macro is used to build an external threading library using the
|
|
||||||
``<__threading_support>``. Specifically it exposes the threading API
|
|
||||||
definitions in ``<__threading_support>`` as non-inline definitions meant to
|
|
||||||
be compiled into a library.
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
========================
|
|
||||||
Symbol Visibility Macros
|
|
||||||
========================
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Overview
|
|
||||||
========
|
|
||||||
|
|
||||||
Libc++ uses various "visibility" macros in order to provide a stable ABI in
|
|
||||||
both the library and the headers. These macros work by changing the
|
|
||||||
visibility and inlining characteristics of the symbols they are applied to.
|
|
||||||
|
|
||||||
Visibility Macros
|
|
||||||
=================
|
|
||||||
|
|
||||||
**_LIBCPP_HIDDEN**
|
|
||||||
Mark a symbol as hidden so it will not be exported from shared libraries.
|
|
||||||
|
|
||||||
**_LIBCPP_FUNC_VIS**
|
|
||||||
Mark a symbol as being exported by the libc++ library. This attribute must
|
|
||||||
be applied to the declaration of all functions exported by the libc++ dylib.
|
|
||||||
|
|
||||||
**_LIBCPP_EXTERN_VIS**
|
|
||||||
Mark a symbol as being exported by the libc++ library. This attribute may
|
|
||||||
only be applied to objects defined in the libc++ library. On Windows this
|
|
||||||
macro applies `dllimport`/`dllexport` to the symbol. On all other platforms
|
|
||||||
this macro has no effect.
|
|
||||||
|
|
||||||
**_LIBCPP_OVERRIDABLE_FUNC_VIS**
|
|
||||||
Mark a symbol as being exported by the libc++ library, but allow it to be
|
|
||||||
overridden locally. On non-Windows, this is equivalent to `_LIBCPP_FUNC_VIS`.
|
|
||||||
This macro is applied to all `operator new` and `operator delete` overloads.
|
|
||||||
|
|
||||||
**Windows Behavior**: Any symbol marked `dllimport` cannot be overridden
|
|
||||||
locally, since `dllimport` indicates the symbol should be bound to a separate
|
|
||||||
DLL. All `operator new` and `operator delete` overloads are required to be
|
|
||||||
locally overridable, and therefore must not be marked `dllimport`. On Windows,
|
|
||||||
this macro therefore expands to `__declspec(dllexport)` when building the
|
|
||||||
library and has an empty definition otherwise.
|
|
||||||
|
|
||||||
**_LIBCPP_INLINE_VISIBILITY**
|
|
||||||
Mark a function as hidden and force inlining whenever possible.
|
|
||||||
|
|
||||||
**_LIBCPP_ALWAYS_INLINE**
|
|
||||||
A synonym for `_LIBCPP_INLINE_VISIBILITY`
|
|
||||||
|
|
||||||
**_LIBCPP_TYPE_VIS**
|
|
||||||
Mark a type's typeinfo, vtable and members as having default visibility.
|
|
||||||
This attribute cannot be used on class templates.
|
|
||||||
|
|
||||||
**_LIBCPP_TEMPLATE_VIS**
|
|
||||||
Mark a type's typeinfo and vtable as having default visibility.
|
|
||||||
This macro has no effect on the visibility of the type's member functions.
|
|
||||||
|
|
||||||
**GCC Behavior**: GCC does not support Clang's `type_visibility(...)`
|
|
||||||
attribute. With GCC the `visibility(...)` attribute is used and member
|
|
||||||
functions are affected.
|
|
||||||
|
|
||||||
**Windows Behavior**: DLLs do not support dllimport/export on class templates.
|
|
||||||
The macro has an empty definition on this platform.
|
|
||||||
|
|
||||||
|
|
||||||
**_LIBCPP_ENUM_VIS**
|
|
||||||
Mark the typeinfo of an enum as having default visibility. This attribute
|
|
||||||
should be applied to all enum declarations.
|
|
||||||
|
|
||||||
**Windows Behavior**: DLLs do not support importing or exporting enumeration
|
|
||||||
typeinfo. The macro has an empty definition on this platform.
|
|
||||||
|
|
||||||
**GCC Behavior**: GCC un-hides the typeinfo for enumerations by default, even
|
|
||||||
if `-fvisibility=hidden` is specified. Additionally applying a visibility
|
|
||||||
attribute to an enum class results in a warning. The macro has an empty
|
|
||||||
definition with GCC.
|
|
||||||
|
|
||||||
**_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS**
|
|
||||||
Mark the member functions, typeinfo, and vtable of the type named in
|
|
||||||
a `_LIBCPP_EXTERN_TEMPLATE` declaration as being exported by the libc++ library.
|
|
||||||
This attribute must be specified on all extern class template declarations.
|
|
||||||
|
|
||||||
This macro is used to override the `_LIBCPP_TEMPLATE_VIS` attribute
|
|
||||||
specified on the primary template and to export the member functions produced
|
|
||||||
by the explicit instantiation in the dylib.
|
|
||||||
|
|
||||||
**GCC Behavior**: GCC ignores visibility attributes applied the type in
|
|
||||||
extern template declarations and applying an attribute results in a warning.
|
|
||||||
However since `_LIBCPP_TEMPLATE_VIS` is the same as
|
|
||||||
`__attribute__((visibility("default"))` the visibility is already correct.
|
|
||||||
The macro has an empty definition with GCC.
|
|
||||||
|
|
||||||
**Windows Behavior**: `extern template` and `dllexport` are fundamentally
|
|
||||||
incompatible *on a class template* on Windows; the former suppresses
|
|
||||||
instantiation, while the latter forces it. Specifying both on the same
|
|
||||||
declaration makes the class template be instantiated, which is not desirable
|
|
||||||
inside headers. This macro therefore expands to `dllimport` outside of libc++
|
|
||||||
but nothing inside of it (rather than expanding to `dllexport`); instead, the
|
|
||||||
explicit instantiations themselves are marked as exported. Note that this
|
|
||||||
applies *only* to extern *class* templates. Extern *function* templates obey
|
|
||||||
regular import/export semantics, and applying `dllexport` directly to the
|
|
||||||
extern template declaration (i.e. using `_LIBCPP_FUNC_VIS`) is the correct
|
|
||||||
thing to do for them.
|
|
||||||
|
|
||||||
**_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS**
|
|
||||||
Mark the member functions, typeinfo, and vtable of an explicit instantiation
|
|
||||||
of a class template as being exported by the libc++ library. This attribute
|
|
||||||
must be specified on all class template explicit instantiations.
|
|
||||||
|
|
||||||
It is only necessary to mark the explicit instantiation itself (as opposed to
|
|
||||||
the extern template declaration) as exported on Windows, as discussed above.
|
|
||||||
On all other platforms, this macro has an empty definition.
|
|
||||||
|
|
||||||
**_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS**
|
|
||||||
Mark a symbol as hidden so it will not be exported from shared libraries. This
|
|
||||||
is intended specifically for method templates of either classes marked with
|
|
||||||
`_LIBCPP_TYPE_VIS` or classes with an extern template instantiation
|
|
||||||
declaration marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS`.
|
|
||||||
|
|
||||||
When building libc++ with hidden visibility, we want explicit template
|
|
||||||
instantiations to export members, which is consistent with existing Windows
|
|
||||||
behavior. We also want classes annotated with `_LIBCPP_TYPE_VIS` to export
|
|
||||||
their members, which is again consistent with existing Windows behavior.
|
|
||||||
Both these changes are necessary for clients to be able to link against a
|
|
||||||
libc++ DSO built with hidden visibility without encountering missing symbols.
|
|
||||||
|
|
||||||
An unfortunate side effect, however, is that method templates of classes
|
|
||||||
either marked `_LIBCPP_TYPE_VIS` or with extern template instantiation
|
|
||||||
declarations marked with `_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` also get default
|
|
||||||
visibility when instantiated. These methods are often implicitly instantiated
|
|
||||||
inside other libraries which use the libc++ headers, and will therefore end up
|
|
||||||
being exported from those libraries, since those implicit instantiations will
|
|
||||||
receive default visibility. This is not acceptable for libraries that wish to
|
|
||||||
control their visibility, and led to PR30642.
|
|
||||||
|
|
||||||
Consequently, all such problematic method templates are explicitly marked
|
|
||||||
either hidden (via this macro) or inline, so that they don't leak into client
|
|
||||||
libraries. The problematic methods were found by running
|
|
||||||
`bad-visibility-finder <https://github.com/smeenai/bad-visibility-finder>`_
|
|
||||||
against the libc++ headers after making `_LIBCPP_TYPE_VIS` and
|
|
||||||
`_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS` expand to default visibility.
|
|
||||||
|
|
||||||
**_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY**
|
|
||||||
Mark a member function of a class template as visible and always inline. This
|
|
||||||
macro should only be applied to member functions of class templates that are
|
|
||||||
externally instantiated. It is important that these symbols are not marked
|
|
||||||
as hidden as that will prevent the dylib definition from being found.
|
|
||||||
|
|
||||||
This macro is used to maintain ABI compatibility for symbols that have been
|
|
||||||
historically exported by the libc++ library but are now marked inline.
|
|
||||||
|
|
||||||
**_LIBCPP_EXCEPTION_ABI**
|
|
||||||
Mark the member functions, typeinfo, and vtable of the type as being exported
|
|
||||||
by the libc++ library. This macro must be applied to all *exception types*.
|
|
||||||
Exception types should be defined directly in namespace `std` and not the
|
|
||||||
versioning namespace. This allows throwing and catching some exception types
|
|
||||||
between libc++ and libstdc++.
|
|
||||||
|
|
||||||
Links
|
|
||||||
=====
|
|
||||||
|
|
||||||
* `[cfe-dev] Visibility in libc++ - 1 <http://lists.llvm.org/pipermail/cfe-dev/2013-July/030610.html>`_
|
|
||||||
* `[cfe-dev] Visibility in libc++ - 2 <http://lists.llvm.org/pipermail/cfe-dev/2013-August/031195.html>`_
|
|
||||||
* `[libcxx] Visibility fixes for Windows <http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130805/085461.html>`_
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
# Makefile for Sphinx documentation
|
|
||||||
#
|
|
||||||
# FIXME: This hack is only in place to allow the libcxx.llvm.org/docs builder
|
|
||||||
# to work with libcxx. This should be removed when that builder supports
|
|
||||||
# out-of-tree builds.
|
|
||||||
|
|
||||||
# You can set these variables from the command line.
|
|
||||||
SPHINXOPTS = -n -W
|
|
||||||
SPHINXBUILD = sphinx-build
|
|
||||||
PAPER =
|
|
||||||
BUILDDIR = _build
|
|
||||||
|
|
||||||
# Internal variables.
|
|
||||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
|
||||||
PAPEROPT_letter = -D latex_paper_size=letter
|
|
||||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
|
||||||
# the i18n builder cannot share the environment and doctrees with the others
|
|
||||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
|
||||||
|
|
||||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext default
|
|
||||||
|
|
||||||
default: html
|
|
||||||
|
|
||||||
help:
|
|
||||||
@echo "Please use \`make <target>' where <target> is one of"
|
|
||||||
@echo " html to make standalone HTML files"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -rf $(BUILDDIR)/*
|
|
||||||
|
|
||||||
html:
|
|
||||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
|
||||||
@echo
|
|
||||||
@# FIXME: Remove this `cp` once HTML->Sphinx transition is completed.
|
|
||||||
@# Kind of a hack, but HTML-formatted docs are on the way out anyway.
|
|
||||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
|
||||||
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
libc++ Documentation
|
|
||||||
====================
|
|
||||||
|
|
||||||
The libc++ documentation is written using the Sphinx documentation generator. It is
|
|
||||||
currently tested with Sphinx 1.1.3.
|
|
||||||
|
|
||||||
To build the documents into html configure libc++ with the following cmake options:
|
|
||||||
|
|
||||||
* -DLLVM_ENABLE_SPHINX=ON
|
|
||||||
* -DLIBCXX_INCLUDE_DOCS=ON
|
|
||||||
|
|
||||||
After configuring libc++ with these options the make rule `docs-libcxx-html`
|
|
||||||
should be available.
|
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
==============
|
|
||||||
Testing libc++
|
|
||||||
==============
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Getting Started
|
|
||||||
===============
|
|
||||||
|
|
||||||
libc++ uses LIT to configure and run its tests. The primary way to run the
|
|
||||||
libc++ tests is by using make check-libcxx. However since libc++ can be used
|
|
||||||
in any number of possible configurations it is important to customize the way
|
|
||||||
LIT builds and runs the tests. This guide provides information on how to use
|
|
||||||
LIT directly to test libc++.
|
|
||||||
|
|
||||||
Please see the `Lit Command Guide`_ for more information about LIT.
|
|
||||||
|
|
||||||
.. _LIT Command Guide: http://llvm.org/docs/CommandGuide/lit.html
|
|
||||||
|
|
||||||
Setting up the Environment
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
After building libc++ you must setup your environment to test libc++ using
|
|
||||||
LIT.
|
|
||||||
|
|
||||||
#. Create a shortcut to the actual lit executable so that you can invoke it
|
|
||||||
easily from the command line.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ alias lit='python path/to/llvm/utils/lit/lit.py'
|
|
||||||
|
|
||||||
#. Tell LIT where to find your build configuration.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ export LIBCXX_SITE_CONFIG=path/to/build-libcxx/test/lit.site.cfg
|
|
||||||
|
|
||||||
Example Usage
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Once you have your environment set up and you have built libc++ you can run
|
|
||||||
parts of the libc++ test suite by simply running `lit` on a specified test or
|
|
||||||
directory. For example:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ cd path/to/src/libcxx
|
|
||||||
$ lit -sv test/std/re # Run all of the std::regex tests
|
|
||||||
$ lit -sv test/std/depr/depr.c.headers/stdlib_h.pass.cpp # Run a single test
|
|
||||||
$ lit -sv test/std/atomics test/std/threads # Test std::thread and std::atomic
|
|
||||||
|
|
||||||
Sometimes you'll want to change the way LIT is running the tests. Custom options
|
|
||||||
can be specified using the `--param=<name>=<val>` flag. The most common option
|
|
||||||
you'll want to change is the standard dialect (ie -std=c++XX). By default the
|
|
||||||
test suite will select the newest C++ dialect supported by the compiler and use
|
|
||||||
that. However if you want to manually specify the option like so:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ lit -sv test/std/containers # Run the tests with the newest -std
|
|
||||||
$ lit -sv --param=std=c++03 test/std/containers # Run the tests in C++03
|
|
||||||
|
|
||||||
Occasionally you'll want to add extra compile or link flags when testing.
|
|
||||||
You can do this as follows:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ lit -sv --param=compile_flags='-Wcustom-warning'
|
|
||||||
$ lit -sv --param=link_flags='-L/custom/library/path'
|
|
||||||
|
|
||||||
Some other common examples include:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
# Specify a custom compiler.
|
|
||||||
$ lit -sv --param=cxx_under_test=/opt/bin/g++ test/std
|
|
||||||
|
|
||||||
# Enable warnings in the test suite
|
|
||||||
$ lit -sv --param=enable_warnings=true test/std
|
|
||||||
|
|
||||||
# Use UBSAN when running the tests.
|
|
||||||
$ lit -sv --param=use_sanitizer=Undefined
|
|
||||||
|
|
||||||
|
|
||||||
LIT Options
|
|
||||||
===========
|
|
||||||
|
|
||||||
:program:`lit` [*options*...] [*filenames*...]
|
|
||||||
|
|
||||||
Command Line Options
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
To use these options you pass them on the LIT command line as --param NAME or
|
|
||||||
--param NAME=VALUE. Some options have default values specified during CMake's
|
|
||||||
configuration. Passing the option on the command line will override the default.
|
|
||||||
|
|
||||||
.. program:: lit
|
|
||||||
|
|
||||||
.. option:: cxx_under_test=<path/to/compiler>
|
|
||||||
|
|
||||||
Specify the compiler used to build the tests.
|
|
||||||
|
|
||||||
.. option:: cxx_stdlib_under_test=<stdlib name>
|
|
||||||
|
|
||||||
**Values**: libc++, libstdc++
|
|
||||||
|
|
||||||
Specify the C++ standard library being tested. Unless otherwise specified
|
|
||||||
libc++ is used. This option is intended to allow running the libc++ test
|
|
||||||
suite against other standard library implementations.
|
|
||||||
|
|
||||||
.. option:: std=<standard version>
|
|
||||||
|
|
||||||
**Values**: c++98, c++03, c++11, c++14, c++1z
|
|
||||||
|
|
||||||
Change the standard version used when building the tests.
|
|
||||||
|
|
||||||
.. option:: libcxx_site_config=<path/to/lit.site.cfg>
|
|
||||||
|
|
||||||
Specify the site configuration to use when running the tests. This option
|
|
||||||
overrides the environment variable LIBCXX_SITE_CONFIG.
|
|
||||||
|
|
||||||
.. option:: cxx_headers=<path/to/headers>
|
|
||||||
|
|
||||||
Specify the c++ standard library headers that are tested. By default the
|
|
||||||
headers in the source tree are used.
|
|
||||||
|
|
||||||
.. option:: cxx_library_root=<path/to/lib/>
|
|
||||||
|
|
||||||
Specify the directory of the libc++ library to be tested. By default the
|
|
||||||
library folder of the build directory is used. This option cannot be used
|
|
||||||
when use_system_cxx_lib is provided.
|
|
||||||
|
|
||||||
|
|
||||||
.. option:: cxx_runtime_root=<path/to/lib/>
|
|
||||||
|
|
||||||
Specify the directory of the libc++ library to use at runtime. This directory
|
|
||||||
is not added to the linkers search path. This can be used to compile tests
|
|
||||||
against one version of libc++ and run them using another. The default value
|
|
||||||
for this option is `cxx_library_root`. This option cannot be used
|
|
||||||
when use_system_cxx_lib is provided.
|
|
||||||
|
|
||||||
.. option:: use_system_cxx_lib=<bool>
|
|
||||||
|
|
||||||
**Default**: False
|
|
||||||
|
|
||||||
Enable or disable testing against the installed version of libc++ library.
|
|
||||||
Note: This does not use the installed headers.
|
|
||||||
|
|
||||||
.. option:: use_lit_shell=<bool>
|
|
||||||
|
|
||||||
Enable or disable the use of LIT's internal shell in ShTests. If the
|
|
||||||
environment variable LIT_USE_INTERNAL_SHELL is present then that is used as
|
|
||||||
the default value. Otherwise the default value is True on Windows and False
|
|
||||||
on every other platform.
|
|
||||||
|
|
||||||
.. option:: no_default_flags=<bool>
|
|
||||||
|
|
||||||
**Default**: False
|
|
||||||
|
|
||||||
Disable all default compile and link flags from being added. When this
|
|
||||||
option is used only flags specified using the compile_flags and link_flags
|
|
||||||
will be used.
|
|
||||||
|
|
||||||
.. option:: compile_flags="<list-of-args>"
|
|
||||||
|
|
||||||
Specify additional compile flags as a space delimited string.
|
|
||||||
Note: This options should not be used to change the standard version used.
|
|
||||||
|
|
||||||
.. option:: link_flags="<list-of-args>"
|
|
||||||
|
|
||||||
Specify additional link flags as a space delimited string.
|
|
||||||
|
|
||||||
.. option:: debug_level=<level>
|
|
||||||
|
|
||||||
**Values**: 0, 1
|
|
||||||
|
|
||||||
Enable the use of debug mode. Level 0 enables assertions and level 1 enables
|
|
||||||
assertions and debugging of iterator misuse.
|
|
||||||
|
|
||||||
.. option:: use_sanitizer=<sanitizer name>
|
|
||||||
|
|
||||||
**Values**: Memory, MemoryWithOrigins, Address, Undefined
|
|
||||||
|
|
||||||
Run the tests using the given sanitizer. If LLVM_USE_SANITIZER was given when
|
|
||||||
building libc++ then that sanitizer will be used by default.
|
|
||||||
|
|
||||||
.. option:: color_diagnostics
|
|
||||||
|
|
||||||
Enable the use of colorized compile diagnostics. If the color_diagnostics
|
|
||||||
option is specified or the environment variable LIBCXX_COLOR_DIAGNOSTICS is
|
|
||||||
present then color diagnostics will be enabled.
|
|
||||||
|
|
||||||
|
|
||||||
Environment Variables
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
.. envvar:: LIBCXX_SITE_CONFIG=<path/to/lit.site.cfg>
|
|
||||||
|
|
||||||
Specify the site configuration to use when running the tests.
|
|
||||||
Also see `libcxx_site_config`.
|
|
||||||
|
|
||||||
.. envvar:: LIBCXX_COLOR_DIAGNOSTICS
|
|
||||||
|
|
||||||
If ``LIBCXX_COLOR_DIAGNOSTICS`` is defined then the test suite will attempt
|
|
||||||
to use color diagnostic outputs from the compiler.
|
|
||||||
Also see `color_diagnostics`.
|
|
||||||
|
|
||||||
Benchmarks
|
|
||||||
==========
|
|
||||||
|
|
||||||
Libc++ contains benchmark tests separately from the test of the test suite.
|
|
||||||
The benchmarks are written using the `Google Benchmark`_ library, a copy of which
|
|
||||||
is stored in the libc++ repository.
|
|
||||||
|
|
||||||
For more information about using the Google Benchmark library see the
|
|
||||||
`official documentation <https://github.com/google/benchmark>`_.
|
|
||||||
|
|
||||||
.. _`Google Benchmark`: https://github.com/google/benchmark
|
|
||||||
|
|
||||||
Building Benchmarks
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
The benchmark tests are not built by default. The benchmarks can be built using
|
|
||||||
the ``cxx-benchmarks`` target.
|
|
||||||
|
|
||||||
An example build would look like:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ cd build
|
|
||||||
$ cmake [options] <path to libcxx sources>
|
|
||||||
$ make cxx-benchmarks
|
|
||||||
|
|
||||||
This will build all of the benchmarks under ``<libcxx-src>/benchmarks`` to be
|
|
||||||
built against the just-built libc++. The compiled tests are output into
|
|
||||||
``build/benchmarks``.
|
|
||||||
|
|
||||||
The benchmarks can also be built against the platforms native standard library
|
|
||||||
using the ``-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON`` CMake option. This
|
|
||||||
is useful for comparing the performance of libc++ to other standard libraries.
|
|
||||||
The compiled benchmarks are named ``<test>.libcxx.out`` if they test libc++ and
|
|
||||||
``<test>.native.out`` otherwise.
|
|
||||||
|
|
||||||
Also See:
|
|
||||||
|
|
||||||
* :ref:`Building Libc++ <build instructions>`
|
|
||||||
* :ref:`CMake Options`
|
|
||||||
|
|
||||||
Running Benchmarks
|
|
||||||
------------------
|
|
||||||
|
|
||||||
The benchmarks must be run manually by the user. Currently there is no way
|
|
||||||
to run them as part of the build.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ cd build/benchmarks
|
|
||||||
$ make cxx-benchmarks
|
|
||||||
$ ./algorithms.libcxx.out # Runs all the benchmarks
|
|
||||||
$ ./algorithms.libcxx.out --benchmark_filter=BM_Sort.* # Only runs the sort benchmarks
|
|
||||||
|
|
||||||
For more information about running benchmarks see `Google Benchmark`_.
|
|
||||||
@@ -1,199 +0,0 @@
|
|||||||
============
|
|
||||||
Using libc++
|
|
||||||
============
|
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Getting Started
|
|
||||||
===============
|
|
||||||
|
|
||||||
If you already have libc++ installed you can use it with clang.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -stdlib=libc++ test.cpp
|
|
||||||
$ clang++ -std=c++11 -stdlib=libc++ test.cpp
|
|
||||||
|
|
||||||
On OS X and FreeBSD libc++ is the default standard library
|
|
||||||
and the ``-stdlib=libc++`` is not required.
|
|
||||||
|
|
||||||
.. _alternate libcxx:
|
|
||||||
|
|
||||||
If you want to select an alternate installation of libc++ you
|
|
||||||
can use the following options.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -std=c++11 -stdlib=libc++ -nostdinc++ \
|
|
||||||
-I<libcxx-install-prefix>/include/c++/v1 \
|
|
||||||
-L<libcxx-install-prefix>/lib \
|
|
||||||
-Wl,-rpath,<libcxx-install-prefix>/lib \
|
|
||||||
test.cpp
|
|
||||||
|
|
||||||
The option ``-Wl,-rpath,<libcxx-install-prefix>/lib`` adds a runtime library
|
|
||||||
search path. Meaning that the systems dynamic linker will look for libc++ in
|
|
||||||
``<libcxx-install-prefix>/lib`` whenever the program is run. Alternatively the
|
|
||||||
environment variable ``LD_LIBRARY_PATH`` (``DYLD_LIBRARY_PATH`` on OS X) can
|
|
||||||
be used to change the dynamic linkers search paths after a program is compiled.
|
|
||||||
|
|
||||||
An example of using ``LD_LIBRARY_PATH``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -stdlib=libc++ -nostdinc++ \
|
|
||||||
-I<libcxx-install-prefix>/include/c++/v1
|
|
||||||
-L<libcxx-install-prefix>/lib \
|
|
||||||
test.cpp -o
|
|
||||||
$ ./a.out # Searches for libc++ in the systems library paths.
|
|
||||||
$ export LD_LIBRARY_PATH=<libcxx-install-prefix>/lib
|
|
||||||
$ ./a.out # Searches for libc++ along LD_LIBRARY_PATH
|
|
||||||
|
|
||||||
Using libc++experimental and ``<experimental/...>``
|
|
||||||
=====================================================
|
|
||||||
|
|
||||||
Libc++ provides implementations of experimental technical specifications
|
|
||||||
in a separate library, ``libc++experimental.a``. Users of ``<experimental/...>``
|
|
||||||
headers may be required to link ``-lc++experimental``.
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -std=c++14 -stdlib=libc++ test.cpp -lc++experimental
|
|
||||||
|
|
||||||
Libc++experimental.a may not always be available, even when libc++ is already
|
|
||||||
installed. For information on building libc++experimental from source see
|
|
||||||
:ref:`Building Libc++ <build instructions>` and
|
|
||||||
:ref:`libc++experimental CMake Options <libc++experimental options>`.
|
|
||||||
|
|
||||||
Also see the `Experimental Library Implementation Status <http://libcxx.llvm.org/ts1z_status.html>`__
|
|
||||||
page.
|
|
||||||
|
|
||||||
.. warning::
|
|
||||||
Experimental libraries are Experimental.
|
|
||||||
* The contents of the ``<experimental/...>`` headers and ``libc++experimental.a``
|
|
||||||
library will not remain compatible between versions.
|
|
||||||
* No guarantees of API or ABI stability are provided.
|
|
||||||
|
|
||||||
Using libc++ on Linux
|
|
||||||
=====================
|
|
||||||
|
|
||||||
On Linux libc++ can typically be used with only '-stdlib=libc++'. However
|
|
||||||
some libc++ installations require the user manually link libc++abi themselves.
|
|
||||||
If you are running into linker errors when using libc++ try adding '-lc++abi'
|
|
||||||
to the link line. For example:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -stdlib=libc++ test.cpp -lc++ -lc++abi -lm -lc -lgcc_s -lgcc
|
|
||||||
|
|
||||||
Alternately, you could just add libc++abi to your libraries list, which in
|
|
||||||
most situations will give the same result:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ clang++ -stdlib=libc++ test.cpp -lc++abi
|
|
||||||
|
|
||||||
|
|
||||||
Using libc++ with GCC
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
GCC does not provide a way to switch from libstdc++ to libc++. You must manually
|
|
||||||
configure the compile and link commands.
|
|
||||||
|
|
||||||
In particular you must tell GCC to remove the libstdc++ include directories
|
|
||||||
using ``-nostdinc++`` and to not link libstdc++.so using ``-nodefaultlibs``.
|
|
||||||
|
|
||||||
Note that ``-nodefaultlibs`` removes all of the standard system libraries and
|
|
||||||
not just libstdc++ so they must be manually linked. For example:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ g++ -nostdinc++ -I<libcxx-install-prefix>/include/c++/v1 \
|
|
||||||
test.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc
|
|
||||||
|
|
||||||
|
|
||||||
GDB Pretty printers for libc++
|
|
||||||
------------------------------
|
|
||||||
|
|
||||||
GDB does not support pretty-printing of libc++ symbols by default. Unfortunately
|
|
||||||
libc++ does not provide pretty-printers itself. However there are 3rd
|
|
||||||
party implementations available and although they are not officially
|
|
||||||
supported by libc++ they may be useful to users.
|
|
||||||
|
|
||||||
Known 3rd Party Implementations Include:
|
|
||||||
|
|
||||||
* `Koutheir's libc++ pretty-printers <https://github.com/koutheir/libcxx-pretty-printers>`_.
|
|
||||||
|
|
||||||
|
|
||||||
Libc++ Configuration Macros
|
|
||||||
===========================
|
|
||||||
|
|
||||||
Libc++ provides a number of configuration macros which can be used to enable
|
|
||||||
or disable extended libc++ behavior, including enabling "debug mode" or
|
|
||||||
thread safety annotations.
|
|
||||||
|
|
||||||
**_LIBCPP_DEBUG**:
|
|
||||||
See :ref:`using-debug-mode` for more information.
|
|
||||||
|
|
||||||
**_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**:
|
|
||||||
This macro is used to enable -Wthread-safety annotations on libc++'s
|
|
||||||
``std::mutex`` and ``std::lock_guard``. By default these annotations are
|
|
||||||
disabled and must be manually enabled by the user.
|
|
||||||
|
|
||||||
**_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS**:
|
|
||||||
This macro is used to disable all visibility annotations inside libc++.
|
|
||||||
Defining this macro and then building libc++ with hidden visibility gives a
|
|
||||||
build of libc++ which does not export any symbols, which can be useful when
|
|
||||||
building statically for inclusion into another library.
|
|
||||||
|
|
||||||
**_LIBCPP_DISABLE_EXTERN_TEMPLATE**:
|
|
||||||
This macro is used to disable extern template declarations in the libc++
|
|
||||||
headers. The intended use case is for clients who wish to use the libc++
|
|
||||||
headers without taking a dependency on the libc++ library itself.
|
|
||||||
|
|
||||||
**_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
|
|
||||||
This macro is used to re-enable an extension in `std::tuple` which allowed
|
|
||||||
it to be implicitly constructed from fewer initializers than contained
|
|
||||||
elements. Elements without an initializer are default constructed. For example:
|
|
||||||
|
|
||||||
.. code-block:: cpp
|
|
||||||
|
|
||||||
std::tuple<std::string, int, std::error_code> foo() {
|
|
||||||
return {"hello world", 42}; // default constructs error_code
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Since libc++ 4.0 this extension has been disabled by default. This macro
|
|
||||||
may be defined to re-enable it in order to support existing code that depends
|
|
||||||
on the extension. New use of this extension should be discouraged.
|
|
||||||
See `PR 27374 <http://llvm.org/PR27374>`_ for more information.
|
|
||||||
|
|
||||||
Note: The "reduced-arity-initialization" extension is still offered but only
|
|
||||||
for explicit conversions. Example:
|
|
||||||
|
|
||||||
.. code-block:: cpp
|
|
||||||
|
|
||||||
auto foo() {
|
|
||||||
using Tup = std::tuple<std::string, int, std::error_code>;
|
|
||||||
return Tup{"hello world", 42}; // explicit constructor called. OK.
|
|
||||||
}
|
|
||||||
|
|
||||||
**_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS**:
|
|
||||||
This macro disables the additional diagnostics generated by libc++ using the
|
|
||||||
`diagnose_if` attribute. These additional diagnostics include checks for:
|
|
||||||
|
|
||||||
* Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
|
|
||||||
const callable.
|
|
||||||
|
|
||||||
C++17 Specific Configuration Macros
|
|
||||||
-----------------------------------
|
|
||||||
**_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
|
|
||||||
This macro is used to re-enable all the features removed in C++17. The effect
|
|
||||||
is equivalent to manually defining each macro listed below.
|
|
||||||
|
|
||||||
**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**:
|
|
||||||
This macro is used to re-enable the `set_unexpected`, `get_unexpected`, and
|
|
||||||
`unexpected` functions, which were removed in C++17.
|
|
||||||
|
|
||||||
**_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**:
|
|
||||||
This macro is used to re-enable `std::auto_ptr` in C++17.
|
|
||||||
-251
@@ -1,251 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# libc++ documentation build configuration file.
|
|
||||||
#
|
|
||||||
# This file is execfile()d with the current directory set to its containing dir.
|
|
||||||
#
|
|
||||||
# Note that not all possible configuration values are present in this
|
|
||||||
# autogenerated file.
|
|
||||||
#
|
|
||||||
# All configuration values have a default; values that are commented out
|
|
||||||
# serve to show the default.
|
|
||||||
|
|
||||||
import sys, os
|
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
||||||
#sys.path.insert(0, os.path.abspath('.'))
|
|
||||||
|
|
||||||
# -- General configuration -----------------------------------------------------
|
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
|
||||||
#needs_sphinx = '1.0'
|
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
|
||||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
|
||||||
extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo']
|
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
|
||||||
templates_path = ['_templates']
|
|
||||||
|
|
||||||
# The suffix of source filenames.
|
|
||||||
source_suffix = '.rst'
|
|
||||||
|
|
||||||
# The encoding of source files.
|
|
||||||
#source_encoding = 'utf-8-sig'
|
|
||||||
|
|
||||||
# The master toctree document.
|
|
||||||
master_doc = 'index'
|
|
||||||
|
|
||||||
# General information about the project.
|
|
||||||
project = u'libc++'
|
|
||||||
copyright = u'2011-2017, LLVM Project'
|
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
|
||||||
# |version| and |release|, also used in various other places throughout the
|
|
||||||
# built documents.
|
|
||||||
#
|
|
||||||
# The short X.Y version.
|
|
||||||
version = '5.0'
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
|
||||||
release = '5.0'
|
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
||||||
# for a list of supported languages.
|
|
||||||
#language = None
|
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
|
||||||
# non-false value, then it is used:
|
|
||||||
#today = ''
|
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
|
||||||
today_fmt = '%Y-%m-%d'
|
|
||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
|
||||||
# directories to ignore when looking for source files.
|
|
||||||
exclude_patterns = ['_build']
|
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
|
||||||
#default_role = None
|
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
|
||||||
#add_function_parentheses = True
|
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
|
||||||
# unit titles (such as .. function::).
|
|
||||||
#add_module_names = True
|
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
|
||||||
# output. They are ignored by default.
|
|
||||||
show_authors = True
|
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
|
||||||
pygments_style = 'friendly'
|
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
|
||||||
#modindex_common_prefix = []
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ---------------------------------------------------
|
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
||||||
# a list of builtin themes.
|
|
||||||
html_theme = 'haiku'
|
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
|
||||||
# further. For a list of options available for each theme, see the
|
|
||||||
# documentation.
|
|
||||||
#html_theme_options = {}
|
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
|
||||||
#html_theme_path = []
|
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
|
||||||
# "<project> v<release> documentation".
|
|
||||||
#html_title = None
|
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
|
||||||
#html_short_title = None
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top
|
|
||||||
# of the sidebar.
|
|
||||||
#html_logo = None
|
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
|
||||||
# pixels large.
|
|
||||||
#html_favicon = None
|
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
||||||
html_static_path = []
|
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
|
||||||
# using the given strftime format.
|
|
||||||
#html_last_updated_fmt = '%b %d, %Y'
|
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
|
||||||
# typographically correct entities.
|
|
||||||
#html_use_smartypants = True
|
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
|
||||||
#html_sidebars = {}
|
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
|
||||||
# template names.
|
|
||||||
#html_additional_pages = {}
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
#html_domain_indices = True
|
|
||||||
|
|
||||||
# If false, no index is generated.
|
|
||||||
#html_use_index = True
|
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
|
||||||
#html_split_index = False
|
|
||||||
|
|
||||||
# If true, links to the reST sources are added to the pages.
|
|
||||||
#html_show_sourcelink = True
|
|
||||||
|
|
||||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
|
||||||
#html_show_sphinx = True
|
|
||||||
|
|
||||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
|
||||||
#html_show_copyright = True
|
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
|
||||||
# base URL from which the finished HTML is served.
|
|
||||||
#html_use_opensearch = ''
|
|
||||||
|
|
||||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
|
||||||
#html_file_suffix = None
|
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
|
||||||
htmlhelp_basename = 'libcxxdoc'
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output --------------------------------------------------
|
|
||||||
|
|
||||||
latex_elements = {
|
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
|
||||||
#'papersize': 'letterpaper',
|
|
||||||
|
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
|
||||||
#'pointsize': '10pt',
|
|
||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
|
||||||
#'preamble': '',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
|
||||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
|
||||||
latex_documents = [
|
|
||||||
('contents', 'libcxx.tex', u'libcxx Documentation',
|
|
||||||
u'LLVM project', 'manual'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
|
||||||
# the title page.
|
|
||||||
#latex_logo = None
|
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
|
||||||
# not chapters.
|
|
||||||
#latex_use_parts = False
|
|
||||||
|
|
||||||
# If true, show page references after internal links.
|
|
||||||
#latex_show_pagerefs = False
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
#latex_show_urls = False
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
#latex_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
#latex_domain_indices = True
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for manual page output --------------------------------------------
|
|
||||||
|
|
||||||
# One entry per manual page. List of tuples
|
|
||||||
# (source start file, name, description, authors, manual section).
|
|
||||||
man_pages = [
|
|
||||||
('contents', 'libc++', u'libc++ Documentation',
|
|
||||||
[u'LLVM project'], 1)
|
|
||||||
]
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
#man_show_urls = False
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for Texinfo output ------------------------------------------------
|
|
||||||
|
|
||||||
# Grouping the document tree into Texinfo files. List of tuples
|
|
||||||
# (source start file, target name, title, author,
|
|
||||||
# dir menu entry, description, category)
|
|
||||||
texinfo_documents = [
|
|
||||||
('contents', 'libc++', u'libc++ Documentation',
|
|
||||||
u'LLVM project', 'libc++', 'One line description of project.',
|
|
||||||
'Miscellaneous'),
|
|
||||||
]
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
#texinfo_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
#texinfo_domain_indices = True
|
|
||||||
|
|
||||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
|
||||||
#texinfo_show_urls = 'footnote'
|
|
||||||
|
|
||||||
|
|
||||||
# FIXME: Define intersphinx configration.
|
|
||||||
intersphinx_mapping = {}
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for extensions ----------------------------------------------------
|
|
||||||
|
|
||||||
# Enable this if you want TODOs to show up in the generated documentation.
|
|
||||||
todo_include_todos = True
|
|
||||||
-188
@@ -1,188 +0,0 @@
|
|||||||
.. _index:
|
|
||||||
|
|
||||||
=============================
|
|
||||||
"libc++" C++ Standard Library
|
|
||||||
=============================
|
|
||||||
|
|
||||||
Overview
|
|
||||||
========
|
|
||||||
|
|
||||||
libc++ is a new implementation of the C++ standard library, targeting C++11 and
|
|
||||||
above.
|
|
||||||
|
|
||||||
* Features and Goals
|
|
||||||
|
|
||||||
* Correctness as defined by the C++11 standard.
|
|
||||||
* Fast execution.
|
|
||||||
* Minimal memory use.
|
|
||||||
* Fast compile times.
|
|
||||||
* ABI compatibility with gcc's libstdc++ for some low-level features
|
|
||||||
such as exception objects, rtti and memory allocation.
|
|
||||||
* Extensive unit tests.
|
|
||||||
|
|
||||||
* Design and Implementation:
|
|
||||||
|
|
||||||
* Extensive unit tests
|
|
||||||
* Internal linker model can be dumped/read to textual format
|
|
||||||
* Additional linking features can be plugged in as "passes"
|
|
||||||
* OS specific and CPU specific code factored out
|
|
||||||
|
|
||||||
|
|
||||||
Getting Started with libc++
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 2
|
|
||||||
|
|
||||||
UsingLibcxx
|
|
||||||
BuildingLibcxx
|
|
||||||
TestingLibcxx
|
|
||||||
|
|
||||||
|
|
||||||
Current Status
|
|
||||||
--------------
|
|
||||||
|
|
||||||
After its initial introduction, many people have asked "why start a new
|
|
||||||
library instead of contributing to an existing library?" (like Apache's
|
|
||||||
libstdcxx, GNU's libstdc++, STLport, etc). There are many contributing
|
|
||||||
reasons, but some of the major ones are:
|
|
||||||
|
|
||||||
* From years of experience (including having implemented the standard
|
|
||||||
library before), we've learned many things about implementing
|
|
||||||
the standard containers which require ABI breakage and fundamental changes
|
|
||||||
to how they are implemented. For example, it is generally accepted that
|
|
||||||
building std::string using the "short string optimization" instead of
|
|
||||||
using Copy On Write (COW) is a superior approach for multicore
|
|
||||||
machines (particularly in C++11, which has rvalue references). Breaking
|
|
||||||
ABI compatibility with old versions of the library was
|
|
||||||
determined to be critical to achieving the performance goals of
|
|
||||||
libc++.
|
|
||||||
|
|
||||||
* Mainline libstdc++ has switched to GPL3, a license which the developers
|
|
||||||
of libc++ cannot use. libstdc++ 4.2 (the last GPL2 version) could be
|
|
||||||
independently extended to support C++11, but this would be a fork of the
|
|
||||||
codebase (which is often seen as worse for a project than starting a new
|
|
||||||
independent one). Another problem with libstdc++ is that it is tightly
|
|
||||||
integrated with G++ development, tending to be tied fairly closely to the
|
|
||||||
matching version of G++.
|
|
||||||
|
|
||||||
* STLport and the Apache libstdcxx library are two other popular
|
|
||||||
candidates, but both lack C++11 support. Our experience (and the
|
|
||||||
experience of libstdc++ developers) is that adding support for C++11 (in
|
|
||||||
particular rvalue references and move-only types) requires changes to
|
|
||||||
almost every class and function, essentially amounting to a rewrite.
|
|
||||||
Faced with a rewrite, we decided to start from scratch and evaluate every
|
|
||||||
design decision from first principles based on experience.
|
|
||||||
Further, both projects are apparently abandoned: STLport 5.2.1 was
|
|
||||||
released in Oct'08, and STDCXX 4.2.1 in May'08.
|
|
||||||
|
|
||||||
Platform and Compiler Support
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
libc++ is known to work on the following platforms, using gcc-4.2 and
|
|
||||||
clang (lack of C++11 language support disables some functionality).
|
|
||||||
Note that functionality provided by ``<atomic>`` is only functional with clang
|
|
||||||
and GCC.
|
|
||||||
|
|
||||||
============ ==================== ============ ========================
|
|
||||||
OS Arch Compilers ABI Library
|
|
||||||
============ ==================== ============ ========================
|
|
||||||
Mac OS X i386, x86_64 Clang, GCC libc++abi
|
|
||||||
FreeBSD 10+ i386, x86_64, ARM Clang, GCC libcxxrt, libc++abi
|
|
||||||
Linux i386, x86_64 Clang, GCC libc++abi
|
|
||||||
============ ==================== ============ ========================
|
|
||||||
|
|
||||||
The following minimum compiler versions are strongly recommended.
|
|
||||||
|
|
||||||
* Clang 3.5 and above
|
|
||||||
* GCC 4.7 and above.
|
|
||||||
|
|
||||||
Anything older *may* work.
|
|
||||||
|
|
||||||
C++ Dialect Support
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
* C++11 - Complete
|
|
||||||
* `C++14 - Complete <http://libcxx.llvm.org/cxx1y_status.html>`__
|
|
||||||
* `C++1z - In Progress <http://libcxx.llvm.org/cxx1z_status.html>`__
|
|
||||||
* `Post C++14 Technical Specifications - In Progress <http://libcxx.llvm.org/ts1z_status.html>`__
|
|
||||||
|
|
||||||
Notes and Known Issues
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
This list contains known issues with libc++
|
|
||||||
|
|
||||||
* Building libc++ with ``-fno-rtti`` is not supported. However
|
|
||||||
linking against it with ``-fno-rtti`` is supported.
|
|
||||||
* On OS X v10.8 and older the CMake option ``-DLIBCXX_LIBCPPABI_VERSION=""``
|
|
||||||
must be used during configuration.
|
|
||||||
|
|
||||||
|
|
||||||
A full list of currently open libc++ bugs can be `found here`__.
|
|
||||||
|
|
||||||
.. __: https://bugs.llvm.org/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184
|
|
||||||
|
|
||||||
Design Documents
|
|
||||||
----------------
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 1
|
|
||||||
|
|
||||||
DesignDocs/AvailabilityMarkup
|
|
||||||
DesignDocs/DebugMode
|
|
||||||
DesignDocs/CapturingConfigInfo
|
|
||||||
DesignDocs/ABIVersioning
|
|
||||||
DesignDocs/VisibilityMacros
|
|
||||||
DesignDocs/ThreadingSupportAPI
|
|
||||||
|
|
||||||
* `<atomic> design <http://libcxx.llvm.org/atomic_design.html>`_
|
|
||||||
* `<type_traits> design <http://libcxx.llvm.org/type_traits_design.html>`_
|
|
||||||
* `Notes by Marshall Clow`__
|
|
||||||
|
|
||||||
.. __: https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/
|
|
||||||
|
|
||||||
Build Bots and Test Coverage
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
* `LLVM Buildbot Builders <http://lab.llvm.org:8011/console>`_
|
|
||||||
* `Apple Jenkins Builders <http://lab.llvm.org:8080/green/view/Libcxx/>`_
|
|
||||||
* `Windows Appveyor Builders <https://ci.appveyor.com/project/llvm-mirror/libcxx>`_
|
|
||||||
* `Code Coverage Results <http://efcs.ca/libcxx-coverage>`_
|
|
||||||
|
|
||||||
Getting Involved
|
|
||||||
================
|
|
||||||
|
|
||||||
First please review our `Developer's Policy <http://llvm.org/docs/DeveloperPolicy.html>`__
|
|
||||||
and `Getting started with LLVM <http://llvm.org/docs/GettingStarted.html>`__.
|
|
||||||
|
|
||||||
**Bug Reports**
|
|
||||||
|
|
||||||
If you think you've found a bug in libc++, please report it using
|
|
||||||
the `LLVM Bugzilla`_. If you're not sure, you
|
|
||||||
can post a message to the `cfe-dev mailing list`_ or on IRC.
|
|
||||||
Please include "libc++" in your subject.
|
|
||||||
|
|
||||||
**Patches**
|
|
||||||
|
|
||||||
If you want to contribute a patch to libc++, the best place for that is
|
|
||||||
`Phabricator <http://llvm.org/docs/Phabricator.html>`_. Please include [libcxx] in the subject and
|
|
||||||
add `cfe-commits` as a subscriber. Also make sure you are subscribed to the
|
|
||||||
`cfe-commits mailing list <http://lists.llvm.org/mailman/listinfo/cfe-commits>`_.
|
|
||||||
|
|
||||||
**Discussion and Questions**
|
|
||||||
|
|
||||||
Send discussions and questions to the
|
|
||||||
`cfe-dev mailing list <http://lists.llvm.org/mailman/listinfo/cfe-dev>`_.
|
|
||||||
Please include [libcxx] in the subject.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Quick Links
|
|
||||||
===========
|
|
||||||
* `LLVM Homepage <http://llvm.org/>`_
|
|
||||||
* `libc++abi Homepage <http://libcxxabi.llvm.org/>`_
|
|
||||||
* `LLVM Bugzilla <https://bugs.llvm.org/>`_
|
|
||||||
* `cfe-commits Mailing List`_
|
|
||||||
* `cfe-dev Mailing List`_
|
|
||||||
* `Browse libc++ -- SVN <http://llvm.org/svn/llvm-project/libcxx/trunk/>`_
|
|
||||||
* `Browse libc++ -- ViewVC <http://llvm.org/viewvc/llvm-project/libcxx/trunk/>`_
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
macro(pythonize_bool var)
|
|
||||||
if (${var})
|
|
||||||
set(${var} True)
|
|
||||||
else()
|
|
||||||
set(${var} False)
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
|
|
||||||
"Configuration variant to use for LIT.")
|
|
||||||
|
|
||||||
# The tests shouldn't link to any ABI library when it has been linked into
|
|
||||||
# libc++ statically or via a linker script.
|
|
||||||
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
||||||
set(LIBCXX_CXX_ABI_LIBNAME "none")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# The tests shouldn't link to libunwind if we have a linker script which
|
|
||||||
# already does so.
|
|
||||||
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
||||||
set(LIBCXXABI_USE_LLVM_UNWINDER OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
|
|
||||||
pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
|
|
||||||
pythonize_bool(LIBCXX_ENABLE_FILESYSTEM)
|
|
||||||
pythonize_bool(LIBCXX_ENABLE_RTTI)
|
|
||||||
pythonize_bool(LIBCXX_ENABLE_SHARED)
|
|
||||||
pythonize_bool(LIBCXX_BUILD_32_BITS)
|
|
||||||
pythonize_bool(LIBCXX_GENERATE_COVERAGE)
|
|
||||||
pythonize_bool(LIBCXXABI_ENABLE_SHARED)
|
|
||||||
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
|
|
||||||
pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
|
|
||||||
pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
|
|
||||||
pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
|
|
||||||
pythonize_bool(LIBCXX_DEBUG_BUILD)
|
|
||||||
|
|
||||||
# By default, for non-standalone builds, libcxx and libcxxabi share a library
|
|
||||||
# directory.
|
|
||||||
if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
|
|
||||||
set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
|
|
||||||
"The path to libc++abi library.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
|
|
||||||
"TargetInfo to use when setting up test environment.")
|
|
||||||
set(LIBCXX_EXECUTOR "None" CACHE STRING
|
|
||||||
"Executor to use when running tests.")
|
|
||||||
|
|
||||||
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
|
|
||||||
|
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
||||||
@ONLY)
|
|
||||||
|
|
||||||
set(LIBCXX_TEST_DEPS "")
|
|
||||||
|
|
||||||
if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
|
|
||||||
set(LIBCXX_TEST_DEPS cxx_experimental)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
|
|
||||||
list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (LIBCXX_INCLUDE_TESTS)
|
|
||||||
include(AddLLVM) # for add_lit_testsuite
|
|
||||||
add_lit_testsuite(check-cxx
|
|
||||||
"Running libcxx tests"
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
DEPENDS cxx ${LIBCXX_TEST_DEPS})
|
|
||||||
|
|
||||||
add_custom_target(check-libcxx DEPENDS check-cxx)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (LIBCXX_GENERATE_COVERAGE)
|
|
||||||
include(CodeCoverage)
|
|
||||||
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
|
|
||||||
set(capture_dirs
|
|
||||||
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
|
|
||||||
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
|
|
||||||
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}")
|
|
||||||
set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
|
|
||||||
setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if (LIBCXX_CONFIGURE_IDE)
|
|
||||||
# Create dummy targets for each of the tests in the test suite, this allows
|
|
||||||
# IDE's such as CLion to correctly highlight the tests because it knows
|
|
||||||
# roughly what include paths/compile flags/macro definitions are needed.
|
|
||||||
include_directories(support)
|
|
||||||
file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
|
|
||||||
file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
|
|
||||||
file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
|
|
||||||
add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
|
|
||||||
${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
|
|
||||||
add_dependencies(libcxx_test_objects cxx)
|
|
||||||
|
|
||||||
set(STATIC_ROOT ${LIBCXX_SOURCE_DIR}/test/std/experimental/filesystem/Inputs/static_test_env)
|
|
||||||
add_definitions(-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="${STATIC_ROOT}")
|
|
||||||
|
|
||||||
set(DYNAMIC_ROOT ${LIBCXX_BINARY_DIR}/test/filesystem/Output/dynamic_env)
|
|
||||||
add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="${DYNAMIC_ROOT}")
|
|
||||||
|
|
||||||
set(DYNAMIC_HELPER "python ${LIBCXX_SOURCE_DIR}/test/support/filesystem_dynamic_test_helper.py ")
|
|
||||||
add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="${DYNAMIC_HELPER}")
|
|
||||||
|
|
||||||
split_list(LIBCXX_COMPILE_FLAGS)
|
|
||||||
split_list(LIBCXX_LINK_FLAGS)
|
|
||||||
|
|
||||||
set_target_properties(libcxx_test_objects
|
|
||||||
PROPERTIES
|
|
||||||
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
|
||||||
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
|
||||||
EXCLUDE_FROM_ALL ON
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
-47
@@ -1,47 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <memory>
|
|
||||||
|
|
||||||
// template <class RandomAccessIterator>
|
|
||||||
// void
|
|
||||||
// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
|
|
||||||
//
|
|
||||||
// template <class RandomAccessIterator, class RandomNumberGenerator>
|
|
||||||
// void
|
|
||||||
// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
|
|
||||||
// RandomNumberGenerator& rand);
|
|
||||||
|
|
||||||
//
|
|
||||||
// In C++17, random_shuffle has been removed.
|
|
||||||
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
|
|
||||||
// is defined before including <algorithm>, then random_shuffle will be restored.
|
|
||||||
|
|
||||||
// MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
|
|
||||||
#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct gen
|
|
||||||
{
|
|
||||||
std::ptrdiff_t operator()(std::ptrdiff_t n)
|
|
||||||
{
|
|
||||||
return n-1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::vector<int> v;
|
|
||||||
std::random_shuffle(v.begin(), v.end());
|
|
||||||
gen r;
|
|
||||||
std::random_shuffle(v.begin(), v.end(), r);
|
|
||||||
}
|
|
||||||
@@ -1,167 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <algorithm>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,93 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// 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; });
|
|
||||||
}
|
|
||||||
@@ -1,31 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// UNSUPPORTED: libcpp-has-no-threads
|
|
||||||
|
|
||||||
// <atomic>
|
|
||||||
|
|
||||||
// struct atomic_flag
|
|
||||||
|
|
||||||
// TESTING EXTENSION atomic_flag(bool)
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
std::atomic_flag f(false);
|
|
||||||
assert(f.test_and_set() == 0);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
std::atomic_flag f(true);
|
|
||||||
assert(f.test_and_set() == 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,128 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// This test fails because diagnose_if doesn't emit all of the diagnostics
|
|
||||||
// when -fdelayed-template-parsing is enabled, like it is on Windows.
|
|
||||||
// XFAIL: LIBCXX-WINDOWS-FIXME
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <atomic>
|
|
||||||
|
|
||||||
// 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
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,18 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// XFAIL: libcpp-has-no-threads
|
|
||||||
|
|
||||||
#ifdef _LIBCPP_HAS_NO_THREADS
|
|
||||||
#error This should be XFAIL'd for the purpose of detecting that the LIT feature\
|
|
||||||
'libcpp-has-no-threads' is available iff _LIBCPP_HAS_NO_THREADS is defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// UNSUPPORTED: libcpp-has-no-threads
|
|
||||||
|
|
||||||
// <atomic>
|
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <map>
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,47 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <set>
|
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include <__tree>
|
|
||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
#include "test_macros.h"
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
void testKeyValueTrait() {
|
|
||||||
{
|
|
||||||
typedef int Tp;
|
|
||||||
typedef std::__tree_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, int>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
|
|
||||||
static_assert(Traits::__is_map == false, "");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
typedef std::pair<int, int> Tp;
|
|
||||||
typedef std::__tree_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
|
|
||||||
static_assert(Traits::__is_map == false, "");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
typedef std::pair<const int, int> Tp;
|
|
||||||
typedef std::__tree_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
|
|
||||||
static_assert(Traits::__is_map == false, "");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
typedef std::__value_type<int, int> Tp;
|
|
||||||
typedef std::__tree_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, int>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::mapped_type, int>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type,
|
|
||||||
std::pair<const int, int> >::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__map_value_type,
|
|
||||||
std::pair<const int, int> >::value), "");
|
|
||||||
static_assert(Traits::__is_map == true, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
testKeyValueTrait();
|
|
||||||
}
|
|
||||||
@@ -1,101 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Not a portable test
|
|
||||||
|
|
||||||
// Precondition: __x->__right_ != nullptr
|
|
||||||
// template <class _NodePtr>
|
|
||||||
// void
|
|
||||||
// __tree_left_rotate(_NodePtr __x);
|
|
||||||
|
|
||||||
#include <__tree>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
struct Node
|
|
||||||
{
|
|
||||||
Node* __left_;
|
|
||||||
Node* __right_;
|
|
||||||
Node* __parent_;
|
|
||||||
|
|
||||||
Node* __parent_unsafe() const { return __parent_; }
|
|
||||||
void __set_parent(Node* x) { __parent_ = x;}
|
|
||||||
|
|
||||||
Node() : __left_(), __right_(), __parent_() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
test1()
|
|
||||||
{
|
|
||||||
Node root;
|
|
||||||
Node x;
|
|
||||||
Node y;
|
|
||||||
root.__left_ = &x;
|
|
||||||
x.__left_ = 0;
|
|
||||||
x.__right_ = &y;
|
|
||||||
x.__parent_ = &root;
|
|
||||||
y.__left_ = 0;
|
|
||||||
y.__right_ = 0;
|
|
||||||
y.__parent_ = &x;
|
|
||||||
std::__tree_left_rotate(&x);
|
|
||||||
assert(root.__parent_ == 0);
|
|
||||||
assert(root.__left_ == &y);
|
|
||||||
assert(root.__right_ == 0);
|
|
||||||
assert(y.__parent_ == &root);
|
|
||||||
assert(y.__left_ == &x);
|
|
||||||
assert(y.__right_ == 0);
|
|
||||||
assert(x.__parent_ == &y);
|
|
||||||
assert(x.__left_ == 0);
|
|
||||||
assert(x.__right_ == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test2()
|
|
||||||
{
|
|
||||||
Node root;
|
|
||||||
Node x;
|
|
||||||
Node y;
|
|
||||||
Node a;
|
|
||||||
Node b;
|
|
||||||
Node c;
|
|
||||||
root.__left_ = &x;
|
|
||||||
x.__left_ = &a;
|
|
||||||
x.__right_ = &y;
|
|
||||||
x.__parent_ = &root;
|
|
||||||
y.__left_ = &b;
|
|
||||||
y.__right_ = &c;
|
|
||||||
y.__parent_ = &x;
|
|
||||||
a.__parent_ = &x;
|
|
||||||
b.__parent_ = &y;
|
|
||||||
c.__parent_ = &y;
|
|
||||||
std::__tree_left_rotate(&x);
|
|
||||||
assert(root.__parent_ == 0);
|
|
||||||
assert(root.__left_ == &y);
|
|
||||||
assert(root.__right_ == 0);
|
|
||||||
assert(y.__parent_ == &root);
|
|
||||||
assert(y.__left_ == &x);
|
|
||||||
assert(y.__right_ == &c);
|
|
||||||
assert(x.__parent_ == &y);
|
|
||||||
assert(x.__left_ == &a);
|
|
||||||
assert(x.__right_ == &b);
|
|
||||||
assert(a.__parent_ == &x);
|
|
||||||
assert(a.__left_ == 0);
|
|
||||||
assert(a.__right_ == 0);
|
|
||||||
assert(b.__parent_ == &x);
|
|
||||||
assert(b.__left_ == 0);
|
|
||||||
assert(b.__right_ == 0);
|
|
||||||
assert(c.__parent_ == &y);
|
|
||||||
assert(c.__left_ == 0);
|
|
||||||
assert(c.__right_ == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
test1();
|
|
||||||
test2();
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,101 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Not a portable test
|
|
||||||
|
|
||||||
// Precondition: __x->__left_ != nullptr
|
|
||||||
// template <class _NodePtr>
|
|
||||||
// void
|
|
||||||
// __tree_right_rotate(_NodePtr __x);
|
|
||||||
|
|
||||||
#include <__tree>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
struct Node
|
|
||||||
{
|
|
||||||
Node* __left_;
|
|
||||||
Node* __right_;
|
|
||||||
Node* __parent_;
|
|
||||||
|
|
||||||
Node* __parent_unsafe() const { return __parent_; }
|
|
||||||
void __set_parent(Node* x) { __parent_ = x;}
|
|
||||||
|
|
||||||
Node() : __left_(), __right_(), __parent_() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
test1()
|
|
||||||
{
|
|
||||||
Node root;
|
|
||||||
Node x;
|
|
||||||
Node y;
|
|
||||||
root.__left_ = &x;
|
|
||||||
x.__left_ = &y;
|
|
||||||
x.__right_ = 0;
|
|
||||||
x.__parent_ = &root;
|
|
||||||
y.__left_ = 0;
|
|
||||||
y.__right_ = 0;
|
|
||||||
y.__parent_ = &x;
|
|
||||||
std::__tree_right_rotate(&x);
|
|
||||||
assert(root.__parent_ == 0);
|
|
||||||
assert(root.__left_ == &y);
|
|
||||||
assert(root.__right_ == 0);
|
|
||||||
assert(y.__parent_ == &root);
|
|
||||||
assert(y.__left_ == 0);
|
|
||||||
assert(y.__right_ == &x);
|
|
||||||
assert(x.__parent_ == &y);
|
|
||||||
assert(x.__left_ == 0);
|
|
||||||
assert(x.__right_ == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test2()
|
|
||||||
{
|
|
||||||
Node root;
|
|
||||||
Node x;
|
|
||||||
Node y;
|
|
||||||
Node a;
|
|
||||||
Node b;
|
|
||||||
Node c;
|
|
||||||
root.__left_ = &x;
|
|
||||||
x.__left_ = &y;
|
|
||||||
x.__right_ = &c;
|
|
||||||
x.__parent_ = &root;
|
|
||||||
y.__left_ = &a;
|
|
||||||
y.__right_ = &b;
|
|
||||||
y.__parent_ = &x;
|
|
||||||
a.__parent_ = &y;
|
|
||||||
b.__parent_ = &y;
|
|
||||||
c.__parent_ = &x;
|
|
||||||
std::__tree_right_rotate(&x);
|
|
||||||
assert(root.__parent_ == 0);
|
|
||||||
assert(root.__left_ == &y);
|
|
||||||
assert(root.__right_ == 0);
|
|
||||||
assert(y.__parent_ == &root);
|
|
||||||
assert(y.__left_ == &a);
|
|
||||||
assert(y.__right_ == &x);
|
|
||||||
assert(x.__parent_ == &y);
|
|
||||||
assert(x.__left_ == &b);
|
|
||||||
assert(x.__right_ == &c);
|
|
||||||
assert(a.__parent_ == &y);
|
|
||||||
assert(a.__left_ == 0);
|
|
||||||
assert(a.__right_ == 0);
|
|
||||||
assert(b.__parent_ == &x);
|
|
||||||
assert(b.__left_ == 0);
|
|
||||||
assert(b.__right_ == 0);
|
|
||||||
assert(c.__parent_ == &x);
|
|
||||||
assert(c.__left_ == 0);
|
|
||||||
assert(c.__right_ == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
test1();
|
|
||||||
test2();
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
|
||||||
#pragma GCC diagnostic ignored "-W#warnings"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define min THIS IS A NASTY MACRO!
|
|
||||||
#define max THIS IS A NASTY MACRO!
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
std::map<int, int> m;
|
|
||||||
((void)m);
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <queue>
|
|
||||||
|
|
||||||
#include <queue>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <stack>
|
|
||||||
|
|
||||||
#include <stack>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,26 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Prevent emission of the deprecated warning.
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic ignored "-W#warnings"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ext/hash_map>
|
|
||||||
|
|
||||||
namespace __gnu_cxx {
|
|
||||||
template class hash_map<int, int>;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
typedef __gnu_cxx::hash_map<int, int> Map;
|
|
||||||
Map m;
|
|
||||||
Map m2(m);
|
|
||||||
((void)m2);
|
|
||||||
}
|
|
||||||
@@ -1,26 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Prevent emission of the deprecated warning.
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic ignored "-W#warnings"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ext/hash_set>
|
|
||||||
|
|
||||||
namespace __gnu_cxx {
|
|
||||||
template class hash_set<int>;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
typedef __gnu_cxx::hash_set<int> Set;
|
|
||||||
Set s;
|
|
||||||
Set s2(s);
|
|
||||||
((void)s2);
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <array>
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,32 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <deque>
|
|
||||||
|
|
||||||
// deque()
|
|
||||||
// deque::iterator()
|
|
||||||
|
|
||||||
// MODULES_DEFINES: _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
|
|
||||||
#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
|
|
||||||
#include <deque>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
struct A {
|
|
||||||
std::deque<A> d;
|
|
||||||
std::deque<A>::iterator it;
|
|
||||||
std::deque<A>::reverse_iterator it2;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
A a;
|
|
||||||
assert(a.d.size() == 0);
|
|
||||||
a.it = a.d.begin();
|
|
||||||
a.it2 = a.d.rend();
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <deque>
|
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <forward_list>
|
|
||||||
|
|
||||||
#include <forward_list>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,31 +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>
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
@@ -1,35 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,47 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,31 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,32 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,32 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,31 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,31 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,30 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
-39
@@ -1,39 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
-30
@@ -1,30 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,32 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,36 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
@@ -1,32 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// <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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +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>
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,73 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// reference operator[](size_type n);
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "asan_testing.h"
|
|
||||||
#include "min_allocator.h"
|
|
||||||
#include "test_iterators.h"
|
|
||||||
#include "test_macros.h"
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_ASAN
|
|
||||||
extern "C" void __sanitizer_set_death_callback(void (*callback)(void));
|
|
||||||
|
|
||||||
void do_exit() {
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
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());
|
|
||||||
volatile T foo = c[c.size()]; // bad, but not caught by ASAN
|
|
||||||
((void)foo);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
|
||||||
typedef input_iterator<int*> MyInputIter;
|
|
||||||
// Sould not trigger ASan.
|
|
||||||
std::vector<int> v;
|
|
||||||
v.reserve(1);
|
|
||||||
int i[] = {42};
|
|
||||||
v.insert(v.begin(), MyInputIter(i), MyInputIter(i + 1));
|
|
||||||
assert(v[0] == 42);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
__sanitizer_set_death_callback(do_exit);
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
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());
|
|
||||||
assert(is_contiguous_container_asan_correct(c));
|
|
||||||
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
|
|
||||||
int main () { return 0; }
|
|
||||||
#endif
|
|
||||||
@@ -1,234 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: libcpp-no-exceptions
|
|
||||||
// Test asan vector annotations with a class that throws in a CTOR.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#include "test_macros.h"
|
|
||||||
#include "asan_testing.h"
|
|
||||||
|
|
||||||
class X {
|
|
||||||
public:
|
|
||||||
X(const X &x) { Init(x.a); }
|
|
||||||
X(char arg) { Init(arg); }
|
|
||||||
X() { Init(42); }
|
|
||||||
X &operator=(const X &x) {
|
|
||||||
Init(x.a);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
void Init(char arg) {
|
|
||||||
if (arg == 42)
|
|
||||||
throw 0;
|
|
||||||
if (arg == 66)
|
|
||||||
arg = 42;
|
|
||||||
a = arg;
|
|
||||||
}
|
|
||||||
char get() const { return a; }
|
|
||||||
void set(char arg) { a = arg; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
char a;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ThrowOnCopy {
|
|
||||||
public:
|
|
||||||
ThrowOnCopy() : should_throw(false) {}
|
|
||||||
explicit ThrowOnCopy(bool xshould_throw) : should_throw(xshould_throw) {}
|
|
||||||
|
|
||||||
ThrowOnCopy(ThrowOnCopy const & other)
|
|
||||||
: should_throw(other.should_throw)
|
|
||||||
{
|
|
||||||
if (should_throw) {
|
|
||||||
throw 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool should_throw;
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_push_back() {
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(2);
|
|
||||||
v.push_back(X(2));
|
|
||||||
assert(v.size() == 1);
|
|
||||||
try {
|
|
||||||
v.push_back(X(66));
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 1);
|
|
||||||
}
|
|
||||||
assert(v.size() == 1);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_emplace_back() {
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(2);
|
|
||||||
v.push_back(X(2));
|
|
||||||
assert(v.size() == 1);
|
|
||||||
try {
|
|
||||||
v.emplace_back(42);
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 1);
|
|
||||||
}
|
|
||||||
assert(v.size() == 1);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_insert_range() {
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(4);
|
|
||||||
v.push_back(X(1));
|
|
||||||
v.push_back(X(2));
|
|
||||||
assert(v.size() == 2);
|
|
||||||
assert(v.capacity() >= 4);
|
|
||||||
try {
|
|
||||||
char a[2] = {21, 42};
|
|
||||||
v.insert(v.end(), a, a + 2);
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 3);
|
|
||||||
}
|
|
||||||
assert(v.size() == 3);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_insert() {
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(3);
|
|
||||||
v.insert(v.end(), X(1));
|
|
||||||
v.insert(v.begin(), X(2));
|
|
||||||
assert(v.size() == 2);
|
|
||||||
try {
|
|
||||||
v.insert(v.end(), X(66));
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 2);
|
|
||||||
}
|
|
||||||
assert(v.size() == 2);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_emplace() {
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(3);
|
|
||||||
v.insert(v.end(), X(1));
|
|
||||||
v.insert(v.begin(), X(2));
|
|
||||||
assert(v.size() == 2);
|
|
||||||
try {
|
|
||||||
v.emplace(v.end(), 42);
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 2);
|
|
||||||
}
|
|
||||||
assert(v.size() == 2);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_insert_range2() {
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(4);
|
|
||||||
v.insert(v.end(), X(1));
|
|
||||||
v.insert(v.begin(), X(2));
|
|
||||||
assert(v.size() == 2);
|
|
||||||
assert(v.capacity() >= 4);
|
|
||||||
try {
|
|
||||||
char a[2] = {10, 42};
|
|
||||||
v.insert(v.begin(), a, a + 2);
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() <= 4);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_insert_n() {
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(10);
|
|
||||||
v.insert(v.end(), X(1));
|
|
||||||
v.insert(v.begin(), X(2));
|
|
||||||
assert(v.size() == 2);
|
|
||||||
try {
|
|
||||||
v.insert(v.begin(), 1, X(66));
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() <= 3);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void test_insert_n2() {
|
|
||||||
std::vector<ThrowOnCopy> v(10);
|
|
||||||
v.reserve(100);
|
|
||||||
assert(v.size() == 10);
|
|
||||||
v[6].should_throw = true;
|
|
||||||
try {
|
|
||||||
v.insert(v.cbegin(), 5, ThrowOnCopy());
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 11);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_resize() {
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(3);
|
|
||||||
v.push_back(X(0));
|
|
||||||
try {
|
|
||||||
v.resize(3);
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 1);
|
|
||||||
}
|
|
||||||
assert(v.size() == 1);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_resize_param() {
|
|
||||||
std::vector<X> v;
|
|
||||||
v.reserve(3);
|
|
||||||
v.push_back(X(0));
|
|
||||||
try {
|
|
||||||
v.resize(3, X(66));
|
|
||||||
assert(0);
|
|
||||||
} catch (int e) {
|
|
||||||
assert(v.size() == 1);
|
|
||||||
}
|
|
||||||
assert(v.size() == 1);
|
|
||||||
assert(is_contiguous_container_asan_correct(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
test_push_back();
|
|
||||||
test_emplace_back();
|
|
||||||
test_insert_range();
|
|
||||||
test_insert();
|
|
||||||
test_emplace();
|
|
||||||
test_insert_range2();
|
|
||||||
test_insert_n();
|
|
||||||
test_insert_n2();
|
|
||||||
test_resize();
|
|
||||||
test_resize_param();
|
|
||||||
}
|
|
||||||
@@ -1,22 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// vector<const int> v; // an extension
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::vector<const int> v = {1, 2, 3};
|
|
||||||
}
|
|
||||||
@@ -1,56 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call back() on empty container.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c.back() == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c.back() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c.back() == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c.back() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,52 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call back() on empty const container.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
const C c;
|
|
||||||
assert(c.back() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
const C c;
|
|
||||||
assert(c.back() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,52 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call front() on empty const container.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
const C c;
|
|
||||||
assert(c.front() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
const C c;
|
|
||||||
assert(c.front() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,54 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Index const vector out of bounds.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
const C c(1);
|
|
||||||
assert(c[0] == 0);
|
|
||||||
assert(c[1] == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
const C c(1);
|
|
||||||
assert(c[0] == 0);
|
|
||||||
assert(c[1] == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,56 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call front() on empty container.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c.front() == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c.front() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c.front() == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c.front() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,56 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Index vector out of bounds.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c[0] == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c[0] == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c[0] == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c[0] == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,54 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Compare iterators from different containers with <.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c1;
|
|
||||||
C c2;
|
|
||||||
bool b = c1.begin() < c2.begin();
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c1;
|
|
||||||
C c2;
|
|
||||||
bool b = c1.begin() < c2.begin();
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,54 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Subtract iterators from different containers.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c1;
|
|
||||||
C c2;
|
|
||||||
int i = c1.begin() - c2.begin();
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c1;
|
|
||||||
C c2;
|
|
||||||
int i = c1.begin() - c2.begin();
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,56 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Index iterator out of bounds.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
assert(i[0] == 0);
|
|
||||||
assert(i[1] == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
assert(i[0] == 0);
|
|
||||||
assert(i[1] == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,60 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Add to iterator out of bounds.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
i += 1;
|
|
||||||
assert(i == c.end());
|
|
||||||
i = c.begin();
|
|
||||||
i += 2;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
i += 1;
|
|
||||||
assert(i == c.end());
|
|
||||||
i = c.begin();
|
|
||||||
i += 2;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,58 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Decrement iterator prior to begin.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.end();
|
|
||||||
--i;
|
|
||||||
assert(i == c.begin());
|
|
||||||
--i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.end();
|
|
||||||
--i;
|
|
||||||
assert(i == c.begin());
|
|
||||||
--i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,58 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Increment iterator past end.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
++i;
|
|
||||||
assert(i == c.end());
|
|
||||||
++i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
++i;
|
|
||||||
assert(i == c.end());
|
|
||||||
++i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,54 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Dereference non-dereferenceable iterator.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.end();
|
|
||||||
T j = *i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::vector<T, min_allocator<T>> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.end();
|
|
||||||
T j = *i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#include <__hash_table>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
#include "test_macros.h"
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
void testKeyValueTrait() {
|
|
||||||
{
|
|
||||||
typedef int Tp;
|
|
||||||
typedef std::__hash_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, int>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
|
|
||||||
static_assert(Traits::__is_map == false, "");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
typedef std::pair<int, int> Tp;
|
|
||||||
typedef std::__hash_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
|
|
||||||
static_assert(Traits::__is_map == false, "");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
typedef std::pair<const int, int> Tp;
|
|
||||||
typedef std::__hash_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type, Tp>::value), "");
|
|
||||||
static_assert(Traits::__is_map == false, "");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
typedef std::__hash_value_type<int, int> Tp;
|
|
||||||
typedef std::__hash_key_value_types<Tp> Traits;
|
|
||||||
static_assert((std::is_same<Traits::key_type, int>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::mapped_type, int>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__node_value_type, Tp>::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__container_value_type,
|
|
||||||
std::pair<const int, int> >::value), "");
|
|
||||||
static_assert((std::is_same<Traits::__map_value_type,
|
|
||||||
std::pair<const int, int> >::value), "");
|
|
||||||
static_assert(Traits::__is_map == true, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
testKeyValueTrait();
|
|
||||||
}
|
|
||||||
@@ -1,88 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// REQUIRES: long_tests
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// Not a portable test
|
|
||||||
|
|
||||||
// <__hash_table>
|
|
||||||
|
|
||||||
// size_t __next_hash_pow2(size_t n);
|
|
||||||
|
|
||||||
// If n <= 1, return n. If n is a power of 2, return n.
|
|
||||||
// Otherwise, return the next power of 2.
|
|
||||||
|
|
||||||
#include <__hash_table>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
bool
|
|
||||||
is_power_of_two(unsigned long n)
|
|
||||||
{
|
|
||||||
return __builtin_popcount(n) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_next_pow2_val(size_t n)
|
|
||||||
{
|
|
||||||
std::size_t npow2 = std::__next_hash_pow2(n);
|
|
||||||
assert(is_power_of_two(npow2) && npow2 > n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
test_next_pow2()
|
|
||||||
{
|
|
||||||
assert(!is_power_of_two(0));
|
|
||||||
assert(is_power_of_two(1));
|
|
||||||
assert(is_power_of_two(2));
|
|
||||||
assert(!is_power_of_two(3));
|
|
||||||
|
|
||||||
assert(std::__next_hash_pow2(0) == 0);
|
|
||||||
assert(std::__next_hash_pow2(1) == 1);
|
|
||||||
|
|
||||||
for (std::size_t n = 2; n < (sizeof(std::size_t) * 8 - 1); ++n)
|
|
||||||
{
|
|
||||||
std::size_t pow2 = 1ULL << n;
|
|
||||||
assert(std::__next_hash_pow2(pow2) == pow2);
|
|
||||||
}
|
|
||||||
|
|
||||||
test_next_pow2_val(3);
|
|
||||||
test_next_pow2_val(7);
|
|
||||||
test_next_pow2_val(9);
|
|
||||||
test_next_pow2_val(15);
|
|
||||||
test_next_pow2_val(127);
|
|
||||||
test_next_pow2_val(129);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: this is only really useful when run with -fsanitize=undefined.
|
|
||||||
void
|
|
||||||
fuzz_unordered_map_reserve(unsigned num_inserts,
|
|
||||||
unsigned num_reserve1,
|
|
||||||
unsigned num_reserve2)
|
|
||||||
{
|
|
||||||
std::unordered_map<uint64_t, unsigned long> m;
|
|
||||||
m.reserve(num_reserve1);
|
|
||||||
for (unsigned I = 0; I < num_inserts; ++I) m[I] = 0;
|
|
||||||
m.reserve(num_reserve2);
|
|
||||||
assert(m.bucket_count() >= num_reserve2);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
test_next_pow2();
|
|
||||||
|
|
||||||
for (unsigned num_inserts = 0; num_inserts <= 64; ++num_inserts)
|
|
||||||
for (unsigned num_reserve1 = 1; num_reserve1 <= 64; ++num_reserve1)
|
|
||||||
for (unsigned num_reserve2 = 1; num_reserve2 <= 64; ++num_reserve2)
|
|
||||||
fuzz_unordered_map_reserve(num_inserts, num_reserve1, num_reserve2);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,51 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// REQUIRES: long_tests
|
|
||||||
|
|
||||||
// Not a portable test
|
|
||||||
|
|
||||||
// <__hash_table>
|
|
||||||
|
|
||||||
// size_t __next_prime(size_t n);
|
|
||||||
|
|
||||||
// If n == 0, return 0, else return the lowest prime greater than or equal to n
|
|
||||||
|
|
||||||
#include <__hash_table>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
bool
|
|
||||||
is_prime(size_t n)
|
|
||||||
{
|
|
||||||
switch (n)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (size_t i = 2; i*i <= n; ++i)
|
|
||||||
{
|
|
||||||
if (n % i == 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
assert(std::__next_prime(0) == 0);
|
|
||||||
for (std::size_t n = 1; n <= 100000; ++n)
|
|
||||||
{
|
|
||||||
std::size_t p = std::__next_prime(n);
|
|
||||||
assert(p >= n);
|
|
||||||
for (std::size_t i = n; i < p; ++i)
|
|
||||||
assert(!is_prime(i));
|
|
||||||
assert(is_prime(p));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// Increment iterator past end.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <string>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string> C;
|
|
||||||
C c;
|
|
||||||
c.insert(std::make_pair(1, "one"));
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
++i;
|
|
||||||
assert(i == c.end());
|
|
||||||
++i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
|
||||||
min_allocator<std::pair<const int, std::string>>> C;
|
|
||||||
C c;
|
|
||||||
c.insert(std::make_pair(1, "one"));
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
++i;
|
|
||||||
assert(i == c.end());
|
|
||||||
++i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,56 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// Dereference non-dereferenceable iterator.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <string>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string> C;
|
|
||||||
C c;
|
|
||||||
c.insert(std::make_pair(1, "one"));
|
|
||||||
C::iterator i = c.end();
|
|
||||||
C::value_type j = *i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
|
||||||
min_allocator<std::pair<const int, std::string>>> C;
|
|
||||||
C c;
|
|
||||||
c.insert(std::make_pair(1, "one"));
|
|
||||||
C::iterator i = c.end();
|
|
||||||
C::value_type j = *i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,57 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// Increment local_iterator past end.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <string>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string> C;
|
|
||||||
C c(1);
|
|
||||||
C::local_iterator i = c.begin(0);
|
|
||||||
++i;
|
|
||||||
++i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
|
||||||
min_allocator<std::pair<const int, std::string>>> C;
|
|
||||||
C c(1);
|
|
||||||
C::local_iterator i = c.begin(0);
|
|
||||||
++i;
|
|
||||||
++i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,54 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
// Dereference non-dereferenceable iterator.
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <string>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string> C;
|
|
||||||
C c(1);
|
|
||||||
C::local_iterator i = c.end(0);
|
|
||||||
C::value_type j = *i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
{
|
|
||||||
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
|
|
||||||
min_allocator<std::pair<const int, std::string>>> C;
|
|
||||||
C c(1);
|
|
||||||
C::local_iterator i = c.end(0);
|
|
||||||
C::value_type j = *i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_map>
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,70 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// REQUIRES: diagnose-if-support
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
|
|
||||||
// Libc++ only provides a defined primary template for std::hash in C++14 and
|
|
||||||
// newer.
|
|
||||||
// UNSUPPORTED: c++11
|
|
||||||
|
|
||||||
// <unordered_set>
|
|
||||||
|
|
||||||
// Test that we generate a reasonable diagnostic when the specified hash is
|
|
||||||
// not enabled.
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
using VT = std::pair<int, int>;
|
|
||||||
|
|
||||||
struct BadHashNoCopy {
|
|
||||||
BadHashNoCopy() = default;
|
|
||||||
BadHashNoCopy(BadHashNoCopy const&) = delete;
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
size_t operator()(T const&) const { return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BadHashNoCall {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct GoodHashNoDefault {
|
|
||||||
explicit GoodHashNoDefault(void*) {}
|
|
||||||
template <class T>
|
|
||||||
size_t operator()(T const&) const { return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
{
|
|
||||||
using Set = std::unordered_set<VT>;
|
|
||||||
Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}}
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME: It would be great to suppress the below diagnostic all together.
|
|
||||||
// but for now it's sufficient that it appears last. However there is
|
|
||||||
// currently no way to test the order diagnostics are issued.
|
|
||||||
// expected-error@memory:* {{call to implicitly-deleted default constructor of '__compressed_pair_elem}}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
using Set = std::unordered_set<int, BadHashNoCopy>;
|
|
||||||
Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
using Set = std::unordered_set<int, BadHashNoCall>;
|
|
||||||
Set s; // expected-error@__hash_table:* {{the specified hash does not meet the Hash requirements}}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
using Set = std::unordered_set<int, GoodHashNoDefault>;
|
|
||||||
Set s(/*bucketcount*/42, GoodHashNoDefault(nullptr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <unordered_set>
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
#ifndef _LIBCPP_VERSION
|
|
||||||
#error _LIBCPP_VERSION not defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,70 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
|
||||||
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
|
|
||||||
// MODULES_DEFINES: _LIBCPP_DEBUG=1
|
|
||||||
// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,270 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
|
||||||
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
|
|
||||||
// MODULES_DEFINES: _LIBCPP_DEBUG=1
|
|
||||||
// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,100 +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.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
|
||||||
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
|
|
||||||
// MODULES_DEFINES: _LIBCPP_DEBUG=1
|
|
||||||
// MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
|
|
||||||
|
|
||||||
// Can't test the system lib because this test enables debug mode
|
|
||||||
// UNSUPPORTED: with_system_cxx_lib
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user