re2: churn to new Abseil
Recent Abseil introduced a MutexLock constructor taking a
reference instead of a pointer and then immediately marked
the pointer one deprecated, causing deprecation errors/warnings
for users. Update to the new Abseil and change to references.
Change-Id: Id9436a79789b5700bbe883f4ee1de99b32e0d3e1
Reviewed-on: https://code-review.googlesource.com/c/re2/+/64030
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81b4af2..7e9fa56 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,7 +87,7 @@
# indirectly), let that take precedence over any copy of Abseil that might have
# been installed on the system. And likewise for ICU, GoogleTest and Benchmark.
if(NOT TARGET absl::base)
- find_package(absl REQUIRED)
+ find_package(absl 20250814 REQUIRED)
endif()
list(APPEND REQUIRES ${ABSL_DEPS})
diff --git a/MODULE.bazel b/MODULE.bazel
index 1caf578..e6f3a84 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -12,8 +12,8 @@
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "apple_support", version = "1.22.1")
-bazel_dep(name = "rules_cc", version = "0.1.4")
-bazel_dep(name = "abseil-cpp", version = "20250512.1")
+bazel_dep(name = "rules_cc", version = "0.2.0")
+bazel_dep(name = "abseil-cpp", version = "20250814.1")
bazel_dep(name = "rules_python", version = "1.5.1")
bazel_dep(name = "pybind11_bazel", version = "2.13.6")
diff --git a/re2/dfa.cc b/re2/dfa.cc
index 712a7b6..d587a55 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -1015,7 +1015,7 @@
DFA::State* DFA::RunStateOnByteUnlocked(State* state, int c) {
// Keep only one RunStateOnByte going
// even if the DFA is being run by multiple threads.
- absl::MutexLock l(&mutex_);
+ absl::MutexLock l(mutex_);
return RunStateOnByte(state, c);
}
@@ -1267,7 +1267,7 @@
DFA::State* DFA::StateSaver::Restore() {
if (is_special_)
return special_;
- absl::MutexLock l(&dfa_->mutex_);
+ absl::MutexLock l(dfa_->mutex_);
State* s = dfa_->CachedState(inst_, ninst_, flag_);
if (s == NULL)
ABSL_LOG(DFATAL) << "StateSaver failed to restore state.";
@@ -1730,7 +1730,7 @@
if (start != NULL)
return true;
- absl::MutexLock l(&mutex_);
+ absl::MutexLock l(mutex_);
start = info->start.load(std::memory_order_relaxed);
if (start != NULL)
return true;
@@ -2050,7 +2050,7 @@
// Build minimum prefix.
State* s = params.start;
min->clear();
- absl::MutexLock lock(&mutex_);
+ absl::MutexLock lock(mutex_);
for (int i = 0; i < maxlen; i++) {
if (previously_visited_states[s] > kMaxEltRepetitions)
break;
diff --git a/re2/regexp.cc b/re2/regexp.cc
index f7e5ba2..54955c1 100644
--- a/re2/regexp.cc
+++ b/re2/regexp.cc
@@ -95,7 +95,7 @@
if (ref_ < kMaxRef)
return ref_;
- absl::MutexLock l(ref_mutex());
+ absl::MutexLock l(*ref_mutex());
return (*ref_map())[this];
}
@@ -108,7 +108,7 @@
});
// Store ref count in overflow map.
- absl::MutexLock l(ref_mutex());
+ absl::MutexLock l(*ref_mutex());
if (ref_ == kMaxRef) {
// already overflowed
(*ref_map())[this]++;
@@ -128,7 +128,7 @@
void Regexp::Decref() {
if (ref_ == kMaxRef) {
// Ref count is stored in overflow map.
- absl::MutexLock l(ref_mutex());
+ absl::MutexLock l(*ref_mutex());
int r = (*ref_map())[this] - 1;
if (r < kMaxRef) {
ref_ = static_cast<uint16_t>(r);
diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc
index 3b0a533..3940467 100644
--- a/re2/testing/regexp_benchmark.cc
+++ b/re2/testing/regexp_benchmark.cc
@@ -964,7 +964,7 @@
Prog* GetCachedProg(const char* regexp) {
static auto& mutex = *new absl::Mutex;
- absl::MutexLock lock(&mutex);
+ absl::MutexLock lock(mutex);
static auto& cache = *new absl::flat_hash_map<std::string, Prog*>;
Prog* prog = cache[regexp];
if (prog == NULL) {
@@ -982,7 +982,7 @@
PCRE* GetCachedPCRE(const char* regexp) {
static auto& mutex = *new absl::Mutex;
- absl::MutexLock lock(&mutex);
+ absl::MutexLock lock(mutex);
static auto& cache = *new absl::flat_hash_map<std::string, PCRE*>;
PCRE* re = cache[regexp];
if (re == NULL) {
@@ -995,7 +995,7 @@
RE2* GetCachedRE2(const char* regexp) {
static auto& mutex = *new absl::Mutex;
- absl::MutexLock lock(&mutex);
+ absl::MutexLock lock(mutex);
static auto& cache = *new absl::flat_hash_map<std::string, RE2*>;
RE2* re = cache[regexp];
if (re == NULL) {