Skip to content

Commit

Permalink
Use the ABSL_-prefixed Abseil logging macros.
Browse files Browse the repository at this point in the history
This is done primarily for the sake of Chromium,
which bans the unprefixed Abseil logging macros.

I mostly baked the following slices of Perl pie:

```
's,//absl/log:check",//absl/log:absl_check",'
's,//absl/log",//absl/log:absl_log",'
's,"absl/log/check.h","absl/log/absl_check.h",'
's,"absl/log/log.h","absl/log/absl_log.h",'
's,D?CHECK(_(EQ|NE|LE|LT|GE|GT))?\(,ABSL_$&,'
's,V?LOG\(,ABSL_$&,'
```

Change-Id: I65493aff42abab6865f8e2b5b769b6a651dbef3a
Reviewed-on: https://code-review.googlesource.com/c/re2/+/63092
Reviewed-by: Paul Wankadia <[email protected]>
Reviewed-by: Alex Chernyakhovsky <[email protected]>
  • Loading branch information
junyer committed May 20, 2024
1 parent 4f5fd7a commit 630d011
Show file tree
Hide file tree
Showing 49 changed files with 716 additions and 624 deletions.
60 changes: 30 additions & 30 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ cc_library(
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/container:flat_hash_set",
"@abseil-cpp//absl/container:inlined_vector",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/synchronization",
Expand Down Expand Up @@ -135,8 +135,8 @@ cc_library(
"@abseil-cpp//absl/base",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/flags:flag",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
"@googletest//:gtest",
Expand All @@ -163,8 +163,8 @@ cc_test(
deps = [
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -178,8 +178,8 @@ cc_test(
":re2",
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -192,8 +192,8 @@ cc_test(
deps = [
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -206,8 +206,8 @@ cc_test(
deps = [
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -221,8 +221,8 @@ cc_test(
":re2",
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@abseil-cpp//absl/strings",
"@googletest//:gtest",
"@googletest//:gtest_main",
Expand All @@ -237,8 +237,8 @@ cc_test(
":re2",
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -252,8 +252,8 @@ cc_test(
":re2",
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@abseil-cpp//absl/strings:str_format",
"@googletest//:gtest",
"@googletest//:gtest_main",
Expand All @@ -266,8 +266,8 @@ cc_test(
srcs = ["re2/testing/regexp_test.cc"],
deps = [
":testing",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -280,8 +280,8 @@ cc_test(
deps = [
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -306,8 +306,8 @@ cc_test(
deps = [
":re2",
":testing",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -320,8 +320,8 @@ cc_test(
deps = [
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
Expand All @@ -347,8 +347,8 @@ cc_test(
":testing",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/flags:flag",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@abseil-cpp//absl/strings:str_format",
"@googletest//:gtest",
"@googletest//:gtest_main",
Expand Down Expand Up @@ -421,8 +421,8 @@ cc_binary(
":testing",
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/flags:flag",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/log:absl_check",
"@abseil-cpp//absl/log:absl_log",
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/synchronization",
"@google_benchmark//:benchmark_main",
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ if(UNIX)
endif()

set(ABSL_DEPS
absl_absl_check
absl_absl_log
absl_base
absl_check
absl_core_headers
absl_fixed_array
absl_flags
absl_flat_hash_map
absl_flat_hash_set
absl_inlined_vector
absl_log
absl_optional
absl_span
absl_str_format
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

# Build against Abseil.
ABSL_DEPS=\
absl_absl_check\
absl_absl_log\
absl_base\
absl_check\
absl_core_headers\
absl_fixed_array\
absl_flags\
absl_flat_hash_map\
absl_flat_hash_set\
absl_inlined_vector\
absl_log\
absl_optional\
absl_span\
absl_str_format\
Expand Down
8 changes: 4 additions & 4 deletions re2/bitmap256.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include <stdint.h>

#include "absl/base/macros.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"

namespace re2 {

int Bitmap256::FindNextSetBit(int c) const {
DCHECK_GE(c, 0);
DCHECK_LE(c, 255);
ABSL_DCHECK_GE(c, 0);
ABSL_DCHECK_LE(c, 255);

// Check the word that contains the bit. Mask out any lower bits.
int i = c / 64;
Expand Down
14 changes: 7 additions & 7 deletions re2/bitmap256.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <stdint.h>
#include <string.h>

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"

namespace re2 {

Expand All @@ -29,16 +29,16 @@ class Bitmap256 {

// Tests the bit with index c.
bool Test(int c) const {
DCHECK_GE(c, 0);
DCHECK_LE(c, 255);
ABSL_DCHECK_GE(c, 0);
ABSL_DCHECK_LE(c, 255);

return (words_[c / 64] & (uint64_t{1} << (c % 64))) != 0;
}

// Sets the bit with index c.
void Set(int c) {
DCHECK_GE(c, 0);
DCHECK_LE(c, 255);
ABSL_DCHECK_GE(c, 0);
ABSL_DCHECK_LE(c, 255);

words_[c / 64] |= (uint64_t{1} << (c % 64));
}
Expand All @@ -50,7 +50,7 @@ class Bitmap256 {
private:
// Finds the least significant non-zero bit in n.
static int FindLSBSet(uint64_t n) {
DCHECK_NE(n, 0);
ABSL_DCHECK_NE(n, 0);
#if defined(__GNUC__)
return __builtin_ctzll(n);
#elif defined(_MSC_VER) && defined(_M_X64)
Expand Down
14 changes: 7 additions & 7 deletions re2/bitstate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <limits>
#include <utility>

#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "re2/pod_array.h"
#include "re2/prog.h"
#include "re2/regexp.h"
Expand Down Expand Up @@ -108,9 +108,9 @@ void BitState::Push(int id, const char* p) {
if (njob_ >= job_.size()) {
GrowStack();
if (njob_ >= job_.size()) {
LOG(DFATAL) << "GrowStack() failed: "
<< "njob_ = " << njob_ << ", "
<< "job_.size() = " << job_.size();
ABSL_LOG(DFATAL) << "GrowStack() failed: "
<< "njob_ = " << njob_ << ", "
<< "job_.size() = " << job_.size();
return;
}
}
Expand Down Expand Up @@ -168,7 +168,7 @@ bool BitState::TrySearch(int id0, const char* p0) {
Prog::Inst* ip = prog_->inst(id);
switch (ip->opcode()) {
default:
LOG(DFATAL) << "Unexpected opcode: " << ip->opcode();
ABSL_LOG(DFATAL) << "Unexpected opcode: " << ip->opcode();
return false;

case kInstFail:
Expand Down Expand Up @@ -234,7 +234,7 @@ bool BitState::TrySearch(int id0, const char* p0) {
CheckAndLoop:
// Sanity check: id is the head of its list, which must
// be the case if id-1 is the last of *its* list. :)
DCHECK(id == 0 || prog_->inst(id-1)->last());
ABSL_DCHECK(id == 0 || prog_->inst(id-1)->last());
if (ShouldVisit(id, p))
goto Loop;
break;
Expand Down
20 changes: 10 additions & 10 deletions re2/compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#include "absl/base/macros.h"
#include "absl/container/flat_hash_map.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/log/absl_check.h"
#include "absl/log/absl_log.h"
#include "util/utf.h"
#include "re2/pod_array.h"
#include "re2/prog.h"
Expand Down Expand Up @@ -523,8 +523,8 @@ void Compiler::AddSuffix(int id) {
}

int Compiler::AddSuffixRecursive(int root, int id) {
DCHECK(inst_[root].opcode() == kInstAlt ||
inst_[root].opcode() == kInstByteRange);
ABSL_DCHECK(inst_[root].opcode() == kInstAlt ||
inst_[root].opcode() == kInstByteRange);

Frag f = FindByteRange(root, id);
if (IsNoMatch(f)) {
Expand Down Expand Up @@ -566,7 +566,7 @@ int Compiler::AddSuffixRecursive(int root, int id) {
if (!IsCachedRuneByteSuffix(id)) {
// The head should be the instruction most recently allocated, so free it
// instead of leaving it unreachable.
DCHECK_EQ(id, ninst_-1);
ABSL_DCHECK_EQ(id, ninst_-1);
inst_[id].out_opcode_ = 0;
inst_[id].out1_ = 0;
ninst_--;
Expand Down Expand Up @@ -614,7 +614,7 @@ Frag Compiler::FindByteRange(int root, int id) {
return NoMatch();
}

LOG(DFATAL) << "should never happen";
ABSL_LOG(DFATAL) << "should never happen";
return NoMatch();
}

Expand Down Expand Up @@ -739,7 +739,7 @@ void Compiler::AddRuneRangeUTF8(Rune lo, Rune hi, bool foldcase) {
int n = runetochar(reinterpret_cast<char*>(ulo), &lo);
int m = runetochar(reinterpret_cast<char*>(uhi), &hi);
(void)m; // USED(m)
DCHECK_EQ(n, m);
ABSL_DCHECK_EQ(n, m);

// The logic below encodes this thinking:
//
Expand Down Expand Up @@ -792,7 +792,7 @@ void Compiler::AddRuneRangeUTF8(Rune lo, Rune hi, bool foldcase) {
Frag Compiler::Copy(Frag arg) {
// We're using WalkExponential; there should be no copying.
failed_ = true;
LOG(DFATAL) << "Compiler::Copy called!";
ABSL_LOG(DFATAL) << "Compiler::Copy called!";
return NoMatch();
}

Expand Down Expand Up @@ -919,7 +919,7 @@ Frag Compiler::PostVisit(Regexp* re, Frag, Frag, Frag* child_frags,
if (cc->empty()) {
// This can't happen.
failed_ = true;
LOG(DFATAL) << "No ranges in char class";
ABSL_LOG(DFATAL) << "No ranges in char class";
return NoMatch();
}

Expand Down Expand Up @@ -977,7 +977,7 @@ Frag Compiler::PostVisit(Regexp* re, Frag, Frag, Frag* child_frags,
return EmptyWidth(kEmptyNonWordBoundary);
}
failed_ = true;
LOG(DFATAL) << "Missing case in Compiler: " << re->op();
ABSL_LOG(DFATAL) << "Missing case in Compiler: " << re->op();
return NoMatch();
}

Expand Down
Loading

0 comments on commit 630d011

Please sign in to comment.