about summary refs log tree commit diff
path: root/absl
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-04-01T21·06-0700
committerGennadiy Rozental <rogeeff@google.com>2019-04-01T22·15-0400
commit93dfcf74cb5fccae3da07897d8613ae6cab958a0 (patch)
tree04896cfc845d55a724a1aac5589caf2045fc33a9 /absl
parent2c8421e1c6cef0da9e8a20b01c15256ec9ec116d (diff)
Export of internal Abseil changes.
--
855576faf9556573fd74c2874b290d8feb6565d5 by Gennadiy Rozental <rogeeff@google.com>:

Import of CCTZ from GitHub.

PiperOrigin-RevId: 241395451

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

Fixes comment over AbslHashValue for InlinedVector

PiperOrigin-RevId: 241368320

--
75f58dafcac7d78c28d92a61ec7e53c5b3b86697 by Matt Kulukundis <kfm@google.com>:

Do not call sampling logic for tables with custom allocators.

PiperOrigin-RevId: 241356451

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

Re-enable optionalTest.InPlaceTSFINAEBug after libc++ update

PiperOrigin-RevId: 241222673

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

Update Clang on Kokoro to r356196.

This includes a workaround for a -Wgnu-include-next warning fixed by
https://reviews.llvm.org/rG0706e144d57305782988dd4367530ae04986116f

PiperOrigin-RevId: 241222395

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

Remove identical test and fix char to string per comment

PiperOrigin-RevId: 240855512
GitOrigin-RevId: 855576faf9556573fd74c2874b290d8feb6565d5
Change-Id: Ie155b209ef5567e6597da6ef1844db7e2ad72586
Diffstat (limited to 'absl')
-rw-r--r--absl/container/inlined_vector.h6
-rw-r--r--absl/container/internal/raw_hash_set.h13
-rw-r--r--absl/container/internal/raw_hash_set_test.cc41
-rw-r--r--absl/copts/GENERATED_AbseilCopts.cmake4
-rw-r--r--absl/copts/GENERATED_copts.bzl4
-rw-r--r--absl/copts/copts.py2
-rw-r--r--absl/strings/str_split_test.cc19
-rw-r--r--absl/time/internal/cctz/src/time_zone_lookup.cc33
-rw-r--r--absl/time/internal/cctz/src/tzfile.h3
-rw-r--r--absl/time/internal/cctz/testdata/version2
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/America/Metlakatlabin1409 -> 1423 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/Asia/Gazabin2286 -> 2343 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/Asia/Hebronbin2314 -> 2371 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/Asia/Jerusalembin2256 -> 2312 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/Asia/Tel_Avivbin2256 -> 2312 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/Etc/UCTbin118 -> 118 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/Israelbin2256 -> 2312 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/UCTbin118 -> 118 bytes
-rw-r--r--absl/time/internal/cctz/testdata/zoneinfo/iso3166.tab6
-rw-r--r--absl/types/optional_test.cc2
20 files changed, 94 insertions, 41 deletions
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index 0f066860623c..9b699b57a49a 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -1303,10 +1303,10 @@ bool operator>=(const absl::InlinedVector<T, N, A>& a,
   return !(a < b);
 }
 
-// AbslHashValue()
+// `AbslHashValue()`
 //
