summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/base/attributes.h1
-rw-r--r--absl/base/internal/throw_delegate.cc118
-rw-r--r--absl/flags/CMakeLists.txt1
-rw-r--r--absl/status/CMakeLists.txt1
-rw-r--r--absl/strings/internal/str_format/bind.h9
-rwxr-xr-xci/linux_gcc-latest_libstdcxx_cmake.sh47
-rwxr-xr-xci/linux_gcc_alpine_cmake.sh46
-rwxr-xr-xci/macos_xcode_cmake.sh30
8 files changed, 189 insertions, 64 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 046fbea3..f1d3cfe4 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -607,6 +607,7 @@
// When used with unsupported compilers, the ABSL_FALLTHROUGH_INTENDED macro
// has no effect on diagnostics. In any case this macro has no effect on runtime
// behavior and performance of code.
+
#ifdef ABSL_FALLTHROUGH_INTENDED
#error "ABSL_FALLTHROUGH_INTENDED should not be defined."
#endif
diff --git a/absl/base/internal/throw_delegate.cc b/absl/base/internal/throw_delegate.cc
index c055f75d..c260ff1e 100644
--- a/absl/base/internal/throw_delegate.cc
+++ b/absl/base/internal/throw_delegate.cc
@@ -18,6 +18,7 @@
#include <functional>
#include <new>
#include <stdexcept>
+
#include "absl/base/config.h"
#include "absl/base/internal/raw_logging.h"
@@ -25,83 +26,186 @@ namespace absl {
ABSL_NAMESPACE_BEGIN
namespace base_internal {
+// NOTE: The various STL exception throwing functions are placed within the
+// #ifdef blocks so the symbols aren't exposed on platforms that don't support
+// them, such as the Android NDK. For example, ANGLE fails to link when building
+// within AOSP without them, since the STL functions don't exist.
namespace {
+#ifdef ABSL_HAVE_EXCEPTIONS
template <typename T>
[[noreturn]] void Throw(const T& error) {
-#ifdef ABSL_HAVE_EXCEPTIONS
throw error;
-#else
- ABSL_RAW_LOG(FATAL, "%s", error.what());
- std::abort();
-#endif
}
+#endif
} // namespace
void ThrowStdLogicError(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::logic_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdLogicError(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::logic_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdInvalidArgument(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::invalid_argument(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdInvalidArgument(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::invalid_argument(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdDomainError(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::domain_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdDomainError(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::domain_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdLengthError(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::length_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdLengthError(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::length_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdOutOfRange(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::out_of_range(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdOutOfRange(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::out_of_range(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdRuntimeError(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::runtime_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdRuntimeError(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::runtime_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdRangeError(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::range_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdRangeError(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::range_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdOverflowError(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::overflow_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdOverflowError(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::overflow_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
void ThrowStdUnderflowError(const std::string& what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::underflow_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
+ std::abort();
+#endif
}
void ThrowStdUnderflowError(const char* what_arg) {
+#ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::underflow_error(what_arg));
+#else
+ ABSL_RAW_LOG(FATAL, "%s", what_arg);
+ std::abort();
+#endif
}
-void ThrowStdBadFunctionCall() { Throw(std::bad_function_call()); }
+void ThrowStdBadFunctionCall() {
+#ifdef ABSL_HAVE_EXCEPTIONS
+ Throw(std::bad_function_call());
+#else
+ std::abort();
+#endif
+}
-void ThrowStdBadAlloc() { Throw(std::bad_alloc()); }
+void ThrowStdBadAlloc() {
+#ifdef ABSL_HAVE_EXCEPTIONS
+ Throw(std::bad_alloc());
+#else
+ std::abort();
+#endif
+}
} // namespace base_internal
ABSL_NAMESPACE_END
diff --git a/absl/flags/CMakeLists.txt b/absl/flags/CMakeLists.txt
index 28bd5a85..88551914 100644
--- a/absl/flags/CMakeLists.txt
+++ b/absl/flags/CMakeLists.txt
@@ -183,6 +183,7 @@ absl_cc_library(
DEPS
absl::base
absl::config
+ absl::flags_commandlineflag
absl::flags_commandlineflag_internal
absl::flags_config
absl::flags_marshalling
diff --git a/absl/status/CMakeLists.txt b/absl/status/CMakeLists.txt
index 66728551..f0d798a3 100644
--- a/absl/status/CMakeLists.txt
+++ b/absl/status/CMakeLists.txt
@@ -64,6 +64,7 @@ absl_cc_library(
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
+ absl::status
absl::core_headers
absl::raw_logging_internal
absl::type_traits
diff --git a/absl/strings/internal/str_format/bind.h b/absl/strings/internal/str_format/bind.h
index 727b2115..267cc0ef 100644
--- a/absl/strings/internal/str_format/bind.h
+++ b/absl/strings/internal/str_format/bind.h
@@ -133,10 +133,11 @@ class FormatSpecTemplate
#endif // ABSL_INTERNAL_ENABLE_FORMAT_CHECKER
- template <FormatConversionCharSet... C,
- typename = typename std::enable_if<
- AllOf(sizeof...(C) == sizeof...(Args), Contains(Args,
- C)...)>::type>
+ template <
+ FormatConversionCharSet... C,
+ typename = typename std::enable_if<sizeof...(C) == sizeof...(Args)>::type,
+ typename = typename std::enable_if<AllOf(Contains(Args,
+ C)...)>::type>
FormatSpecTemplate(const ExtendedParsedFormat<C...>& pc) // NOLINT
: Base(&pc) {}
};
diff --git a/ci/linux_gcc-latest_libstdcxx_cmake.sh b/ci/linux_gcc-latest_libstdcxx_cmake.sh
index 1ba02b26..26415e23 100755
--- a/ci/linux_gcc-latest_libstdcxx_cmake.sh
+++ b/ci/linux_gcc-latest_libstdcxx_cmake.sh
@@ -34,31 +34,36 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
ABSL_CMAKE_BUILD_TYPES="Debug Release"
fi
+if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
+ ABSL_CMAKE_BUILD_SHARED="OFF ON"
+fi
+
source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
readonly DOCKER_CONTAINER=${LINUX_GCC_LATEST_CONTAINER}
for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
- echo "--------------------------------------------------------------------"
- echo "Testing with CMAKE_BUILD_TYPE=${compilation_mode} and -std=c++${std}"
-
- time docker run \
- --volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
- --workdir=/abseil-cpp \
- --tmpfs=/buildfs:exec \
- --cap-add=SYS_PTRACE \
- --rm \
- -e CFLAGS="-Werror" \
- -e CXXFLAGS="-Werror" \
- ${DOCKER_CONTAINER} \
- /bin/bash -c "
- cd /buildfs && \
- cmake /abseil-cpp \
- -DABSL_USE_GOOGLETEST_HEAD=ON \
- -DABSL_RUN_TESTS=ON \
- -DCMAKE_BUILD_TYPE=${compilation_mode} \
- -DCMAKE_CXX_STANDARD=${std} && \
- make -j$(nproc) && \
- ctest -j$(nproc) --output-on-failure"
+ for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
+ time docker run \
+ --volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
+ --workdir=/abseil-cpp \
+ --tmpfs=/buildfs:exec \
+ --cap-add=SYS_PTRACE \
+ --rm \
+ -e CFLAGS="-Werror" \
+ -e CXXFLAGS="-Werror" \
+ ${DOCKER_CONTAINER} \
+ /bin/bash -c "
+ cd /buildfs && \
+ cmake /abseil-cpp \
+ -DABSL_USE_GOOGLETEST_HEAD=ON \
+ -DABSL_RUN_TESTS=ON \
+ -DBUILD_SHARED_LIBS=${build_shared} \
+ -DCMAKE_BUILD_TYPE=${compilation_mode} \
+ -DCMAKE_CXX_STANDARD=${std} \
+ -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \
+ make -j$(nproc) && \
+ ctest -j$(nproc) --output-on-failure"
+ done
done
done
diff --git a/ci/linux_gcc_alpine_cmake.sh b/ci/linux_gcc_alpine_cmake.sh
index f57ab12b..b3b8e7a7 100755
--- a/ci/linux_gcc_alpine_cmake.sh
+++ b/ci/linux_gcc_alpine_cmake.sh
@@ -34,31 +34,35 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
ABSL_CMAKE_BUILD_TYPES="Debug Release"
fi
+if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
+ ABSL_CMAKE_BUILD_SHARED="OFF ON"
+fi
+
source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
readonly DOCKER_CONTAINER=${LINUX_ALPINE_CONTAINER}
for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
- echo "--------------------------------------------------------------------"
- echo "Testing with CMAKE_BUILD_TYPE=${compilation_mode} and -std=c++${std}"
-
- time docker run \
- --volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
- --workdir=/abseil-cpp \
- --tmpfs=/buildfs:exec \
- --cap-add=SYS_PTRACE \
- --rm \
- -e CFLAGS="-Werror" \
- -e CXXFLAGS="-Werror" \
- "${DOCKER_CONTAINER}" \
- /bin/sh -c "
- cd /buildfs && \
- cmake /abseil-cpp \
- -DABSL_USE_GOOGLETEST_HEAD=ON \
- -DABSL_RUN_TESTS=ON \
- -DCMAKE_BUILD_TYPE=${compilation_mode} \
- -DCMAKE_CXX_STANDARD=${std} && \
- make -j$(nproc) && \
- ctest -j$(nproc) --output-on-failure"
+ for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
+ time docker run \
+ --volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
+ --workdir=/abseil-cpp \
+ --tmpfs=/buildfs:exec \
+ --cap-add=SYS_PTRACE \
+ --rm \
+ -e CFLAGS="-Werror" \
+ -e CXXFLAGS="-Werror" \
+ "${DOCKER_CONTAINER}" \
+ /bin/sh -c "
+ cd /buildfs && \
+ cmake /abseil-cpp \
+ -DABSL_USE_GOOGLETEST_HEAD=ON \
+ -DABSL_RUN_TESTS=ON \
+ -DCMAKE_BUILD_TYPE=${compilation_mode} \
+ -DCMAKE_CXX_STANDARD=${std} \
+ -DCMAKE_MODULE_LINKER_FLAGS=\"-Wl,--no-undefined\" && \
+ make -j$(nproc) && \
+ ctest -j$(nproc) --output-on-failure"
+ done
done
done
diff --git a/ci/macos_xcode_cmake.sh b/ci/macos_xcode_cmake.sh
index cf78e207..d90e273a 100755
--- a/ci/macos_xcode_cmake.sh
+++ b/ci/macos_xcode_cmake.sh
@@ -28,17 +28,25 @@ if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
ABSL_CMAKE_BUILD_TYPES="Debug"
fi
+if [[ -z ${ABSL_CMAKE_BUILD_SHARED:-} ]]; then
+ ABSL_CMAKE_BUILD_SHARED="OFF ON"
+fi
+
for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
- BUILD_DIR=$(mktemp -d ${compilation_mode}.XXXXXXXX)
- cd ${BUILD_DIR}
+ for build_shared in ${ABSL_CMAKE_BUILD_SHARED}; do
+ BUILD_DIR=$(mktemp -d ${compilation_mode}.XXXXXXXX)
+ cd ${BUILD_DIR}
- # TODO(absl-team): Enable -Werror once all warnings are fixed.
- time cmake ${ABSEIL_ROOT} \
- -GXcode \
- -DCMAKE_BUILD_TYPE=${compilation_mode} \
- -DCMAKE_CXX_STANDARD=11 \
- -DABSL_USE_GOOGLETEST_HEAD=ON \
- -DABSL_RUN_TESTS=ON
- time cmake --build .
- time ctest -C ${compilation_mode} --output-on-failure
+ # TODO(absl-team): Enable -Werror once all warnings are fixed.
+ time cmake ${ABSEIL_ROOT} \
+ -GXcode \
+ -DBUILD_SHARED_LIBS=${build_shared} \
+ -DCMAKE_BUILD_TYPE=${compilation_mode} \
+ -DCMAKE_CXX_STANDARD=11 \
+ -DCMAKE_MODULE_LINKER_FLAGS="-Wl,--no-undefined" \
+ -DABSL_USE_GOOGLETEST_HEAD=ON \
+ -DABSL_RUN_TESTS=ON
+ time cmake --build .
+ time ctest -C ${compilation_mode} --output-on-failure
+ done
done