From 6de53819a7173bd446156237a37f53464b7732cc Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 13 Oct 2017 10:21:40 -0700 Subject: [PATCH] Changes imported from Abseil "staging" branch: - 432508bf64998983b3c194d5f164872ce3c2e573 Put visibility tags into absl external build files by Jon Cohen - 25d59d11e7b833fe632cddb5bf4d76075ae6282b Use ABSL_PREDICT_TRUE instead of *FALSE for the range che... by Jon Cohen - 8d8a5890a55ddd19aac849748441eeb57c684f10 Better detection for MSVC support on std::optional. by Xiaoyi Zhang - c1b31e4a97939885c3bbc23ecb093e9619e73ad1 Internal cleanup by Gennadiy Rozental - 4f56ad20c4eeccc6f5fb21ec6c7191233d34a090 Internal change. by Matt Calabrese - d2a02b52c75c295708170f4d17b7ff442c8d6a97 Fixed a minor typo in the SimpleAtob() function comment. by Abseil Team - 5adbff5c23a45278d06de2ef3a29ea51b0d1269e Internal cleanup by Gennadiy Rozental GitOrigin-RevId: 432508bf64998983b3c194d5f164872ce3c2e573 Change-Id: I32ddd151d3350b96a22e8f1830f19b59374953ad --- .ci/abseil-cpp.json | 7 ------- absl/BUILD.bazel | 4 ++++ absl/base/BUILD.bazel | 18 ++++++++++++++++-- absl/base/config.h | 15 +++++++++++++++ absl/container/BUILD.bazel | 3 +++ absl/strings/BUILD.bazel | 15 +++++++++++++++ absl/strings/internal/utf8.h | 1 - absl/strings/match.h | 5 +++-- absl/strings/numbers.h | 6 +++--- absl/synchronization/BUILD.bazel | 3 +++ absl/time/BUILD.bazel | 3 +++ absl/types/optional_test.cc | 9 +++++++++ absl/types/span.h | 2 +- 13 files changed, 75 insertions(+), 16 deletions(-) delete mode 100644 .ci/abseil-cpp.json diff --git a/.ci/abseil-cpp.json b/.ci/abseil-cpp.json deleted file mode 100644 index b21e68d1..00000000 --- a/.ci/abseil-cpp.json +++ /dev/null @@ -1,7 +0,0 @@ -// This is a relaxed JSON format, you can have comments in it. -// This is a list of configuration for the job that does not specify a configuration. -[ - {"node": "linux-x86_64"}, - {"node": "ubuntu_16.04-x86_64"}, - {"node": "darwin-x86_64"} -] diff --git a/absl/BUILD.bazel b/absl/BUILD.bazel index 403a35c3..439addbf 100644 --- a/absl/BUILD.bazel +++ b/absl/BUILD.bazel @@ -23,6 +23,7 @@ config_setting( values = { "compiler": "llvm", }, + visibility = [":__subpackages__"], ) # following configs are based on mapping defined in: https://git.io/v5Ijz @@ -31,6 +32,7 @@ config_setting( values = { "cpu": "darwin", }, + visibility = [":__subpackages__"], ) config_setting( @@ -38,6 +40,7 @@ config_setting( values = { "cpu": "x64_windows", }, + visibility = [":__subpackages__"], ) config_setting( @@ -45,4 +48,5 @@ config_setting( values = { "cpu": "ppc", }, + visibility = [":__subpackages__"], ) diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel index 23439a09..d68448da 100644 --- a/absl/base/BUILD.bazel +++ b/absl/base/BUILD.bazel @@ -25,8 +25,6 @@ package(default_visibility = ["//visibility:public"]) licenses(["notice"]) # Apache 2.0 -exports_files(["thread_annotations.h"]) - cc_library( name = "spinlock_wait", srcs = [ @@ -39,6 +37,9 @@ cc_library( "internal/spinlock_wait.h", ], copts = ABSL_DEFAULT_COPTS, + visibility = [ + "//absl/base:__pkg__", + ], deps = [":core_headers"], ) @@ -83,6 +84,9 @@ cc_library( "internal/malloc_extension_c.h", ], copts = ABSL_DEFAULT_COPTS, + visibility = [ + "//absl:__subpackages__", + ], deps = [ ":core_headers", ":dynamic_annotations", @@ -108,6 +112,9 @@ cc_library( textual_hdrs = [ "internal/malloc_hook_invoke.h", ], + visibility = [ + "//absl:__subpackages__", + ], deps = [ ":base", ":config", @@ -124,6 +131,9 @@ cc_library( "internal/invoke.h", ], copts = ABSL_DEFAULT_COPTS, + visibility = [ + "//absl:__subpackages__", + ], ) cc_library( @@ -183,6 +193,9 @@ cc_library( features = [ "-use_header_modules", ], + visibility = [ + "//absl:__subpackages__", + ], deps = [ ":base", ":config", @@ -205,6 +218,7 @@ cc_library( testonly = 1, hdrs = ["internal/exception_testing.h"], copts = ABSL_TEST_COPTS, + visibility = ["//absl:__subpackages__"], deps = [ ":config", "@com_google_googletest//:gtest", diff --git a/absl/base/config.h b/absl/base/config.h index 5f0dd04c..495811bd 100644 --- a/absl/base/config.h +++ b/absl/base/config.h @@ -372,4 +372,19 @@ #endif #endif +// For MSVC, `__has_include` is supported in VS 2017 15.3, which is later than +// the support for , , . So we use _MSC_VER to check +// whether we have VS 2017 RTM (when , , is +// implemented) or higher. +// Also, `__cplusplus` is not correctly set by MSVC, so we use `_MSVC_LANG` to +// check the language version. +// TODO(zhangxy): fix tests before enabling aliasing for `std::any`, +// `std::string_view`. +#if defined(_MSC_VER) && _MSC_VER >= 1910 && \ + ((defined(_MSVC_LANG) && _MSVC_LANG > 201402) || __cplusplus > 201402) +// #define ABSL_HAVE_STD_ANY 1 +#define ABSL_HAVE_STD_OPTIONAL 1 +// #define ABSL_HAVE_STD_STRING_VIEW 1 +#endif + #endif // ABSL_BASE_CONFIG_H_ diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index ee017431..7d550cb1 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -112,6 +112,9 @@ cc_library( srcs = ["internal/test_instance_tracker.cc"], hdrs = ["internal/test_instance_tracker.h"], copts = ABSL_DEFAULT_COPTS, + visibility = [ + "//absl:__subpackages__", + ], ) cc_test( diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel index b2610663..49f49abd 100644 --- a/absl/strings/BUILD.bazel +++ b/absl/strings/BUILD.bazel @@ -103,6 +103,7 @@ cc_test( size = "small", srcs = ["match_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "@com_google_googletest//:gtest_main", @@ -117,6 +118,7 @@ cc_test( "internal/escaping_test_common.inc", ], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:core_headers", @@ -130,6 +132,7 @@ cc_test( size = "small", srcs = ["ascii_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:core_headers", @@ -145,6 +148,7 @@ cc_test( "internal/memutil_test.cc", ], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:core_headers", @@ -159,6 +163,7 @@ cc_test( "internal/utf8_test.cc", ], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":internal", ":strings", @@ -172,6 +177,7 @@ cc_test( size = "small", srcs = ["string_view_test.cc"], copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:config", @@ -186,6 +192,7 @@ cc_test( size = "small", srcs = ["substitute_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:core_headers", @@ -198,6 +205,7 @@ cc_test( size = "small", srcs = ["str_replace_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "@com_google_googletest//:gtest_main", @@ -208,6 +216,7 @@ cc_test( name = "str_split_test", srcs = ["str_split_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:core_headers", @@ -221,6 +230,7 @@ cc_test( size = "small", srcs = ["internal/ostringstream_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":internal", "@com_google_googletest//:gtest_main", @@ -235,6 +245,7 @@ cc_test( "internal/resize_uninitialized_test.cc", ], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ "//absl/base:core_headers", "//absl/meta:type_traits", @@ -247,6 +258,7 @@ cc_test( size = "small", srcs = ["str_join_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:core_headers", @@ -260,6 +272,7 @@ cc_test( size = "small", srcs = ["str_cat_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base:core_headers", @@ -278,6 +291,7 @@ cc_test( tags = [ "no_test_loonix", ], + visibility = ["//visibility:private"], deps = [ ":strings", "//absl/base", @@ -291,6 +305,7 @@ cc_test( size = "small", srcs = ["strip_test.cc"], copts = ABSL_TEST_COPTS, + visibility = ["//visibility:private"], deps = [ ":strings", "@com_google_googletest//:gtest_main", diff --git a/absl/strings/internal/utf8.h b/absl/strings/internal/utf8.h index 705eea7f..5bd82e84 100644 --- a/absl/strings/internal/utf8.h +++ b/absl/strings/internal/utf8.h @@ -25,7 +25,6 @@ #include #include - namespace absl { namespace strings_internal { diff --git a/absl/strings/match.h b/absl/strings/match.h index 4ac35f19..3d54da81 100644 --- a/absl/strings/match.h +++ b/absl/strings/match.h @@ -53,7 +53,7 @@ inline bool StrContains(absl::string_view haystack, absl::string_view needle) { inline bool StartsWith(absl::string_view text, absl::string_view prefix) { return prefix.empty() || (text.size() >= prefix.size() && - memcmp(text.data(), prefix.data(), prefix.size()) == 0); + memcmp(text.data(), prefix.data(), prefix.size()) == 0); } // EndsWith() @@ -63,7 +63,8 @@ inline bool EndsWith(absl::string_view text, absl::string_view suffix) { return suffix.empty() || (text.size() >= suffix.size() && memcmp(text.data() + (text.size() - suffix.size()), suffix.data(), - suffix.size()) == 0); + suffix.size()) == 0 + ); } // StartsWithIgnoreCase() diff --git a/absl/strings/numbers.h b/absl/strings/numbers.h index 74aebc80..1f3bbcfa 100644 --- a/absl/strings/numbers.h +++ b/absl/strings/numbers.h @@ -62,9 +62,9 @@ ABSL_MUST_USE_RESULT bool SimpleAtod(absl::string_view str, double* value); // SimpleAtob() // -// Converts the given std::string into into a boolean, returning `true` if -// successful. The following case-insensitive strings are interpreted as boolean -// `true`: "true", "t", "yes", "y", "1". The following case-insensitive strings +// Converts the given std::string into a boolean, returning `true` if successful. +// The following case-insensitive strings are interpreted as boolean `true`: +// "true", "t", "yes", "y", "1". The following case-insensitive strings // are interpreted as boolean `false`: "false", "f", "no", "n", "0". ABSL_MUST_USE_RESULT bool SimpleAtob(absl::string_view str, bool* value); diff --git a/absl/synchronization/BUILD.bazel b/absl/synchronization/BUILD.bazel index cc8cecf9..4faf62de 100644 --- a/absl/synchronization/BUILD.bazel +++ b/absl/synchronization/BUILD.bazel @@ -34,6 +34,9 @@ cc_library( "internal/graphcycles.h", ], copts = ABSL_DEFAULT_COPTS, + visibility = [ + "//absl:__subpackages__", + ], deps = [ "//absl/base", "//absl/base:core_headers", diff --git a/absl/time/BUILD.bazel b/absl/time/BUILD.bazel index c34f5248..3d1d2df5 100644 --- a/absl/time/BUILD.bazel +++ b/absl/time/BUILD.bazel @@ -57,6 +57,9 @@ cc_library( ], hdrs = ["internal/test_util.h"], copts = ABSL_DEFAULT_COPTS, + visibility = [ + "//absl/time:__pkg__", + ], deps = [ ":time", "//absl/base", diff --git a/absl/types/optional_test.cc b/absl/types/optional_test.cc index 645f5b93..5eedfcfd 100644 --- a/absl/types/optional_test.cc +++ b/absl/types/optional_test.cc @@ -270,8 +270,17 @@ TEST(optionalTest, CopyConstructor) { EXPECT_TRUE(absl::is_trivially_copy_constructible< absl::optional>::value); #endif + // When testing with VS 2017 15.3, there seems to be a bug in MSVC + // std::optional when T is volatile-qualified. So skipping this test. + // Bug report: + // https://connect.microsoft.com/VisualStudio/feedback/details/3142534 +#if defined(ABSL_HAVE_STD_OPTIONAL) && defined(_MSC_VER) && _MSC_VER >= 1911 +#define ABSL_MSVC_OPTIONAL_VOLATILE_COPY_BUG 1 +#endif +#ifndef ABSL_MSVC_OPTIONAL_VOLATILE_COPY_BUG EXPECT_FALSE(std::is_copy_constructible< absl::optional>::value); +#endif } } diff --git a/absl/types/span.h b/absl/types/span.h index e1f006ad..f4738153 100644 --- a/absl/types/span.h +++ b/absl/types/span.h @@ -378,7 +378,7 @@ class Span { // // Returns a reference to the i'th element of this span. constexpr reference at(size_type i) const { - return ABSL_PREDICT_FALSE(i < size()) + return ABSL_PREDICT_TRUE(i < size()) ? ptr_[i] : (base_internal::ThrowStdOutOfRange( "Span::at failed bounds check"),