Remove ALLOW_UNUSED_LOCAL from Crashpad

Bug: 1286390
Change-Id: I9755258960c55bef84e01812a14067ffaf89d2b1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3388879
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/DEPS b/DEPS
index 73adbd4..8f9617f 100644
--- a/DEPS
+++ b/DEPS
@@ -39,7 +39,7 @@
       'e1e7b0ad8ee99a875b272c8e33e308472e897660',
   'crashpad/third_party/mini_chromium/mini_chromium':
       Var('chromium_git') + '/chromium/mini_chromium@' +
-      'bbb68fcec19ff7c268fadeebd2ef79f7203fa2f2',
+      'c2bc7a2a195eb8940215d0b81767f022aa5ecfdd',
   'crashpad/third_party/libfuzzer/src':
       Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' +
       'fda403cf93ecb8792cb1d061564d89a6553ca020',
diff --git a/handler/handler_main.cc b/handler/handler_main.cc
index 5733463..5e8ff1a 100644
--- a/handler/handler_main.cc
+++ b/handler/handler_main.cc
@@ -28,7 +28,6 @@
 #include <vector>
 
 #include "base/auto_reset.h"
-#include "base/compiler_specific.h"
 #include "base/files/file_path.h"
 #include "base/files/scoped_file.h"
 #include "base/logging.h"
@@ -252,11 +251,10 @@
 // a normal exit, or if a CallMetricsRecordNormalExit object is destroyed after
 // something else logs an exit event.
 void MetricsRecordExit(Metrics::LifetimeMilestone milestone) {
-  static bool once = [](Metrics::LifetimeMilestone milestone) {
+  [[maybe_unused]] static bool once = [](Metrics::LifetimeMilestone milestone) {
     Metrics::HandlerLifetimeMilestone(milestone);
     return true;
   }(milestone);
-  ALLOW_UNUSED_LOCAL(once);
 }
 
 // Calls MetricsRecordExit() to record a failure, and returns EXIT_FAILURE for
@@ -422,8 +420,8 @@
   // enough. Note that destroying the TerminateHandler would wait for its thread
   // to exit, which isn’t necessary or desirable.
   SetConsoleCtrlHandler(ConsoleHandler, true);
-  static TerminateHandler* terminate_handler = new TerminateHandler();
-  ALLOW_UNUSED_LOCAL(terminate_handler);
+  [[maybe_unused]] static TerminateHandler* terminate_handler =
+      new TerminateHandler();
 }
 
 #endif  // OS_APPLE
diff --git a/minidump/minidump_misc_info_writer_test.cc b/minidump/minidump_misc_info_writer_test.cc
index 18ac296..f74d0bd 100644
--- a/minidump/minidump_misc_info_writer_test.cc
+++ b/minidump/minidump_misc_info_writer_test.cc
@@ -19,7 +19,6 @@
 #include <string>
 #include <utility>
 
-#include "base/compiler_specific.h"
 #include "base/cxx17_backports.h"
 #include "base/format_macros.h"
 #include "base/strings/stringprintf.h"
@@ -436,8 +435,7 @@
 
   constexpr uint32_t kTimeZoneId = 2;
   constexpr int32_t kBias = 300;
-  MINIDUMP_MISC_INFO_N tmp;
-  ALLOW_UNUSED_LOCAL(tmp);
+  [[maybe_unused]] MINIDUMP_MISC_INFO_N tmp;
   std::string standard_name(base::size(tmp.TimeZone.StandardName) + 1, 's');
   constexpr int32_t kStandardBias = 0;
   std::string daylight_name(base::size(tmp.TimeZone.DaylightName), 'd');
@@ -528,8 +526,7 @@
   MinidumpFileWriter minidump_file_writer;
   auto misc_info_writer = std::make_unique<MinidumpMiscInfoWriter>();
 
-  MINIDUMP_MISC_INFO_N tmp;
-  ALLOW_UNUSED_LOCAL(tmp);
+  [[maybe_unused]] MINIDUMP_MISC_INFO_N tmp;
   std::string build_string(base::size(tmp.BuildString) + 1, 'B');
   std::string debug_build_string(base::size(tmp.DbgBldStr), 'D');
 
diff --git a/minidump/minidump_string_writer_test.cc b/minidump/minidump_string_writer_test.cc
index bfaf3a9..9609ade 100644
--- a/minidump/minidump_string_writer_test.cc
+++ b/minidump/minidump_string_writer_test.cc
@@ -16,7 +16,6 @@
 
 #include <string>
 
-#include "base/compiler_specific.h"
 #include "base/cxx17_backports.h"
 #include "base/format_macros.h"
 #include "base/strings/stringprintf.h"
@@ -86,8 +85,7 @@
 
     const size_t expected_utf16_units_with_nul =
         kTestData[index].output_length + 1;
