about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--absl/base/internal/inline_variable.h30
-rw-r--r--absl/base/internal/malloc_hook.h7
-rw-r--r--absl/base/internal/malloc_hook_c.h1
-rw-r--r--absl/base/internal/spinlock.h2
-rw-r--r--absl/container/fixed_array.h8
-rw-r--r--absl/container/fixed_array_test.cc1
-rw-r--r--absl/synchronization/mutex.cc5
-rw-r--r--absl/synchronization/mutex.h4
-rw-r--r--absl/synchronization/mutex_test.cc10
-rw-r--r--absl/types/BUILD.bazel2
-rw-r--r--absl/types/any.h1
12 files changed, 48 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c65805ebdfbd..9d3262393317 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,7 +33,7 @@ if (MSVC)
   # /wd4267  conversion from 'size_t' to 'type2'
   # /wd4800  force value to bool 'true' or 'false' (performance warning)
   add_compile_options(/W3 /WX /wd4005 /wd4068 /wd4244 /wd4267 /wd4800)
-  add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS)
+  add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS)
 else()
   set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)")
 endif()
diff --git a/absl/base/internal/inline_variable.h b/absl/base/internal/inline_variable.h
index f7bb8c56525d..a65fe89354cb 100644
--- a/absl/base/internal/inline_variable.h
+++ b/absl/base/internal/inline_variable.h
@@ -53,7 +53,24 @@
 //   it will likely be a reference type).
 ////////////////////////////////////////////////////////////////////////////////
 
-#ifdef __cpp_inline_variables
+// ABSL_INTERNAL_HAS_WARNING()
+//
+// If the compiler supports the `__has_warning` extension for detecting
+// warnings, then this macro is defined to be `__has_warning`.
+//
+// If the compiler does not support `__has_warning`, invocations expand to 0.
+//
+// For clang's documentation of `__has_warning`, see
+// https://clang.llvm.org/docs/LanguageExtensions.html#has-warning
+#if defined(__has_warning)
+#define ABSL_INTERNAL_HAS_WARNING __has_warning
+#else  // Otherwise, be optimistic and assume the warning is not enabled.
+#define ABSL_INTERNAL_HAS_WARNING(warning) 0
+#endif  // defined(__has_warning)
+
+// If the compiler supports inline variables and does not warn when used...
+#if defined(__cpp_inline_variables) && \
+    !ABSL_INTERNAL_HAS_WARNING("-Wc++98-c++11-c++14-compat")
 
 // Clang's -Wmissing-variable-declarations option erroneously warned that
 // inline constexpr objects need to be pre-declared. This has now been fixed,
@@ -66,19 +83,21 @@
 //   identity_t is used here so that the const and name are in the
 //   appropriate place for pointer types, reference types, function pointer
 //   types, etc..
-#if defined(__clang__)
+#if defined(__clang__) && \
+    ABSL_INTERNAL_HAS_WARNING("-Wmissing-variable-declarations")
 #define ABSL_INTERNAL_EXTERN_DECL(type, name) \
   extern const ::absl::internal::identity_t<type> name;
 #else  // Otherwise, just define the macro to do nothing.
 #define ABSL_INTERNAL_EXTERN_DECL(type, name)
-#endif  // defined(__clang__)
+#endif  // defined(__clang__) &&
+        // ABSL_INTERNAL_HAS_WARNING("-Wmissing-variable-declarations")
 
 // See above comment at top of file for details.
 #define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \
   ABSL_INTERNAL_EXTERN_DECL(type, name)                  \
   inline constexpr ::absl::internal::identity_t<type> name = init
 
-#else
+#else  // Otherwise, we need to emulate inline variables...
 
 // See above comment at top of file for details.
 //
@@ -102,6 +121,7 @@
   static_assert(sizeof(void (*)(decltype(name))) != 0,                        \
                 "Silence unused variable warnings.")
 
-#endif  // __cpp_inline_variables
+#endif  // defined(__cpp_inline_variables) &&
+        // !ABSL_INTERNAL_HAS_WARNING("-Wc++98-c++11-c++14-compat")
 
 #endif  // ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_