-// Provides `absl::Hash` support for inlined vectors. You do not normally call
-// this function directly.
+// Provides `absl::Hash` support for `absl::InlinedVector`. You do not normally
+// call this function directly.
 template <typename H, typename TheT, size_t TheN, typename TheA>
 H AbslHashValue(H h, const absl::InlinedVector<TheT, TheN, TheA>& a) {
   auto a_data = a.data();
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
index 85e33344c7d5..9c926812a07a 100644
--- a/absl/container/internal/raw_hash_set.h
+++ b/absl/container/internal/raw_hash_set.h
@@ -1437,7 +1437,18 @@ class raw_hash_set {
 
   void initialize_slots() {
     assert(capacity_);
-    if (slots_ == nullptr) {
+    // Folks with custom allocators often make unwaranted assumptions about the
+    // behavior of their classes vis-a-vis trivial destructability and what
+    // calls they will or wont make.  Avoid sampling for people with custom
+    // allocators to get us out of this mess.  This is not a hard guarntee but a
+    // workaround while we plan the exact guarantee we want to provide.
+    //
+    // People are often sloppy with the exact type of their allocator (sometimes
+    // it has an extra const or is missing the pair, but rebinds made it work
+    // anyway).  To avoid the ambiguitity, we work off SlotAlloc which we have
+    // bound more carefully.
+    if (std::is_same<SlotAlloc, std::allocator<slot_type>>::value &&
+        slots_ == nullptr) {
       infoz_ = Sample();
     }
 
diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc
index 7d96ed90be9c..871d85f139a1 100644
--- a/absl/container/internal/raw_hash_set_test.cc
+++ b/absl/container/internal/raw_hash_set_test.cc
@@ -343,7 +343,25 @@ struct IntTable
     : raw_hash_set<IntPolicy, container_internal::hash_default_hash<int64_t>,
                    std::equal_to<int64_t>, std::allocator<int64_t>> {
   using Base = typename IntTable::raw_hash_set;
-  IntTable() {}
+  using Base::Base;
+};
+
+template <typename T>
+struct CustomAlloc : std::allocator<T> {
+  CustomAlloc() {}
+
+  template <typename U>
+  CustomAlloc(const CustomAlloc<U>& other) {}
+
+  template<class U> struct rebind {
+    using other = CustomAlloc<U>;
+  };
+};
+
+struct CustomAllocIntTable
+    : raw_hash_set<IntPolicy, container_internal::hash_default_hash<int64_t>,
+                   std::equal_to<int64_t>, CustomAlloc<int64_t>> {
+  using Base = typename CustomAllocIntTable::raw_hash_set;
   using Base::Base;
 };
 
@@ -1869,6 +1887,27 @@ TEST(RawHashSamplerTest, Sample) {
               0.01, 0.005);
 }
 
+TEST(RawHashSamplerTest, DoNotSampleCustomAllocators) {
+  // Enable the feature even if the prod default is off.
+  SetHashtablezEnabled(true);
+  SetHashtablezSampleParameter(100);
+
+  auto& sampler = HashtablezSampler::Global();
+  size_t start_size = 0;
+  start_size += sampler.Iterate([&](const HashtablezInfo&) { ++start_size; });
+
+  std::vector<CustomAllocIntTable> tables;
+  for (int i = 0; i < 1000000; ++i) {
+    tables.emplace_back();
+    tables.back().insert(1);
+  }
+  size_t end_size = 0;
+  end_size += sampler.Iterate([&](const HashtablezInfo&) { ++end_size; });
+
+  EXPECT_NEAR((end_size - start_size) / static_cast<double>(tables.size()),
+              0.00, 0.001);
+}
+
 #ifdef ADDRESS_SANITIZER
 TEST(Sanitizer, PoisoningUnused) {
   IntTable t;
diff --git a/absl/copts/GENERATED_AbseilCopts.cmake b/absl/copts/GENERATED_AbseilCopts.cmake
index 043c88a2f576..16cf9feaee8e 100644
--- a/absl/copts/GENERATED_AbseilCopts.cmake
+++ b/absl/copts/GENERATED_AbseilCopts.cmake
@@ -76,6 +76,7 @@ list(APPEND ABSL_CLANG_CL_TEST_FLAGS
     "-Wno-unused-template"
     "-Wno-used-but-marked-unused"
     "-Wno-zero-as-null-pointer-constant"
+    "-Wno-gnu-include-next"
     "-Wno-gnu-zero-variadic-macro-arguments"
 )
 
@@ -177,6 +178,7 @@ list(APPEND ABSL_LLVM_TEST_FLAGS
     "-Wno-unused-template"
     "-Wno-used-but-marked-unused"
     "-Wno-zero-as-null-pointer-constant"
+    "-Wno-gnu-include-next"
     "-Wno-gnu-zero-variadic-macro-arguments"
 )
 
@@ -202,7 +204,7 @@ list(APPEND ABSL_MSVC_FLAGS
 )
 
 list(APPEND ABSL_MSVC_LINKOPTS
-    "-ignore:4221"
+    "/ignore:4221"
 )
 
 list(APPEND ABSL_MSVC_TEST_FLAGS
diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
index d40380b86057..0669c7242e72 100644
--- a/absl/copts/GENERATED_copts.bzl
+++ b/absl/copts/GENERATED_copts.bzl
@@ -77,6 +77,7 @@ ABSL_CLANG_CL_TEST_FLAGS = [
     "-Wno-unused-template",
     "-Wno-used-but-marked-unused",
     "-Wno-zero-as-null-pointer-constant",
+    "-Wno-gnu-include-next",
     "-Wno-gnu-zero-variadic-macro-arguments",
 ]
 
@@ -178,6 +179,7 @@ ABSL_LLVM_TEST_FLAGS = [
     "-Wno-unused-template",
     "-Wno-used-but-marked-unused",
     "-Wno-zero-as-null-pointer-constant",
+    "-Wno-gnu-include-next",
     "-Wno-gnu-zero-variadic-macro-arguments",
 ]
 
@@ -203,7 +205,7 @@ ABSL_MSVC_FLAGS = [
 ]
 
 ABSL_MSVC_LINKOPTS = [
-    "-ignore:4221",
+    "/ignore:4221",
 ]
 
 ABSL_MSVC_TEST_FLAGS = [
diff --git a/absl/copts/copts.py b/absl/copts/copts.py
index 608d7c0edeee..cd56890671e5 100644
--- a/absl/copts/copts.py
+++ b/absl/copts/copts.py
@@ -103,6 +103,8 @@ LLVM_TEST_DISABLE_WARNINGS_FLAGS = [
     "-Wno-unused-template",
     "-Wno-used-but-marked-unused",
     "-Wno-zero-as-null-pointer-constant",
+    # For a libc++ bug fixed in r357267
+    "-Wno-gnu-include-next",
     # gtest depends on this GNU extension being offered.
     "-Wno-gnu-zero-variadic-macro-arguments",
 ]
diff --git a/absl/strings/str_split_test.cc b/absl/strings/str_split_test.cc
index 4b8e7d6b43a7..02f27bc41497 100644
--- a/absl/strings/str_split_test.cc
+++ b/absl/strings/str_split_test.cc
@@ -71,8 +71,8 @@ TEST(Split, TraitsTest) {
 // namespaces just like callers will need to use.
 TEST(Split, APIExamples) {
   {
-    // Passes std::string delimiter. Assumes the default of Literal.
-    std::vector<std::string> v = absl::StrSplit("a,b,c", ',');
+    // Passes std::string delimiter. Assumes the default of ByString.
+    std::vector<std::string> v = absl::StrSplit("a,b,c", ",");  // NOLINT
     EXPECT_THAT(v, ElementsAre("a", "b", "c"));
 
     // Equivalent to...
@@ -97,17 +97,6 @@ TEST(Split, APIExamples) {
   }
 
   {
-    // Same as above, but using std::string
-    std::vector<std::string> v = absl::StrSplit("a,b,c", ',');
-    EXPECT_THAT(v, ElementsAre("a", "b", "c"));
-
-    // Equivalent to...
-    using absl::ByChar;
-    v = absl::StrSplit("a,b,c", ByChar(','));
-    EXPECT_THAT(v, ElementsAre("a", "b", "c"));
-  }
-
-  {
     // Uses the Literal std::string "=>" as the delimiter.
     const std::vector<std::string> v = absl::StrSplit("a=>b=>c", "=>");
     EXPECT_THAT(v, ElementsAre("a", "b", "c"));
@@ -797,7 +786,7 @@ static bool IsFoundAt(absl::string_view text, Delimiter d, int expected_pos) {
 }
 
 //
-// Tests for Literal
+// Tests for ByString
 //
 
 // Tests using any delimiter that represents a single comma.
@@ -817,7 +806,7 @@ void TestComma(Delimiter d) {
   EXPECT_FALSE(IsFoundAt(";", d, -1));
 }
 
-TEST(Delimiter, Literal) {
+TEST(Delimiter, ByString) {
   using absl::ByString;
   TestComma(ByString(","));
 
diff --git a/absl/time/internal/cctz/src/time_zone_lookup.cc b/absl/time/internal/cctz/src/time_zone_lookup.cc
index fd04e2df3985..a27bfc1353a3 100644
--- a/absl/time/internal/cctz/src/time_zone_lookup.cc
+++ b/absl/time/internal/cctz/src/time_zone_lookup.cc
@@ -23,6 +23,7 @@
 
 #if defined(__APPLE__)
 #include <CoreFoundation/CFTimeZone.h>
+#include <vector>
 #endif
 
 #include <cstdlib>
@@ -121,25 +122,33 @@ time_zone fixed_time_zone(const seconds& offset) {
 
 time_zone local_time_zone() {
   const char* zone = ":localtime";
+#if defined(__ANDROID__)
+  char sysprop[PROP_VALUE_MAX];
+  if (__system_property_get("persist.sys.timezone", sysprop) > 0) {
+    zone = sysprop;
+  }
+#endif
+#if defined(__APPLE__)
+  std::vector<char> buffer;
+  CFTimeZoneRef tz_default = CFTimeZoneCopyDefault();
+  if (CFStringRef tz_name = CFTimeZoneGetName(tz_default)) {
+    CFStringEncoding encoding = kCFStringEncodingUTF8;
+    CFIndex length = CFStringGetLength(tz_name);
+    buffer.resize(CFStringGetMaximumSizeForEncoding(length, encoding) + 1);
+    if (CFStringGetCString(tz_name, &buffer[0], buffer.size(), encoding)) {
+      zone = &buffer[0];
+    }
+  }
+  CFRelease(tz_default);
+#endif
 
   // Allow ${TZ} to override to default zone.
   char* tz_env = nullptr;
 #if defined(_MSC_VER)
   _dupenv_s(&tz_env, nullptr, "TZ");
-#elif defined(__APPLE__)
-  CFTimeZoneRef system_time_zone = CFTimeZoneCopyDefault();
-  CFStringRef tz_name = CFTimeZoneGetName(system_time_zone);
-  tz_env = strdup(CFStringGetCStringPtr(tz_name, CFStringGetSystemEncoding()));
-  CFRelease(system_time_zone);
 #else
   tz_env = std::getenv("TZ");
 #endif
-#if defined(__ANDROID__)
-  char sysprop[PROP_VALUE_MAX];
-  if (tz_env == nullptr)
-    if (__system_property_get("persist.sys.timezone", sysprop) > 0)
-      tz_env = sysprop;
-#endif
   if (tz_env) zone = tz_env;
 
   // We only support the "[:]<zone-name>" form.
@@ -163,8 +172,6 @@ time_zone local_time_zone() {
 #if defined(_MSC_VER)
   free(localtime_env);
   free(tz_env);
-#elif defined(__APPLE__)
-  free(tz_env);
 #endif
 
   time_zone tz;
diff --git a/absl/time/internal/cctz/src/tzfile.h b/absl/time/internal/cctz/src/tzfile.h
index 4485ba55e014..ef3feff0c7d8 100644
--- a/absl/time/internal/cctz/src/tzfile.h
+++ b/absl/time/internal/cctz/src/tzfile.h
@@ -33,6 +33,9 @@
 #define TZDEFRULES	"posixrules"
 #endif /* !defined TZDEFRULES */
 
+
+/* See Internet RFC 8536 for more details about the following format.  */
+
 /*
 ** Each file begins with. . .
 */
diff --git a/absl/time/internal/cctz/testdata/version b/absl/time/internal/cctz/testdata/version
index 63f58006ee93..149d790c3d12 100644
--- a/absl/time/internal/cctz/testdata/version
+++ b/absl/time/internal/cctz/testdata/version
@@ -1 +1 @@
-2018i
+2019a
diff --git a/absl/time/internal/cctz/testdata/zoneinfo/America/Metlakatla b/absl/time/internal/cctz/testdata/zoneinfo/America/Metlakatla
index 85a7e16e165d..1e94be3d552e 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/America/Metlakatla
+++ b/absl/time/internal/cctz/testdata/zoneinfo/America/Metlakatla
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Gaza b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Gaza
index cf54deb8f1d4..32b4ed659ef9 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Gaza
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Gaza
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hebron b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hebron
index 09c876a669d3..0ed8b0d4bdad 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hebron
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Hebron
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Jerusalem b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Jerusalem
index 2d14c9998e9d..93e9f19c7cf8 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Jerusalem
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Jerusalem
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Tel_Aviv b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Tel_Aviv
index 2d14c9998e9d..93e9f19c7cf8 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Asia/Tel_Aviv
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Asia/Tel_Aviv
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/Etc/UCT b/absl/time/internal/cctz/testdata/zoneinfo/Etc/UCT
index a88c4b665b3e..5583f5b0c6e6 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Etc/UCT
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Etc/UCT
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/Israel b/absl/time/internal/cctz/testdata/zoneinfo/Israel
index 2d14c9998e9d..93e9f19c7cf8 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/Israel
+++ b/absl/time/internal/cctz/testdata/zoneinfo/Israel
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/UCT b/absl/time/internal/cctz/testdata/zoneinfo/UCT
index a88c4b665b3e..5583f5b0c6e6 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/UCT
+++ b/absl/time/internal/cctz/testdata/zoneinfo/UCT
Binary files differdiff --git a/absl/time/internal/cctz/testdata/zoneinfo/iso3166.tab b/absl/time/internal/cctz/testdata/zoneinfo/iso3166.tab
index 4e4a5c3d1dbf..a4ff61a4d321 100644
--- a/absl/time/internal/cctz/testdata/zoneinfo/iso3166.tab
+++ b/absl/time/internal/cctz/testdata/zoneinfo/iso3166.tab
@@ -9,7 +9,7 @@
 # All text uses UTF-8 encoding.  The columns of the table are as follows:
 #
 # 1.  ISO 3166-1 alpha-2 country code, current as of
-#     ISO 3166-1 N905 (2016-11-15).  See: Updates on ISO 3166-1
+#     ISO 3166-1 N976 (2018-11-06).  See: Updates on ISO 3166-1
 #     https://isotc.iso.org/livelink/livelink/Open/16944257
 # 2.  The usual English name for the coded region,
 #     chosen so that alphabetic sorting of subsets produces helpful lists.
@@ -166,7 +166,7 @@ ME	Montenegro
 MF	St Martin (French)
 MG	Madagascar
 MH	Marshall Islands
-MK	Macedonia
+MK	North Macedonia
 ML	Mali
 MM	Myanmar (Burma)
 MN	Mongolia
@@ -235,7 +235,7 @@ ST	Sao Tome & Principe
 SV	El Salvador
 SX	St Maarten (Dutch)
 SY	Syria
-SZ	Swaziland
+SZ	Eswatini (Swaziland)
 TC	Turks & Caicos Is
 TD	Chad
 TF	French Southern & Antarctic Lands
diff --git a/absl/types/optional_test.cc b/absl/types/optional_test.cc
index 897c183aa762..221c314593ad 100644
--- a/absl/types/optional_test.cc
+++ b/absl/types/optional_test.cc
@@ -1628,7 +1628,6 @@ TEST(optionalTest, AssignmentConstraints) {
   EXPECT_TRUE(absl::is_copy_assignable<absl::optional<AnyLike>>::value);
 }
 
-#if !defined(ABSL_HAVE_STD_OPTIONAL) && !defined(_LIBCPP_VERSION)
 struct NestedClassBug {
   struct Inner {
     bool dummy = false;
@@ -1651,6 +1650,5 @@ TEST(optionalTest, InPlaceTSFINAEBug) {
   o.emplace();
   EXPECT_TRUE(o.has_value());
 }
-#endif  // !defined(ABSL_HAVE_STD_OPTIONAL) && !defined(_LIBCPP_VERSION)
 
 }  // namespace