-    MINIDUMP_STRING* tmp;
-    ALLOW_UNUSED_LOCAL(tmp);
+    [[maybe_unused]] MINIDUMP_STRING* tmp;
     const size_t expected_utf16_bytes =
         expected_utf16_units_with_nul * sizeof(tmp->Buffer[0]);
     ASSERT_EQ(string_file.string().size(), sizeof(*tmp) + expected_utf16_bytes);
@@ -130,8 +128,7 @@
     const MINIDUMP_STRING* minidump_string =
         MinidumpStringAtRVA(string_file.string(), 0);
     EXPECT_TRUE(minidump_string);
-    MINIDUMP_STRING* tmp;
-    ALLOW_UNUSED_LOCAL(tmp);
+    [[maybe_unused]] MINIDUMP_STRING* tmp;
     EXPECT_EQ(
         minidump_string->Length,
         string_file.string().size() - sizeof(*tmp) - sizeof(tmp->Buffer[0]));
diff --git a/minidump/minidump_system_info_writer_test.cc b/minidump/minidump_system_info_writer_test.cc
index 206a8e4..81de730 100644
--- a/minidump/minidump_system_info_writer_test.cc
+++ b/minidump/minidump_system_info_writer_test.cc
@@ -20,7 +20,6 @@
 #include <string>
 #include <utility>
 
-#include "base/compiler_specific.h"
 #include "gtest/gtest.h"
 #include "minidump/minidump_file_writer.h"
 #include "minidump/test/minidump_file_writer_test_util.h"
@@ -39,8 +38,7 @@
                          const MINIDUMP_SYSTEM_INFO** system_info,
                          const MINIDUMP_STRING** csd_version) {
   // The expected number of bytes for the CSD version’s MINIDUMP_STRING::Buffer.
-  MINIDUMP_STRING* tmp;
-  ALLOW_UNUSED_LOCAL(tmp);
+  [[maybe_unused]] MINIDUMP_STRING* tmp;
   const size_t kCSDVersionBytes = csd_version_length * sizeof(tmp->Buffer[0]);
   const size_t kCSDVersionBytesWithNUL =
       kCSDVersionBytes + sizeof(tmp->Buffer[0]);
diff --git a/util/misc/arraysize_test.cc b/util/misc/arraysize_test.cc
index ad8da09..5a2106a 100644
--- a/util/misc/arraysize_test.cc
+++ b/util/misc/arraysize_test.cc
@@ -14,7 +14,6 @@
 
 #include "util/misc/arraysize.h"
 
-#include "base/compiler_specific.h"
 #include "gtest/gtest.h"
 
 namespace crashpad {
@@ -22,37 +21,29 @@
 namespace {
 
 TEST(ArraySize, ArraySize) {
-  char c1[1];
+  [[maybe_unused]] char c1[1];
   static_assert(ArraySize(c1) == 1, "c1");
-  ALLOW_UNUSED_LOCAL(c1);
 
-  char c2[2];
+  [[maybe_unused]] char c2[2];
   static_assert(ArraySize(c2) == 2, "c2");
-  ALLOW_UNUSED_LOCAL(c2);
 
-  char c4[4];
+  [[maybe_unused]] char c4[4];
   static_assert(ArraySize(c4) == 4, "c4");
-  ALLOW_UNUSED_LOCAL(c4);
 
-  int i1[1];
+  [[maybe_unused]] int i1[1];
   static_assert(ArraySize(i1) == 1, "i1");
-  ALLOW_UNUSED_LOCAL(i1);
 
-  int i2[2];
+  [[maybe_unused]] int i2[2];
   static_assert(ArraySize(i2) == 2, "i2");
-  ALLOW_UNUSED_LOCAL(i2);
 
-  int i4[4];
+  [[maybe_unused]] int i4[4];
   static_assert(ArraySize(i4) == 4, "i4");
-  ALLOW_UNUSED_LOCAL(i4);
 
-  long l8[8];
+  [[maybe_unused]] long l8[8];
   static_assert(ArraySize(l8) == 8, "l8");
-  ALLOW_UNUSED_LOCAL(l8);
 
-  int l9[9];
+  [[maybe_unused]] int l9[9];
   static_assert(ArraySize(l9) == 9, "l9");
-  ALLOW_UNUSED_LOCAL(l9);
 
   struct S {
     char c;
@@ -61,13 +52,11 @@
     bool b;
   };
 
-  S s1[1];
+  [[maybe_unused]] S s1[1];
   static_assert(ArraySize(s1) == 1, "s1");
-  ALLOW_UNUSED_LOCAL(s1);
 
-  S s10[10];
+  [[maybe_unused]] S s10[10];
   static_assert(ArraySize(s10) == 10, "s10");
-  ALLOW_UNUSED_LOCAL(s10);
 }
 
 }  // namespace
diff --git a/util/misc/initialization_state_dcheck.h b/util/misc/initialization_state_dcheck.h
index e04ff23..51220d5 100644
--- a/util/misc/initialization_state_dcheck.h
+++ b/util/misc/initialization_state_dcheck.h
@@ -17,8 +17,9 @@
 
 //! \file
 
+#include <tuple>
+
 #include "base/check_op.h"
-#include "base/compiler_specific.h"
 #include "build/build_config.h"
 #include "util/misc/initialization_state.h"
 
@@ -175,11 +176,11 @@
 // Avoid triggering warnings by repurposing these macros when DCHECKs are
 // disabled.
 #define INITIALIZATION_STATE_SET_INITIALIZING(initialization_state_dcheck) \
-  ALLOW_UNUSED_LOCAL(initialization_state_dcheck)
+  do { std::ignore = initialization_state_dcheck; } while (false)
 #define INITIALIZATION_STATE_SET_VALID(initialization_state_dcheck) \
-  ALLOW_UNUSED_LOCAL(initialization_state_dcheck)
+  do { std::ignore = initialization_state_dcheck; } while (false)
 #define INITIALIZATION_STATE_DCHECK_VALID(initialization_state_dcheck) \
-  ALLOW_UNUSED_LOCAL(initialization_state_dcheck)
+  do { std::ignore = initialization_state_dcheck; } while (false)
 
 #endif
 
diff --git a/util/misc/scoped_forbid_return_test.cc b/util/misc/scoped_forbid_return_test.cc
index 06cb549..b728cf4 100644
--- a/util/misc/scoped_forbid_return_test.cc
+++ b/util/misc/scoped_forbid_return_test.cc
@@ -14,7 +14,6 @@
 
 #include "util/misc/scoped_forbid_return.h"
 
-#include "base/compiler_specific.h"
 #include "gtest/gtest.h"
 #include "test/gtest_death.h"
 
@@ -43,13 +42,12 @@
   }
 }
 
