Fix warnings:

* 'DoNotOptimize<T>' is deprecated: The const-ref version of this method can permit undesired compiler optimizations in benchmarks
* missing #include <string> for 'std::string'

PiperOrigin-RevId: 554936149
Change-Id: Iaf06cd9b9b0762e3a514b7e1cfe4a4fd6df24083
diff --git a/absl/time/civil_time_benchmark.cc b/absl/time/civil_time_benchmark.cc
index f04dbe2..2de0233 100644
--- a/absl/time/civil_time_benchmark.cc
+++ b/absl/time/civil_time_benchmark.cc
@@ -14,7 +14,9 @@
 
 #include "absl/time/civil_time.h"
 
+#include <cstddef>
 #include <numeric>
+#include <string>
 #include <vector>
 
 #include "absl/hash/hash.h"
@@ -42,7 +44,7 @@
   const absl::CivilDay c(2014, 8, 22);
   const absl::CivilDay epoch(1970, 1, 1);
   while (state.KeepRunning()) {
-    const absl::civil_diff_t n = c - epoch;
+    absl::civil_diff_t n = c - epoch;
     benchmark::DoNotOptimize(n);
   }
 }
@@ -60,7 +62,7 @@
 void BM_Format(benchmark::State& state) {
   const absl::CivilSecond c(2014, 1, 2, 3, 4, 5);
   while (state.KeepRunning()) {
-    const std::string s = absl::FormatCivilTime(c);
+    std::string s = absl::FormatCivilTime(c);
     benchmark::DoNotOptimize(s);
   }
 }
@@ -70,7 +72,7 @@
   const std::string f = "2014-01-02T03:04:05";
   absl::CivilSecond c;
   while (state.KeepRunning()) {
-    const bool b = absl::ParseCivilTime(f, &c);
+    bool b = absl::ParseCivilTime(f, &c);
     benchmark::DoNotOptimize(b);
   }
 }
@@ -80,7 +82,7 @@
   const absl::CivilSecond c(2014, 1, 2, 3, 4, 5);
   absl::CivilSecond out;
   while (state.KeepRunning()) {
-    const bool b = absl::ParseCivilTime(absl::FormatCivilTime(c), &out);
+    bool b = absl::ParseCivilTime(absl::FormatCivilTime(c), &out);
     benchmark::DoNotOptimize(b);
   }
 }
@@ -95,7 +97,8 @@
   absl::Hash<T> absl_hasher;
   while (state.KeepRunningBatch(kSize)) {
     for (const T civil_time : civil_times) {
-      benchmark::DoNotOptimize(absl_hasher(civil_time));
+      size_t hash = absl_hasher(civil_time);
+      benchmark::DoNotOptimize(hash);
     }
   }
 }