diff --git a/absl/base/internal/malloc_hook.h b/absl/base/internal/malloc_hook.h
index 7c1eaddb70ec..6b006edac6d4 100644
--- a/absl/base/internal/malloc_hook.h
+++ b/absl/base/internal/malloc_hook.h
@@ -91,8 +91,11 @@ class MallocHook {
   // SampledAlloc has the following fields:
   //  * AllocHandle handle: to be set to an effectively unique value (in this
   //    process) by allocator.
-  //  * size_t allocated_size: space actually used by allocator to host
-  //    the object.
+  //  * size_t allocated_size: space actually used by allocator to host the
+  //    object. Not necessarily equal to the requested size due to alignment
+  //    and other reasons.
+  //  * double weight: the expected number of allocations matching this profile
+  //    that this sample represents.
   //  * int stack_depth and const void* stack: invocation stack for
   //    the allocation.
   // The allocator invoking the hook should record the handle value and later
diff --git a/absl/base/internal/malloc_hook_c.h b/absl/base/internal/malloc_hook_c.h
index ed41143a2020..7255ddc22900 100644
--- a/absl/base/internal/malloc_hook_c.h
+++ b/absl/base/internal/malloc_hook_c.h
@@ -37,6 +37,7 @@ typedef struct {
   /* See malloc_hook.h  for documentation for this struct. */
   MallocHook_AllocHandle handle;
   size_t allocated_size;
+  double weight;
   int stack_depth;
   const void* stack;
 } MallocHook_SampledAlloc;
diff --git a/absl/base/internal/spinlock.h b/absl/base/internal/spinlock.h
index a9037e3ed05c..212abc669e62 100644
--- a/absl/base/internal/spinlock.h
+++ b/absl/base/internal/spinlock.h
@@ -227,7 +227,7 @@ inline uint32_t SpinLock::TryLockInternal(uint32_t lock_value,
           kSpinLockHeld | lock_value | wait_cycles | sched_disabled_bit,
           std::memory_order_acquire, std::memory_order_relaxed)) {
   } else {
-    base_internal::SchedulingGuard::EnableRescheduling(sched_disabled_bit);
+    base_internal::SchedulingGuard::EnableRescheduling(sched_disabled_bit != 0);
   }
 
   return lock_value;
diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h
index 1fec9d2b3784..b92d90564d21 100644
--- a/absl/container/fixed_array.h
+++ b/absl/container/fixed_array.h
@@ -458,7 +458,7 @@ class FixedArray {
       // Loop optimizes to nothing for trivially destructible T.
       for (Holder* p = end(); p != begin();) (--p)->~Holder();
       if (IsAllocated(size())) {
-        ::operator delete[](begin());
+        std::allocator<Holder>().deallocate(p_, n_);
       } else {
         this->AnnotateDestruct(size());
       }
@@ -470,17 +470,13 @@ class FixedArray {
    private:
     Holder* MakeHolder(size_type n) {
       if (IsAllocated(n)) {
-        return Allocate(n);
+        return std::allocator<Holder>().allocate(n);
       } else {
         this->AnnotateConstruct(n);
         return this->data();
       }
     }
 
-    Holder* Allocate(size_type n) {
-      return static_cast<Holder*>(::operator new[](n * sizeof(Holder)));
-    }
-
     bool IsAllocated(size_type n) const { return n > inline_elements; }
 
     const size_type n_;
diff --git a/absl/container/fixed_array_test.cc b/absl/container/fixed_array_test.cc
index b6782f517a6c..2142132d1352 100644
--- a/absl/container/fixed_array_test.cc
+++ b/absl/container/fixed_array_test.cc
@@ -504,6 +504,7 @@ struct PickyDelete {
 
 TEST(FixedArrayTest, UsesGlobalAlloc) { absl::FixedArray<PickyDelete, 0> a(5); }
 
+
 TEST(FixedArrayTest, Data) {
   static const int kInput[] = { 2, 3, 5, 7, 11, 13, 17 };
   absl::FixedArray<int> fa(std::begin(kInput), std::end(kInput));
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc
index 06a058cf710b..33f92d8fabba 100644
--- a/absl/synchronization/mutex.cc
+++ b/absl/synchronization/mutex.cc
@@ -48,7 +48,6 @@
 #include "absl/base/internal/spinlock.h"
 #include "absl/base/internal/sysinfo.h"
 #include "absl/base/internal/thread_identity.h"
-#include "absl/base/internal/tsan_mutex_interface.h"
 #include "absl/base/port.h"
 #include "absl/debugging/stacktrace.h"
 #include "absl/synchronization/internal/graphcycles.h"
@@ -687,10 +686,6 @@ static unsigned TsanFlags(Mutex::MuHow how) {
 }
 #endif
 
-Mutex::Mutex() : mu_(0) {
-  ABSL_TSAN_MUTEX_CREATE(this, __tsan_mutex_not_static);
-}
-
 static bool DebugOnlyIsExiting() {
   return false;
 }
diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h
index b09802b523bc..374cf57d2e94 100644
--- a/absl/synchronization/mutex.h
+++ b/absl/synchronization/mutex.h
@@ -64,6 +64,7 @@
 #include "absl/base/internal/identity.h"
 #include "absl/base/internal/low_level_alloc.h"
 #include "absl/base/internal/thread_identity.h"
+#include "absl/base/internal/tsan_mutex_interface.h"
 #include "absl/base/port.h"
 #include "absl/base/thread_annotations.h"
 #include "absl/synchronization/internal/kernel_timeout.h"
@@ -860,6 +861,9 @@ class SCOPED_LOCKABLE ReleasableMutexLock {
 
 #ifdef ABSL_INTERNAL_USE_NONPROD_MUTEX
 #else
+inline Mutex::Mutex() : mu_(0) {
+  ABSL_TSAN_MUTEX_CREATE(this, __tsan_mutex_not_static);
+}
 
 inline CondVar::CondVar() : cv_(0) {}
 #endif
diff --git a/absl/synchronization/mutex_test.cc b/absl/synchronization/mutex_test.cc
index 5a5874def72d..53b937843a34 100644
--- a/absl/synchronization/mutex_test.cc
+++ b/absl/synchronization/mutex_test.cc
@@ -1234,10 +1234,12 @@ static void CheckResults(bool exp_result, bool act_result,
                          absl::Duration act_duration) {
   ABSL_RAW_CHECK(exp_result == act_result, "CheckResults failed");
   // Allow for some worse-case scheduling delay and clock skew.
-  ABSL_RAW_CHECK(exp_duration - absl::Milliseconds(40) <= act_duration,
-                 "CheckResults failed");
-  ABSL_RAW_CHECK(exp_duration + absl::Milliseconds(150) >= act_duration,
-                 "CheckResults failed");
+  if ((exp_duration - absl::Milliseconds(40) > act_duration) ||
+      (exp_duration + absl::Milliseconds(150) < act_duration)) {
+    ABSL_RAW_LOG(FATAL, "CheckResults failed: operation took %s, expected %s",
+                 absl::FormatDuration(act_duration).c_str(),
+                 absl::FormatDuration(exp_duration).c_str());
+  }
 }
 
 static void TestAwaitTimeout(Cond *cp, absl::Duration timeout, bool exp_result,
diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel
index 60d6a60fa881..c2f033870ab0 100644
--- a/absl/types/BUILD.bazel
+++ b/absl/types/BUILD.bazel
@@ -110,7 +110,7 @@ cc_test(
     name = "span_test",
     size = "small",
     srcs = ["span_test.cc"],
-    copts = ABSL_TEST_COPTS + ["-fexceptions"],
+    copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
     deps = [
         ":span",
         "//absl/base:config",
diff --git a/absl/types/any.h b/absl/types/any.h
index 2e7bf21f55f6..cee9cd324fc9 100644
--- a/absl/types/any.h
+++ b/absl/types/any.h
@@ -373,6 +373,7 @@ class any {
     return typeid(void);
   }
 #endif  // ABSL_ANY_DETAIL_HAS_RTTI
+
  private:
   // Tagged type-erased abstraction for holding a cloneable object.
   class ObjInterface {