-constexpr char kForbiddenMessage[] = "attempt to exit scope forbidden";
+// kForbiddenMessage may appear to be unused if ASSERT_DEATH_CHECK() throws it
+// away.
+[[maybe_unused]] constexpr char kForbiddenMessage[] =
+    "attempt to exit scope forbidden";
 
 TEST(ScopedForbidReturnDeathTest, Default) {
-  // kForbiddenMessage may appear to be unused if ASSERT_DEATH_CHECK() throws it
-  // away.
-  ALLOW_UNUSED_LOCAL(kForbiddenMessage);
-
   ASSERT_DEATH_CHECK(ScopedForbidReturnHelper(kForbidReturnDefault),
                      kForbiddenMessage);
 }
diff --git a/util/posix/signals_test.cc b/util/posix/signals_test.cc
index cb29ff5..769483c 100644
--- a/util/posix/signals_test.cc
+++ b/util/posix/signals_test.cc
@@ -22,7 +22,6 @@
 
 #include <limits>
 
-#include "base/compiler_specific.h"
 #include "base/cxx17_backports.h"
 #include "base/files/scoped_file.h"
 #include "base/logging.h"
@@ -163,10 +162,9 @@
  * Arm architecture.
  */
 #if defined(ARCH_CPU_X86_FAMILY)
-      volatile int a = 42;
+      [[maybe_unused]] volatile int a = 42;
       volatile int b = 0;
       a /= b;
-      ALLOW_UNUSED_LOCAL(a);
 #endif
       break;
     }
diff --git a/util/stdlib/aligned_allocator_test.cc b/util/stdlib/aligned_allocator_test.cc
index 1c16dcc..e44494b 100644
--- a/util/stdlib/aligned_allocator_test.cc
+++ b/util/stdlib/aligned_allocator_test.cc
@@ -16,7 +16,6 @@
 
 #include <stdint.h>
 
-#include "base/compiler_specific.h"
 #include "gtest/gtest.h"
 #include "test/gtest_death.h"
 
@@ -93,12 +92,10 @@
 void BadAlignmentTest() {
 #if defined(OS_WIN)
   // Suppress the assertion MessageBox() normally displayed by the CRT in debug
-  // mode.
-  int previous = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
-
-  // In release mode, _CrtSetReportMode() is #defined to ((int)0), so |previous|
-  // would appear unused.
-  ALLOW_UNUSED_LOCAL(previous);
+  // mode. In release mode, _CrtSetReportMode() is #defined to ((int)0), so
+  // |previous| would appear unused, thus the [[maybe_unused]].
+  [[maybe_unused]] int previous =
+      _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
 #endif
 
   // Alignment constraints must be powers of 2. 7 is not valid.