Export of internal Abseil changes.

--
22fa219d17b2281c0695642830c4300711bd65ea by CJ Johnson <johnsoncj@google.com>:

Rearrange the private method declarations in InlinedVector

PiperOrigin-RevId: 224202447

--
eed3c9f488f23b521bee41d3683eb6cc22517ded by Derek Mauro <dmauro@google.com>:

Fix leak_check target (it was always a no-op when LSAN isn't available).
Fixes https://github.com/abseil/abseil-cpp/issues/232

PiperOrigin-RevId: 224201634

--
fc08039e175204b14a9561f618fcfc0234586801 by Greg Falcon <gfalcon@google.com>:

Add parens around more invocations of min() and max() missed in my prior CL.

PiperOrigin-RevId: 224162430

--
0ec5476a8293c7796cd84928a1a558b14f14f222 by Abseil Team <absl-team@google.com>:

Update absl/numeric/CMakeLists.txt to use new functions
i.e. absl_cc_(library|test)

PiperOrigin-RevId: 224139165

--
2b46aa6fabb20c589661f8bbc84030ecf39ce394 by Abseil Team <absl-team@google.com>:

Update absl/meta/CMakeLists.txt to use new functions
i.e. absl_cc_(library|test)

PiperOrigin-RevId: 224117258

--
6c951c798f8c6903bd8793a8a4b5f69244be8aa9 by Abseil Team <absl-team@google.com>:

Fix 2 Unused C++ BUILD Dependencies

PiperOrigin-RevId: 224070093

--
0ee7bd191708708f91fc5209c197fd93f6e4a8b3 by Greg Falcon <gfalcon@google.com>:

Inside Abseil headers, wrap most invocations of methods and functions named `min` and `max` in parentheses, for better interoperability with Windows toolchains.

CCTZ fixes will appear in a follow-up CL.

PiperOrigin-RevId: 224051960

--
f562f56577b84a8bc07e5873775c01d068531bca by Jon Cohen <cohenjon@google.com>:

Generate Abseil compile options.  The single source of truth is now absl/copts/copts.py

The way this works goes something like this:
copts.py acts as the configuration file.  We use python because unlike JSON it allows comments.  It has two maps in it: one from names to external flags, and one from names to internal flags.

generate_copts.py imports the maps and loops through them to write GENERATED_copts.bzl and GENERATED_AbseilCopts.cmake

AbseilConfigureCopts.cmake and configure_copts.bzl import their respective copts args and set the platform-appropriate copts into ABSL_DEFAULT_COPTS, ABSL_TEST_COPTS, ABSL_EXCEPTIONS_FLAG, and ABSL_EXCEPTIONS_LINKOPTS

For Bazel, each BUILD file load()s configure_copts.bzl

For CMake, AbseilHelpers.cmake include()s AbseilConfigureCopts.cmake to get the final copts and both inserts them as needed into legacy target rules and also makes them available to the rest of our CMakeLists.txt file.  We may instead want to include() AbseilConfigureCopts.cmake directly into each CMakeLists.txt file for consistency, but I'm not sure what the deal is with cmake and include guards, or if they are even needed.  That's also not as idiomatic -- CMake tends to use directory scope where globals set at a higher level CMakeLists.txt file are used in the subdirectory CMakeLists.txt files.

PiperOrigin-RevId: 224039419

--
f7402f6bb65037e668a7355f0a003f5c05a3b6a7 by Abseil Team <absl-team@google.com>:

Import of CCTZ from GitHub.

PiperOrigin-RevId: 224036622
GitOrigin-RevId: 22fa219d17b2281c0695642830c4300711bd65ea
Change-Id: I6b505360539ff2aef8aa30c51a5f7d55db1c75cf
This commit is contained in:
Abseil Team 2018-12-05 12:37:41 -08:00 committed by CJ Johnson
parent 44b0fafc62
commit 284378a71b
36 changed files with 751 additions and 509 deletions

2
.gitignore vendored
View file

@ -10,3 +10,5 @@ build
CMakeLists.txt.user
# Ignore VS Code files
.vscode/*
# Ignore generated .pyc binaries
copts/copts.pyc

View file

@ -1,145 +0,0 @@
# Abseil-specific compiler flags. See absl/copts.bzl for description.
# DO NOT CHANGE THIS FILE WITHOUT THE CORRESPONDING CHANGE TO absl/copts.bzl
list(APPEND GCC_FLAGS
-Wall
-Wextra
-Wcast-qual
-Wconversion-null
-Wmissing-declarations
-Woverlength-strings
-Wpointer-arith
-Wunused-local-typedefs
-Wunused-result
-Wvarargs
-Wwrite-strings
-Wno-sign-compare
)
list(APPEND GCC_TEST_FLAGS
-Wno-conversion-null
-Wno-missing-declarations
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-parameter
-Wno-unused-private-field
)
list(APPEND LLVM_FLAGS
-Wall
-Wextra
-Weverything
-Wno-c++98-compat-pedantic
-Wno-conversion
-Wno-covered-switch-default
-Wno-deprecated
-Wno-disabled-macro-expansion
-Wno-double-promotion
-Wno-comma
-Wno-extra-semi
-Wno-packed
-Wno-padded
-Wno-sign-compare
-Wno-float-conversion
-Wno-float-equal
-Wno-format-nonliteral
-Wno-gcc-compat
-Wno-global-constructors
-Wno-exit-time-destructors
-Wno-nested-anon-types
-Wno-non-modular-include-in-module
-Wno-old-style-cast
-Wno-range-loop-analysis
-Wno-reserved-id-macro
-Wno-shorten-64-to-32
-Wno-switch-enum
-Wno-thread-safety-negative
-Wno-undef
-Wno-unknown-warning-option
-Wno-unreachable-code
-Wno-unused-macros
-Wno-weak-vtables
-Wbitfield-enum-conversion
-Wbool-conversion
-Wconstant-conversion
-Wenum-conversion
-Wint-conversion
-Wliteral-conversion
-Wnon-literal-null-conversion
-Wnull-conversion
-Wobjc-literal-conversion
-Wno-sign-conversion
-Wstring-conversion
)
list(APPEND LLVM_TEST_FLAGS
-Wno-c99-extensions
-Wno-missing-noreturn
-Wno-missing-prototypes
-Wno-missing-variable-declarations
-Wno-null-conversion
-Wno-shadow
-Wno-shift-sign-overflow
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-member-function
-Wno-unused-parameter
-Wno-unused-private-field
-Wno-unused-template
-Wno-used-but-marked-unused
-Wno-zero-as-null-pointer-constant
-Wno-gnu-zero-variadic-macro-arguments
)
list(APPEND MSVC_FLAGS
/W3
/wd4005
/wd4018
/wd4068
/wd4180
/wd4244
/wd4267
/wd4800
/DNOMINMAX
/DWIN32_LEAN_AND_MEAN
/D_CRT_SECURE_NO_WARNINGS
/D_SCL_SECURE_NO_WARNINGS
/D_ENABLE_EXTENDED_ALIGNED_STORAGE
)
list(APPEND MSVC_TEST_FLAGS
/wd4101
/wd4503
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(ABSL_DEFAULT_COPTS "${GCC_FLAGS}")
set(ABSL_TEST_COPTS "${GCC_FLAGS};${GCC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "-fexceptions")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# MATCHES so we get both Clang and AppleClang
set(ABSL_DEFAULT_COPTS "${LLVM_FLAGS}")
set(ABSL_TEST_COPTS "${LLVM_FLAGS};${LLVM_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "-fexceptions")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(ABSL_DEFAULT_COPTS "${MSVC_FLAGS}")
set(ABSL_TEST_COPTS "${MSVC_FLAGS};${MSVC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "/U_HAS_EXCEPTIONS;/D_HAS_EXCEPTIONS=1;/EHsc")
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}. Building with no default flags")
set(ABSL_DEFAULT_COPTS "")
set(ABSL_TEST_COPTS "")
set(ABSL_EXCEPTIONS_FLAG "")
endif()
# This flag is used internally for Bazel builds and is kept here for consistency
set(ABSL_EXCEPTIONS_FLAG_LINKOPTS "")
if("${CMAKE_CXX_STANDARD}" EQUAL 98)
message(FATAL_ERROR "Abseil requires at least C++11")
elseif(NOT "${CMAKE_CXX_STANDARD}")
message(STATUS "No CMAKE_CXX_STANDARD set, assuming 11")
set(ABSL_CXX_STANDARD 11)
else()
set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
endif()

View file

@ -25,35 +25,15 @@ endif()
project(absl)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/CMake
${CMAKE_CURRENT_LIST_DIR}/absl/copts
)
include(GNUInstallDirs)
include(AbseilHelpers)
# config options
if (MSVC)
# /wd4005 macro-redefinition
# /wd4068 unknown pragma
# /wd4244 conversion from 'type1' to 'type2'
# /wd4267 conversion from 'size_t' to 'type2'
# /wd4800 force value to bool 'true' or 'false' (performance warning)
add_compile_options(/W3 /wd4005 /wd4068 /wd4244 /wd4267 /wd4800)
# /D_ENABLE_EXTENDED_ALIGNED_STORAGE Introduced in VS 2017 15.8, before the
# member type would non-conformingly have an alignment of only alignof(max_align_t).
add_definitions(
/DNOMINMAX
/DWIN32_LEAN_AND_MEAN=1
/D_CRT_SECURE_NO_WARNINGS
/D_SCL_SECURE_NO_WARNINGS
/D_ENABLE_EXTENDED_ALIGNED_STORAGE
)
else()
set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)")
endif()
##
## Using absl targets
##
@ -68,9 +48,6 @@ endif()
# include current path
list(APPEND ABSL_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
# -std=X
set(CMAKE_CXX_FLAGS "${ABSL_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}")
# -fexceptions
set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",
@ -230,7 +230,6 @@ cc_library(
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS,
deps = [
":base",
":config",
":pretty_function",
"//absl/memory",

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",

View file

@ -774,6 +774,39 @@ class InlinedVector {
bool allocated() const { return tag().allocated(); }
void ResetAllocation(Allocation new_allocation, size_type new_size) {
if (allocated()) {
Destroy(allocated_space(), allocated_space() + size());
assert(begin() == allocated_space());
allocation().Dealloc(allocator());
allocation() = new_allocation;
} else {
Destroy(inlined_space(), inlined_space() + size());
init_allocation(new_allocation); // bug: only init once
}
tag().set_allocated_size(new_size);
}
template <typename... Args>
reference Construct(pointer p, Args&&... args) {
std::allocator_traits<allocator_type>::construct(
allocator(), p, std::forward<Args>(args)...);
return *p;
}
template <typename Iterator>
void UninitializedCopy(Iterator src, Iterator src_last, pointer dst) {
for (; src != src_last; ++dst, ++src) Construct(dst, *src);
}
template <typename... Args>
void UninitializedFill(pointer dst, pointer dst_last, const Args&... args) {
for (; dst != dst_last; ++dst) Construct(dst, args...);
}
// Destroy [`from`, `to`) in place.
void Destroy(pointer from, pointer to);
// Enlarge the underlying representation so we can store `size_ + delta` elems
// in allocated space. The size is not changed, and any newly added memory is
// not initialized.
@ -790,19 +823,6 @@ class InlinedVector {
std::pair<iterator, iterator> ShiftRight(const_iterator position,
size_type n);
void ResetAllocation(Allocation new_allocation, size_type new_size) {
if (allocated()) {
Destroy(allocated_space(), allocated_space() + size());
assert(begin() == allocated_space());
allocation().Dealloc(allocator());
allocation() = new_allocation;
} else {
Destroy(inlined_space(), inlined_space() + size());
init_allocation(new_allocation); // bug: only init once
}
tag().set_allocated_size(new_size);
}
template <typename... Args>
reference GrowAndEmplaceBack(Args&&... args) {
assert(size() == capacity());
@ -825,25 +845,11 @@ class InlinedVector {
void InitAssign(size_type n, const_reference v);
template <typename... Args>
reference Construct(pointer p, Args&&... args) {
std::allocator_traits<allocator_type>::construct(
allocator(), p, std::forward<Args>(args)...);
return *p;
}
template <typename Iterator>
void AssignRange(Iterator first, Iterator last, std::forward_iterator_tag);
template <typename Iterator>
void UninitializedCopy(Iterator src, Iterator src_last, pointer dst) {
for (; src != src_last; ++dst, ++src) Construct(dst, *src);
}
template <typename... Args>
void UninitializedFill(pointer dst, pointer dst_last, const Args&... args) {
for (; dst != dst_last; ++dst) Construct(dst, args...);
}
// Destroy [`from`, `to`) in place.
void Destroy(pointer from, pointer to);
void AssignRange(Iterator first, Iterator last, std::input_iterator_tag);
template <typename Iterator>
void AppendRange(Iterator first, Iterator last, std::forward_iterator_tag);
@ -851,12 +857,6 @@ class InlinedVector {
template <typename Iterator>
void AppendRange(Iterator first, Iterator last, std::input_iterator_tag);
template <typename Iterator>
void AssignRange(Iterator first, Iterator last, std::forward_iterator_tag);
template <typename Iterator>
void AssignRange(Iterator first, Iterator last, std::input_iterator_tag);
iterator InsertWithCount(const_iterator position, size_type n,
const_reference v);
@ -1244,7 +1244,7 @@ void InlinedVector<T, N, A>::EnlargeBy(size_type delta) {
const size_type s = size();
assert(s <= capacity());
size_type target = std::max(inlined_capacity(), s + delta);
size_type target = (std::max)(inlined_capacity(), s + delta);
// Compute new capacity by repeatedly doubling current capacity
// TODO(psrc): Check and avoid overflow?
@ -1299,7 +1299,7 @@ auto InlinedVector<T, N, A>::ShiftRight(const_iterator position, size_type n)
iterator pos = const_cast<iterator>(position);
iterator raw_space = end();
size_type slots_in_used_space = raw_space - pos;
size_type new_elements_in_used_space = std::min(n, slots_in_used_space);
size_type new_elements_in_used_space = (std::min)(n, slots_in_used_space);
size_type new_elements_in_raw_space = n - new_elements_in_used_space;
size_type old_elements_in_used_space =
slots_in_used_space - new_elements_in_used_space;

View file

@ -60,7 +60,7 @@ std::vector<size_t> GetHashtableDebugNumProbesHistogram(const C& container) {
size_t num_probes = GetHashtableDebugNumProbes(
container,
absl::container_internal::hashtable_debug_internal::GetKey<C>(*it, 0));
v.resize(std::max(v.size(), num_probes + 1));
v.resize((std::max)(v.size(), num_probes + 1));
v[num_probes]++;
}
return v;

View file

@ -1363,7 +1363,7 @@ class raw_hash_set {
void rehash(size_t n) {
if (n == 0 && capacity_ == 0) return;
if (n == 0 && size_ == 0) return destroy_slots();
auto m = NormalizeCapacity(std::max(n, NumSlotsFast(size())));
auto m = NormalizeCapacity((std::max)(n, NumSlotsFast(size())));
// n == 0 unconditionally rehashes as per the standard.
if (n == 0 || m > capacity_) {
resize(m);

View file

@ -1,170 +0,0 @@
"""absl specific copts.
Flags specified here must not impact ABI. Code compiled with and without these
opts will be linked together, and in some cases headers compiled with and
without these options will be part of the same program.
DO NOT CHANGE THIS FILE WITHOUT CHANGING THE SAME FLAG IN absl/CMake/AbseilConfigureCopts.cmake!!
"""
GCC_FLAGS = [
"-Wall",
"-Wextra",
"-Wcast-qual",
"-Wconversion-null",
"-Wmissing-declarations",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvarargs",
"-Wvla", # variable-length array
"-Wwrite-strings",
# Google style does not use unsigned integers, though STL containers
# have unsigned types.
"-Wno-sign-compare",
]
GCC_TEST_FLAGS = [
"-Wno-conversion-null",
"-Wno-missing-declarations",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
]
# Docs on single flags is preceded by a comment.
# Docs on groups of flags is preceded by ###.
LLVM_FLAGS = [
"-Wall",
"-Wextra",
"-Weverything",
# Abseil does not support C++98
"-Wno-c++98-compat-pedantic",
# Turns off all implicit conversion warnings. Most are re-enabled below.
"-Wno-conversion",
"-Wno-covered-switch-default",
"-Wno-deprecated",
"-Wno-disabled-macro-expansion",
"-Wno-double-promotion",
###
# Turned off as they include valid C++ code.
"-Wno-comma",
"-Wno-extra-semi",
"-Wno-packed",
"-Wno-padded",
###
# Google style does not use unsigned integers, though STL containers
# have unsigned types.
"-Wno-sign-compare",
###
"-Wno-float-conversion",
"-Wno-float-equal",
"-Wno-format-nonliteral",
# Too aggressive: warns on Clang extensions enclosed in Clang-only
# compilation paths.
"-Wno-gcc-compat",
###
# Some internal globals are necessary. Don't do this at home.
"-Wno-global-constructors",
"-Wno-exit-time-destructors",
###
"-Wno-nested-anon-types",
"-Wno-non-modular-include-in-module",
"-Wno-old-style-cast",
# Warns on preferred usage of non-POD types such as string_view
"-Wno-range-loop-analysis",
"-Wno-reserved-id-macro",
"-Wno-shorten-64-to-32",
"-Wno-switch-enum",
"-Wno-thread-safety-negative",
"-Wno-undef",
"-Wno-unknown-warning-option",
"-Wno-unreachable-code",
# Causes warnings on include guards
"-Wno-unused-macros",
"-Wno-weak-vtables",
###
# Implicit conversion warnings turned off by -Wno-conversion
# which are re-enabled below.
"-Wbitfield-enum-conversion",
"-Wbool-conversion",
"-Wconstant-conversion",
"-Wenum-conversion",
"-Wint-conversion",
"-Wliteral-conversion",
"-Wnon-literal-null-conversion",
"-Wnull-conversion",
"-Wobjc-literal-conversion",
"-Wno-sign-conversion",
"-Wstring-conversion",
###
]
LLVM_TEST_FLAGS = [
"-Wno-c99-extensions",
"-Wno-missing-noreturn",
"-Wno-missing-prototypes",
"-Wno-missing-variable-declarations",
"-Wno-null-conversion",
"-Wno-shadow",
"-Wno-shift-sign-overflow",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-member-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-template",
"-Wno-used-but-marked-unused",
"-Wno-zero-as-null-pointer-constant",
# gtest depends on this GNU extension being offered.
"-Wno-gnu-zero-variadic-macro-arguments",
]
MSVC_FLAGS = [
"/W3",
"/wd4005", # macro-redefinition
"/wd4068", # unknown pragma
"/wd4180", # qualifier applied to function type has no meaning; ignored
"/wd4244", # conversion from 'type1' to 'type2', possible loss of data
"/wd4267", # conversion from 'size_t' to 'type', possible loss of data
"/wd4800", # forcing value to bool 'true' or 'false' (performance warning)
"/DNOMINMAX", # Don't define min and max macros (windows.h)
"/DWIN32_LEAN_AND_MEAN", # Don't bloat namespace with incompatible winsock versions.
"/D_CRT_SECURE_NO_WARNINGS", # Don't warn about usage of insecure C functions.
"/D_SCL_SECURE_NO_WARNINGS", # Don't warm when the compiler encounters a function or
# variable that is marked as deprecated (same as /wd4996).
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE", # Introduced in VS 2017 15.8,
# before the member type would non-conformingly have an alignment of only alignof(max_align_t).
]
MSVC_TEST_FLAGS = [
"/wd4018", # signed/unsigned mismatch
"/wd4101", # unreferenced local variable
"/wd4503", # decorated name length exceeded, name was truncated
]
# /Wall with msvc includes unhelpful warnings such as C4711, C4710, ...
ABSL_DEFAULT_COPTS = select({
"//absl:windows": MSVC_FLAGS,
"//absl:llvm_compiler": LLVM_FLAGS,
"//conditions:default": GCC_FLAGS,
})
# in absence of modules (--compiler=gcc or -c opt), cc_tests leak their copts
# to their (included header) dependencies and fail to build outside absl
ABSL_TEST_COPTS = ABSL_DEFAULT_COPTS + select({
"//absl:windows": MSVC_TEST_FLAGS,
"//absl:llvm_compiler": LLVM_TEST_FLAGS,
"//conditions:default": GCC_TEST_FLAGS,
})
ABSL_EXCEPTIONS_FLAG = select({
"//absl:windows": ["/U_HAS_EXCEPTIONS", "/D_HAS_EXCEPTIONS=1", "/EHsc"],
"//conditions:default": ["-fexceptions"],
})
ABSL_EXCEPTIONS_FLAG_LINKOPTS = select({
"//conditions:default": [],
})

View file

@ -0,0 +1,34 @@
# See absl/copts/copts.py and absl/copts/generate_copts.py
include(GENERATED_AbseilCopts)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(ABSL_DEFAULT_COPTS "${GCC_FLAGS}")
set(ABSL_TEST_COPTS "${GCC_FLAGS};${GCC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "${GCC_EXCEPTIONS_FLAGS}")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# MATCHES so we get both Clang and AppleClang
set(ABSL_DEFAULT_COPTS "${LLVM_FLAGS}")
set(ABSL_TEST_COPTS "${LLVM_FLAGS};${LLVM_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "${LLVM_EXCEPTIONS_FLAGS}")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(ABSL_DEFAULT_COPTS "${MSVC_FLAGS}")
set(ABSL_TEST_COPTS "${MSVC_FLAGS};${MSVC_TEST_FLAGS}")
set(ABSL_EXCEPTIONS_FLAG "${MSVC_EXCEPTIONS_FLAGS}")
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}. Building with no default flags")
set(ABSL_DEFAULT_COPTS "")
set(ABSL_TEST_COPTS "")
set(ABSL_EXCEPTIONS_FLAG "")
endif()
# This flag is used internally for Bazel builds and is kept here for consistency
set(ABSL_EXCEPTIONS_FLAG_LINKOPTS "")
if("${CMAKE_CXX_STANDARD}" EQUAL 98)
message(FATAL_ERROR "Abseil requires at least C++11")
elseif(NOT "${CMAKE_CXX_STANDARD}")
message(STATUS "No CMAKE_CXX_STANDARD set, assuming 11")
set(ABSL_CXX_STANDARD 11)
else()
set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
endif()

View file

@ -0,0 +1,130 @@
# GENERATED! DO NOT MANUALLY EDIT THIS FILE.
#
# (1) Edit absl/copts/copts.py.
# (2) Run `python <path_to_absl>/copts/generate_copts.py`.
list(APPEND GCC_EXCEPTIONS_FLAGS
"-fexceptions"
)
list(APPEND GCC_FLAGS
"-Wall"
"-Wextra"
"-Wcast-qual"
"-Wconversion-null"
"-Wmissing-declarations"
"-Woverlength-strings"
"-Wpointer-arith"
"-Wunused-local-typedefs"
"-Wunused-result"
"-Wvarargs"
"-Wvla"
"-Wwrite-strings"
"-Wno-sign-compare"
)
list(APPEND GCC_TEST_FLAGS
"-Wno-conversion-null"
"-Wno-missing-declarations"
"-Wno-sign-compare"
"-Wno-unused-function"
"-Wno-unused-parameter"
"-Wno-unused-private-field"
)
list(APPEND LLVM_EXCEPTIONS_FLAGS
"-fexceptions"
)
list(APPEND LLVM_FLAGS
"-Wall"
"-Wextra"
"-Weverything"
"-Wno-c++98-compat-pedantic"
"-Wno-conversion"
"-Wno-covered-switch-default"
"-Wno-deprecated"
"-Wno-disabled-macro-expansion"
"-Wno-double-promotion"
"-Wno-comma"
"-Wno-extra-semi"
"-Wno-packed"
"-Wno-padded"
"-Wno-sign-compare"
"-Wno-float-conversion"
"-Wno-float-equal"
"-Wno-format-nonliteral"
"-Wno-gcc-compat"
"-Wno-global-constructors"
"-Wno-exit-time-destructors"
"-Wno-nested-anon-types"
"-Wno-non-modular-include-in-module"
"-Wno-old-style-cast"
"-Wno-range-loop-analysis"
"-Wno-reserved-id-macro"
"-Wno-shorten-64-to-32"
"-Wno-switch-enum"
"-Wno-thread-safety-negative"
"-Wno-undef"
"-Wno-unknown-warning-option"
"-Wno-unreachable-code"
"-Wno-unused-macros"
"-Wno-weak-vtables"
"-Wbitfield-enum-conversion"
"-Wbool-conversion"
"-Wconstant-conversion"
"-Wenum-conversion"
"-Wint-conversion"
"-Wliteral-conversion"
"-Wnon-literal-null-conversion"
"-Wnull-conversion"
"-Wobjc-literal-conversion"
"-Wno-sign-conversion"
"-Wstring-conversion"
)
list(APPEND LLVM_TEST_FLAGS
"-Wno-c99-extensions"
"-Wno-missing-noreturn"
"-Wno-missing-prototypes"
"-Wno-missing-variable-declarations"
"-Wno-null-conversion"
"-Wno-shadow"
"-Wno-shift-sign-overflow"
"-Wno-sign-compare"
"-Wno-unused-function"
"-Wno-unused-member-function"
"-Wno-unused-parameter"
"-Wno-unused-private-field"
"-Wno-unused-template"
"-Wno-used-but-marked-unused"
"-Wno-zero-as-null-pointer-constant"
"-Wno-gnu-zero-variadic-macro-arguments"
)
list(APPEND MSVC_EXCEPTIONS_FLAGS
"/U_HAS_EXCEPTIONS"
"/D_HAS_EXCEPTIONS=1"
"/EHsc"
)
list(APPEND MSVC_FLAGS
"/W3"
"/wd4005"
"/wd4068"
"/wd4180"
"/wd4244"
"/wd4267"
"/wd4800"
"/DNOMINMAX"
"/DWIN32_LEAN_AND_MEAN"
"/D_CRT_SECURE_NO_WARNINGS"
"/D_SCL_SECURE_NO_WARNINGS"
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
)
list(APPEND MSVC_TEST_FLAGS
"/wd4018"
"/wd4101"
"/wd4503"
)

View file

@ -0,0 +1,131 @@
"""GENERATED! DO NOT MANUALLY EDIT THIS FILE.
(1) Edit absl/copts/copts.py.
(2) Run `python <path_to_absl>/copts/generate_copts.py`.
"""
GCC_EXCEPTIONS_FLAGS = [
"-fexceptions",
]
GCC_FLAGS = [
"-Wall",
"-Wextra",
"-Wcast-qual",
"-Wconversion-null",
"-Wmissing-declarations",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvarargs",
"-Wvla",
"-Wwrite-strings",
"-Wno-sign-compare",
]
GCC_TEST_FLAGS = [
"-Wno-conversion-null",
"-Wno-missing-declarations",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
]
LLVM_EXCEPTIONS_FLAGS = [
"-fexceptions",
]
LLVM_FLAGS = [
"-Wall",
"-Wextra",
"-Weverything",
"-Wno-c++98-compat-pedantic",
"-Wno-conversion",
"-Wno-covered-switch-default",
"-Wno-deprecated",
"-Wno-disabled-macro-expansion",
"-Wno-double-promotion",
"-Wno-comma",
"-Wno-extra-semi",
"-Wno-packed",
"-Wno-padded",
"-Wno-sign-compare",
"-Wno-float-conversion",
"-Wno-float-equal",
"-Wno-format-nonliteral",
"-Wno-gcc-compat",
"-Wno-global-constructors",
"-Wno-exit-time-destructors",
"-Wno-nested-anon-types",
"-Wno-non-modular-include-in-module",
"-Wno-old-style-cast",
"-Wno-range-loop-analysis",
"-Wno-reserved-id-macro",
"-Wno-shorten-64-to-32",
"-Wno-switch-enum",
"-Wno-thread-safety-negative",
"-Wno-undef",
"-Wno-unknown-warning-option",
"-Wno-unreachable-code",
"-Wno-unused-macros",
"-Wno-weak-vtables",
"-Wbitfield-enum-conversion",
"-Wbool-conversion",
"-Wconstant-conversion",
"-Wenum-conversion",
"-Wint-conversion",
"-Wliteral-conversion",
"-Wnon-literal-null-conversion",
"-Wnull-conversion",
"-Wobjc-literal-conversion",
"-Wno-sign-conversion",
"-Wstring-conversion",
]
LLVM_TEST_FLAGS = [
"-Wno-c99-extensions",
"-Wno-missing-noreturn",
"-Wno-missing-prototypes",
"-Wno-missing-variable-declarations",
"-Wno-null-conversion",
"-Wno-shadow",
"-Wno-shift-sign-overflow",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-member-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-template",
"-Wno-used-but-marked-unused",
"-Wno-zero-as-null-pointer-constant",
"-Wno-gnu-zero-variadic-macro-arguments",
]
MSVC_EXCEPTIONS_FLAGS = [
"/U_HAS_EXCEPTIONS",
"/D_HAS_EXCEPTIONS=1",
"/EHsc",
]
MSVC_FLAGS = [
"/W3",
"/wd4005",
"/wd4068",
"/wd4180",
"/wd4244",
"/wd4267",
"/wd4800",
"/DNOMINMAX",
"/DWIN32_LEAN_AND_MEAN",
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
]
MSVC_TEST_FLAGS = [
"/wd4018",
"/wd4101",
"/wd4503",
]

View file

@ -0,0 +1,42 @@
"""absl specific copts.
This file simply selects the correct options from the generated files. To
change Abseil copts, edit absl/copts/copts.py
"""
load(
"//absl:copts/GENERATED_copts.bzl",
"GCC_EXCEPTIONS_FLAGS",
"GCC_FLAGS",
"GCC_TEST_FLAGS",
"LLVM_EXCEPTIONS_FLAGS",
"LLVM_FLAGS",
"LLVM_TEST_FLAGS",
"MSVC_EXCEPTIONS_FLAGS",
"MSVC_FLAGS",
"MSVC_TEST_FLAGS",
)
ABSL_DEFAULT_COPTS = select({
"//absl:windows": MSVC_FLAGS,
"//absl:llvm_compiler": LLVM_FLAGS,
"//conditions:default": GCC_FLAGS,
})
# in absence of modules (--compiler=gcc or -c opt), cc_tests leak their copts
# to their (included header) dependencies and fail to build outside absl
ABSL_TEST_COPTS = ABSL_DEFAULT_COPTS + select({
"//absl:windows": MSVC_TEST_FLAGS,
"//absl:llvm_compiler": LLVM_TEST_FLAGS,
"//conditions:default": GCC_TEST_FLAGS,
})
ABSL_EXCEPTIONS_FLAG = select({
"//absl:windows": MSVC_EXCEPTIONS_FLAGS,
"//absl:llvm_compiler": LLVM_EXCEPTIONS_FLAGS,
"//conditions:default": GCC_EXCEPTIONS_FLAGS,
})
ABSL_EXCEPTIONS_FLAG_LINKOPTS = select({
"//conditions:default": [],
})

156
absl/copts/copts.py Normal file
View file

@ -0,0 +1,156 @@
"""Abseil compiler options.
This is the source of truth for Abseil compiler options. To modify Abseil
compilation options:
(1) Edit the appropriate list in this file.
(2) Run `python <path_to_absl>/copts/generate_copts.py`.
The generated copts are consumed by configure_copts.bzl and
AbseilConfigureCopts.cmake.
"""
import collections # absl:google-only(used for internal flags)
COPT_VARS = {
"GCC_FLAGS": [
"-Wall",
"-Wextra",
"-Wcast-qual",
"-Wconversion-null",
"-Wmissing-declarations",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvarargs",
"-Wvla", # variable-length array
"-Wwrite-strings",
# Google style does not use unsigned integers, though STL containers
# have unsigned types.
"-Wno-sign-compare",
],
"GCC_TEST_FLAGS": [
"-Wno-conversion-null",
"-Wno-missing-declarations",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
],
"GCC_EXCEPTIONS_FLAGS": ["-fexceptions"],
# Docs on single flags is preceded by a comment.
# Docs on groups of flags is preceded by ###.
"LLVM_FLAGS": [
"-Wall",
"-Wextra",
"-Weverything",
# Abseil does not support C++98
"-Wno-c++98-compat-pedantic",
# Turns off all implicit conversion warnings. Most are re-enabled below.
"-Wno-conversion",
"-Wno-covered-switch-default",
"-Wno-deprecated",
"-Wno-disabled-macro-expansion",
"-Wno-double-promotion",
###
# Turned off as they include valid C++ code.
"-Wno-comma",
"-Wno-extra-semi",
"-Wno-packed",
"-Wno-padded",
###
# Google style does not use unsigned integers, though STL containers
# have unsigned types.
"-Wno-sign-compare",
###
"-Wno-float-conversion",
"-Wno-float-equal",
"-Wno-format-nonliteral",
# Too aggressive: warns on Clang extensions enclosed in Clang-only
# compilation paths.
"-Wno-gcc-compat",
###
# Some internal globals are necessary. Don't do this at home.
"-Wno-global-constructors",
"-Wno-exit-time-destructors",
###
"-Wno-nested-anon-types",
"-Wno-non-modular-include-in-module",
"-Wno-old-style-cast",
# Warns on preferred usage of non-POD types such as string_view
"-Wno-range-loop-analysis",
"-Wno-reserved-id-macro",
"-Wno-shorten-64-to-32",
"-Wno-switch-enum",
"-Wno-thread-safety-negative",
"-Wno-undef",
"-Wno-unknown-warning-option",
"-Wno-unreachable-code",
# Causes warnings on include guards
"-Wno-unused-macros",
"-Wno-weak-vtables",
###
# Implicit conversion warnings turned off by -Wno-conversion
# which are re-enabled below.
"-Wbitfield-enum-conversion",
"-Wbool-conversion",
"-Wconstant-conversion",
"-Wenum-conversion",
"-Wint-conversion",
"-Wliteral-conversion",
"-Wnon-literal-null-conversion",
"-Wnull-conversion",
"-Wobjc-literal-conversion",
"-Wno-sign-conversion",
"-Wstring-conversion",
],
"LLVM_TEST_FLAGS": [
"-Wno-c99-extensions",
"-Wno-missing-noreturn",
"-Wno-missing-prototypes",
"-Wno-missing-variable-declarations",
"-Wno-null-conversion",
"-Wno-shadow",
"-Wno-shift-sign-overflow",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-member-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-template",
"-Wno-used-but-marked-unused",
"-Wno-zero-as-null-pointer-constant",
# gtest depends on this GNU extension being offered.
"-Wno-gnu-zero-variadic-macro-arguments",
],
"LLVM_EXCEPTIONS_FLAGS": ["-fexceptions"],
# /Wall with msvc includes unhelpful warnings such as C4711, C4710, ...
"MSVC_FLAGS": [
"/W3",
"/wd4005", # macro-redefinition
"/wd4068", # unknown pragma
"/wd4180", # qualifier applied to function type has no meaning; ignored
"/wd4244", # conversion from 'type1' to 'type2', possible loss of data
"/wd4267", # conversion from 'size_t' to 'type', possible loss of data
# forcing value to bool 'true' or 'false' (performance warning)
"/wd4800",
"/DNOMINMAX", # Don't define min and max macros (windows.h)
# Don't bloat namespace with incompatible winsock versions.
"/DWIN32_LEAN_AND_MEAN",
# Don't warn about usage of insecure C functions.
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
# Introduced in VS 2017 15.8, allow overaligned types in aligned_storage
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
],
"MSVC_TEST_FLAGS": [
"/wd4018", # signed/unsigned mismatch
"/wd4101", # unreferenced local variable
"/wd4503", # decorated name length exceeded, name was truncated
],
"MSVC_EXCEPTIONS_FLAGS": [
"/U_HAS_EXCEPTIONS", "/D_HAS_EXCEPTIONS=1", "/EHsc"
]
}

View file

@ -0,0 +1,107 @@
"""Generate Abseil compile compile option configs.
Usage: python absl/generate_copts.py
The configs are generated from copts.py.
"""
from os import path
import sys
from copts import COPT_VARS
# Helper functions
def file_header_lines():
return [
"GENERATED! DO NOT MANUALLY EDIT THIS FILE.", "",
"(1) Edit absl/copts/copts.py.",
"(2) Run `python <path_to_absl>/copts/generate_copts.py`."
]
def flatten(*lists):
return [item for sublist in lists for item in sublist]
def relative_filename(filename):
return path.join(path.dirname(__file__), filename)
# Style classes. These contain all the syntactic styling needed to generate a
# copt file for different build tools.
class CMakeStyle(object):
"""Style object for CMake copts file."""
def separator(self):
return ""
def list_introducer(self, name):
return "list(APPEND " + name
def list_closer(self):
return ")\n"
def docstring(self):
return "\n".join((("# " + line).strip() for line in file_header_lines()))
def filename(self):
return "GENERATED_AbseilCopts.cmake"
class StarlarkStyle(object):
"""Style object for Starlark copts file."""
def separator(self):
return ","
def list_introducer(self, name):
return name + " = ["
def list_closer(self):
return "]\n"
def docstring(self):
docstring_quotes = "\"\"\""
return docstring_quotes + "\n".join(
flatten(file_header_lines(), [docstring_quotes]))
def filename(self):
return "GENERATED_copts.bzl"
# Copt file generation
def copt_list(name, arg_list, style):
make_line = lambda s: " \"" + s + "\"" + style.separator()
external_str_list = [make_line(s) for s in arg_list]
return "\n".join(
flatten(
[style.list_introducer(name)],
external_str_list,
[style.list_closer()]))
def generate_copt_file(style):
"""Creates a generated copt file using the given style object.
Args:
style: either StarlarkStyle() or CMakeStyle()
"""
with open(relative_filename(style.filename()), "w") as f:
f.write(style.docstring())
f.write("\n")
for var_name, arg_list in sorted(COPT_VARS.items()):
f.write("\n")
f.write(copt_list(var_name, arg_list, style))
def main(argv):
if len(argv) > 1:
raise RuntimeError("generate_copts needs no command line args")
generate_copt_file(StarlarkStyle())
generate_copt_file(CMakeStyle())
if __name__ == "__main__":
main(sys.argv)

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)
@ -181,22 +181,8 @@ cc_test(
cc_library(
name = "leak_check",
srcs = select({
# The leak checking interface depends on weak function
# declarations that may not necessarily have definitions.
# Windows doesn't support this, and ios requires
# guaranteed definitions for weak symbols.
"//absl:ios": [],
"//absl:windows": [],
"//conditions:default": [
"leak_check.cc",
],
}),
hdrs = select({
"//absl:ios": [],
"//absl:windows": [],
"//conditions:default": ["leak_check.h"],
}),
srcs = ["leak_check.cc"],
hdrs = ["leak_check.h"],
deps = ["//absl/base:core_headers"],
)

View file

@ -181,9 +181,9 @@ absl_cc_library(
NAME
leak_check
HDRS
"$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:leak_check.h>"
"leak_check.h"
SRCS
"$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:leak_check.cc>"
"leak_check.cc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",

View file

@ -1,5 +1,5 @@
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)

View file

@ -14,39 +14,37 @@
# limitations under the License.
#
list(APPEND META_PUBLIC_HEADERS
"type_traits.h"
absl_cc_library(
NAME
type_traits
HDRS
"type_traits.h"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
PUBLIC
)
#
## TESTS
#
# test type_traits_test
list(APPEND TYPE_TRAITS_TEST_SRC
"type_traits_test.cc"
${META_PUBLIC_HEADERS}
)
absl_header_library(
TARGET
absl_meta
PUBLIC_LIBRARIES
absl::base
EXPORT_NAME
meta
)
absl_test(
TARGET
absl_cc_test(
NAME
type_traits_test
SOURCES
${TYPE_TRAITS_TEST_SRC}
PUBLIC_LIBRARIES
SRCS
"type_traits_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS
absl::type_traits
absl::base
absl::meta
absl::core_headers
gmock_main
)
# component target
absl_cc_library(
NAME
meta
DEPS
absl::type_traits
PUBLIC
)

View file

@ -13,7 +13,7 @@
# limitations under the License.
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)

View file

@ -14,49 +14,45 @@
# limitations under the License.
#
list(APPEND NUMERIC_PUBLIC_HEADERS
"int128.h"
)
# library 128
list(APPEND INT128_SRC
"int128.cc"
${NUMERIC_PUBLIC_HEADERS}
)
absl_library(
TARGET
absl_int128
SOURCES
${INT128_SRC}
PUBLIC_LIBRARIES
${INT128_PUBLIC_LIBRARIES}
EXPORT_NAME
absl_cc_library(
NAME
int128
HDRS
"int128.h"
SRCS
"int128.cc"
"int128_have_intrinsic.inc"
"int128_no_intrinsic.inc"
COPTS
${ABSL_DEFAULT_COPTS}
DEPS
absl::config
absl::core_headers
PUBLIC
)
absl_header_library(
TARGET
absl_numeric
PUBLIC_LIBRARIES
absl::int128
EXPORT_NAME
numeric
)
# test int128_test
set(INT128_TEST_SRC "int128_test.cc")
set(INT128_TEST_PUBLIC_LIBRARIES absl::numeric absl::base)
absl_test(
TARGET
absl_cc_test(
NAME
int128_test
SOURCES
${INT128_TEST_SRC}
PUBLIC_LIBRARIES
${INT128_TEST_PUBLIC_LIBRARIES}
SRCS
"int128_stream_test.cc"
"int128_test.cc"
COPTS
${ABSL_TEST_COPTS}
DEPS
absl::int128
absl::base
absl::core_headers
absl::hash_testing
absl::type_traits
gmock_main
)
# component target
absl_cc_library(
NAME
numeric
DEPS
absl::int128
PUBLIC
)

View file

@ -271,9 +271,9 @@ class numeric_limits<absl::uint128> {
#endif // ABSL_HAVE_INTRINSIC_INT128
static constexpr bool tinyness_before = false;
static constexpr absl::uint128 min() { return 0; }
static constexpr absl::uint128 (min)() { return 0; }
static constexpr absl::uint128 lowest() { return 0; }
static constexpr absl::uint128 max() { return absl::Uint128Max(); }
static constexpr absl::uint128 (max)() { return absl::Uint128Max(); }
static constexpr absl::uint128 epsilon() { return 0; }
static constexpr absl::uint128 round_error() { return 0; }
static constexpr absl::uint128 infinity() { return 0; }

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",

View file

@ -103,12 +103,12 @@ class BigUnsigned {
SetToZero();
return;
}
size_ = std::min(size_ + word_shift, max_words);
size_ = (std::min)(size_ + word_shift, max_words);
count %= 32;
if (count == 0) {
std::copy_backward(words_, words_ + size_ - word_shift, words_ + size_);
} else {
for (int i = std::min(size_, max_words - 1); i > word_shift; --i) {
for (int i = (std::min)(size_, max_words - 1); i > word_shift; --i) {
words_[i] = (words_[i - word_shift] << count) |
(words_[i - word_shift - 1] >> (32 - count));
}
@ -267,7 +267,7 @@ class BigUnsigned {
void MultiplyBy(int other_size, const uint32_t* other_words) {
const int original_size = size_;
const int first_step =
std::min(original_size + other_size - 2, max_words - 1);
(std::min)(original_size + other_size - 2, max_words - 1);
for (int step = first_step; step >= 0; --step) {
MultiplyStep(original_size, other_words, other_size, step);
}
@ -286,7 +286,7 @@ class BigUnsigned {
value = 0;
}
}
size_ = std::min(max_words, std::max(index + 1, size_));
size_ = (std::min)(max_words, (std::max)(index + 1, size_));
}
}
@ -309,7 +309,7 @@ class BigUnsigned {
} else {
// Normally 32-bit AddWithCarry() sets size_, but since we don't call
// it when `high` is 0, do it ourselves here.
size_ = std::min(max_words, std::max(index + 1, size_));
size_ = (std::min)(max_words, (std::max)(index + 1, size_));
}
}
}
@ -348,7 +348,7 @@ class BigUnsigned {
// Returns -1 if lhs < rhs, 0 if lhs == rhs, and 1 if lhs > rhs.
template <int N, int M>
int Compare(const BigUnsigned<N>& lhs, const BigUnsigned<M>& rhs) {
int limit = std::max(lhs.size(), rhs.size());
int limit = (std::max)(lhs.size(), rhs.size());
for (int i = limit - 1; i >= 0; --i) {
const uint32_t lhs_word = lhs.GetWord(i);
const uint32_t rhs_word = rhs.GetWord(i);
@ -363,7 +363,7 @@ int Compare(const BigUnsigned<N>& lhs, const BigUnsigned<M>& rhs) {
template <int N, int M>
bool operator==(const BigUnsigned<N>& lhs, const BigUnsigned<M>& rhs) {
int limit = std::max(lhs.size(), rhs.size());
int limit = (std::max)(lhs.size(), rhs.size());
for (int i = 0; i < limit; ++i) {
if (lhs.GetWord(i) != rhs.GetWord(i)) {
return false;

View file

@ -80,7 +80,7 @@ ConvertResult<Conv::s> FormatConvertImpl(const AbslCord& value,
int precision = conv.precision();
if (precision >= 0)
to_write = std::min(to_write, static_cast<size_t>(precision));
to_write = (std::min)(to_write, static_cast<size_t>(precision));
space_remaining = Excess(to_write, space_remaining);

View file

@ -355,7 +355,7 @@ class string_view {
string_view substr(size_type pos, size_type n = npos) const {
if (ABSL_PREDICT_FALSE(pos > length_))
base_internal::ThrowStdOutOfRange("absl::string_view::substr");
n = std::min(n, length_ - pos);
n = (std::min)(n, length_ - pos);
return string_view(ptr_ + pos, n);
}
@ -368,7 +368,7 @@ class string_view {
// on the respective sizes of the two `string_view`s to determine which is
// smaller, equal, or greater.
int compare(string_view x) const noexcept {
auto min_length = std::min(length_, x.length_);
auto min_length = (std::min)(length_, x.length_);
if (min_length > 0) {
int r = memcmp(ptr_, x.ptr_, min_length);
if (r < 0) return -1;
@ -517,7 +517,7 @@ inline bool operator!=(string_view x, string_view y) noexcept {
}
inline bool operator<(string_view x, string_view y) noexcept {
auto min_size = std::min(x.size(), y.size());
auto min_size = (std::min)(x.size(), y.size());
const int r = min_size == 0 ? 0 : memcmp(x.data(), y.data(), min_size);
return (r < 0) || (r == 0 && x.size() < y.size());
}
@ -547,7 +547,7 @@ namespace absl {
// Provided because std::string_view::substr throws if `pos > size()`
inline string_view ClippedSubstr(string_view s, size_t pos,
size_t n = string_view::npos) {
pos = std::min(pos, static_cast<size_t>(s.size()));
pos = (std::min)(pos, static_cast<size_t>(s.size()));
return s.substr(pos, n);
}

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)
@ -182,7 +182,6 @@ cc_library(
":synchronization",
":thread_pool",
"//absl/base",
"//absl/base:base_internal",
"@com_github_google_benchmark//:benchmark_main",
],
alwayslink = 1,

View file

@ -100,8 +100,8 @@ class KernelTimeout {
if (n < 0) n = 0;
struct timespec abstime;
int64_t seconds = std::min(n / kNanosPerSecond,
int64_t{(std::numeric_limits<time_t>::max)()});
int64_t seconds = (std::min)(n / kNanosPerSecond,
int64_t{(std::numeric_limits<time_t>::max)()});
abstime.tv_sec = static_cast<time_t>(seconds);
abstime.tv_nsec =
static_cast<decltype(abstime.tv_nsec)>(n % kNanosPerSecond);

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)

View file

@ -386,12 +386,12 @@ class civil_time {
: civil_time(ct.f_) {}
// Factories for the maximum/minimum representable civil_time.
static CONSTEXPR_F civil_time max() {
const auto max_year = std::numeric_limits<std::int_least64_t>::max();
static CONSTEXPR_F civil_time (max)() {
const auto max_year = (std::numeric_limits<std::int_least64_t>::max)();
return civil_time(max_year, 12, 31, 23, 59, 59);
}
static CONSTEXPR_F civil_time min() {
const auto min_year = std::numeric_limits<std::int_least64_t>::min();
static CONSTEXPR_F civil_time (min)() {
const auto min_year = (std::numeric_limits<std::int_least64_t>::min)();
return civil_time(min_year, 1, 1, 0, 0, 0);
}
@ -409,7 +409,7 @@ class civil_time {
return *this;
}
CONSTEXPR_M civil_time& operator-=(diff_t n) noexcept {
if (n != std::numeric_limits<diff_t>::min()) {
if (n != (std::numeric_limits<diff_t>::min)()) {
f_ = step(T{}, f_, -n);
} else {
f_ = step(T{}, step(T{}, f_, -(n + 1)), 1);

View file

@ -1441,10 +1441,10 @@ T ToChronoDuration(Duration d) {
using Period = typename T::period;
static_assert(IsValidRep64<Rep>(0), "duration::rep is invalid");
if (time_internal::IsInfiniteDuration(d))
return d < ZeroDuration() ? T::min() : T::max();
return d < ZeroDuration() ? (T::min)() : (T::max)();
const auto v = ToInt64(d, Period{});
if (v > (std::numeric_limits<Rep>::max)()) return T::max();
if (v < (std::numeric_limits<Rep>::min)()) return T::min();
if (v > (std::numeric_limits<Rep>::max)()) return (T::max)();
if (v < (std::numeric_limits<Rep>::min)()) return (T::min)();
return T{v};
}

View file

@ -15,7 +15,7 @@
#
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",

View file

@ -1,5 +1,5 @@
load(
"//absl:copts.bzl",
"//absl:copts/configure_copts.bzl",
"ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS",
)