From 630d0115f2d14a93472703079fb0ab4dd12270b9 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Sat, 18 May 2024 11:09:29 +0000 Subject: [PATCH] Use the `ABSL_`-prefixed Abseil logging macros. 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 Reviewed-by: Alex Chernyakhovsky --- BUILD.bazel | 60 ++--- CMakeLists.txt | 4 +- Makefile | 4 +- re2/bitmap256.cc | 8 +- re2/bitmap256.h | 14 +- re2/bitstate.cc | 14 +- re2/compile.cc | 20 +- re2/dfa.cc | 40 ++-- re2/filtered_re2.cc | 12 +- re2/mimics_pcre.cc | 8 +- re2/nfa.cc | 36 +-- re2/onepass.cc | 28 +-- re2/parse.cc | 22 +- re2/prefilter.cc | 24 +- re2/prefilter.h | 6 +- re2/prefilter_tree.cc | 34 +-- re2/prefilter_tree.h | 10 +- re2/prog.cc | 48 ++-- re2/prog.h | 56 +++-- re2/re2.cc | 90 ++++---- re2/re2.h | 35 +-- re2/regexp.cc | 22 +- re2/regexp.h | 51 ++++- re2/set.cc | 22 +- re2/simplify.cc | 19 +- re2/testing/backtrack.cc | 14 +- re2/testing/compile_test.cc | 14 +- re2/testing/dfa_test.cc | 23 +- re2/testing/dump.cc | 8 +- re2/testing/exhaustive_tester.cc | 10 +- re2/testing/filtered_re2_test.cc | 18 +- re2/testing/mimics_pcre_test.cc | 4 +- re2/testing/null_walker.cc | 6 +- re2/testing/parse_test.cc | 6 +- re2/testing/possible_match_test.cc | 15 +- re2/testing/re2_arg_test.cc | 8 +- re2/testing/re2_test.cc | 10 +- re2/testing/regexp_benchmark.cc | 338 +++++++++++++++------------- re2/testing/regexp_generator.cc | 12 +- re2/testing/regexp_test.cc | 4 +- re2/testing/required_prefix_test.cc | 4 +- re2/testing/set_test.cc | 4 +- re2/testing/simplify_test.cc | 6 +- re2/testing/string_generator.cc | 14 +- re2/testing/tester.cc | 81 +++---- re2/tostring.cc | 8 +- re2/walker-inl.h | 8 +- util/pcre.cc | 6 +- util/pcre.h | 32 +-- 49 files changed, 716 insertions(+), 624 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index dcb096953..f1ceaedf1 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", @@ -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", @@ -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", ], @@ -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", ], @@ -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", ], @@ -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", ], @@ -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", @@ -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", ], @@ -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", @@ -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", ], @@ -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", ], @@ -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", ], @@ -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", ], @@ -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", @@ -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", diff --git a/CMakeLists.txt b/CMakeLists.txt index 36e7e7156..2f8a1c77c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Makefile b/Makefile index 51a1034d0..887d82d29 100644 --- a/Makefile +++ b/Makefile @@ -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\ diff --git a/re2/bitmap256.cc b/re2/bitmap256.cc index e455fde76..fe2ba7e4a 100644 --- a/re2/bitmap256.cc +++ b/re2/bitmap256.cc @@ -7,14 +7,14 @@ #include #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; diff --git a/re2/bitmap256.h b/re2/bitmap256.h index 29e2984a0..45913a615 100644 --- a/re2/bitmap256.h +++ b/re2/bitmap256.h @@ -11,8 +11,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" namespace re2 { @@ -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)); } @@ -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) diff --git a/re2/bitstate.cc b/re2/bitstate.cc index cac8aa0af..e69c1067e 100644 --- a/re2/bitstate.cc +++ b/re2/bitstate.cc @@ -23,8 +23,8 @@ #include #include -#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" @@ -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; } } @@ -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: @@ -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; diff --git a/re2/compile.cc b/re2/compile.cc index 17e31481b..ce3c32e23 100644 --- a/re2/compile.cc +++ b/re2/compile.cc @@ -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" @@ -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)) { @@ -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_--; @@ -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(); } @@ -739,7 +739,7 @@ void Compiler::AddRuneRangeUTF8(Rune lo, Rune hi, bool foldcase) { int n = runetochar(reinterpret_cast(ulo), &lo); int m = runetochar(reinterpret_cast(uhi), &hi); (void)m; // USED(m) - DCHECK_EQ(n, m); + ABSL_DCHECK_EQ(n, m); // The logic below encodes this thinking: // @@ -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(); } @@ -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(); } @@ -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(); } diff --git a/re2/dfa.cc b/re2/dfa.cc index 9b8a43758..808f87242 100644 --- a/re2/dfa.cc +++ b/re2/dfa.cc @@ -38,8 +38,8 @@ #include "absl/base/thread_annotations.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "absl/types/span.h" @@ -150,15 +150,15 @@ class DFA { struct StateHash { size_t operator()(const State* a) const { - DCHECK(a != NULL); + ABSL_DCHECK(a != NULL); return absl::Hash()(*a); } }; struct StateEqual { bool operator()(const State* a, const State* b) const { - DCHECK(a != NULL); - DCHECK(b != NULL); + ABSL_DCHECK(a != NULL); + ABSL_DCHECK(b != NULL); return *a == *b; } }; @@ -660,7 +660,7 @@ DFA::State* DFA::WorkqToCachedState(Workq* q, Workq* mq, uint32_t flag) { break; } } - DCHECK_LE(n, q->size()); + ABSL_DCHECK_LE(n, q->size()); if (n > 0 && inst[n-1] == Mark) n--; @@ -848,7 +848,7 @@ void DFA::AddToQueue(Workq* q, int id, uint32_t flag) { stk[nstk++] = id; while (nstk > 0) { - DCHECK_LE(nstk, stack_.size()); + ABSL_DCHECK_LE(nstk, stack_.size()); id = stk[--nstk]; Loop: @@ -873,7 +873,7 @@ void DFA::AddToQueue(Workq* q, int id, uint32_t flag) { Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstByteRange: // just save these on the queue @@ -899,7 +899,7 @@ void DFA::AddToQueue(Workq* q, int id, uint32_t flag) { goto Loop; case kInstAltMatch: - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); id = id+1; goto Loop; @@ -962,7 +962,7 @@ void DFA::RunWorkqOnByte(Workq* oldq, Workq* newq, Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstFail: // never succeeds @@ -1030,14 +1030,14 @@ DFA::State* DFA::RunStateOnByte(State* state, int c) { return FullMatchState; } if (state == DeadState) { - LOG(DFATAL) << "DeadState in RunStateOnByte"; + ABSL_LOG(DFATAL) << "DeadState in RunStateOnByte"; return NULL; } if (state == NULL) { - LOG(DFATAL) << "NULL state in RunStateOnByte"; + ABSL_LOG(DFATAL) << "NULL state in RunStateOnByte"; return NULL; } - LOG(DFATAL) << "Unexpected special state in RunStateOnByte"; + ABSL_LOG(DFATAL) << "Unexpected special state in RunStateOnByte"; return NULL; } @@ -1268,7 +1268,7 @@ DFA::State* DFA::StateSaver::Restore() { absl::MutexLock l(&dfa_->mutex_); State* s = dfa_->CachedState(inst_, ninst_, flag_); if (s == NULL) - LOG(DFATAL) << "StateSaver failed to restore state."; + ABSL_LOG(DFATAL) << "StateSaver failed to restore state."; return s; } @@ -1452,13 +1452,13 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params) { // Restore start and s so we can continue. if ((start = save_start.Restore()) == NULL || (s = save_s.Restore()) == NULL) { - // Restore already did LOG(DFATAL). + // Restore already did ABSL_LOG(DFATAL). params->failed = true; return false; } ns = RunStateOnByteUnlocked(s, c); if (ns == NULL) { - LOG(DFATAL) << "RunStateOnByteUnlocked failed after ResetCache"; + ABSL_LOG(DFATAL) << "RunStateOnByteUnlocked failed after ResetCache"; params->failed = true; return false; } @@ -1530,7 +1530,7 @@ inline bool DFA::InlinedSearchLoop(SearchParams* params) { } ns = RunStateOnByteUnlocked(s, lastbyte); if (ns == NULL) { - LOG(DFATAL) << "RunStateOnByteUnlocked failed after Reset"; + ABSL_LOG(DFATAL) << "RunStateOnByteUnlocked failed after Reset"; params->failed = true; return false; } @@ -1647,7 +1647,7 @@ bool DFA::AnalyzeSearch(SearchParams* params) { // Sanity check: make sure that text lies within context. if (BeginPtr(text) < BeginPtr(context) || EndPtr(text) > EndPtr(context)) { - LOG(DFATAL) << "context does not contain text"; + ABSL_LOG(DFATAL) << "context does not contain text"; params->start = DeadState; return true; } @@ -1695,7 +1695,7 @@ bool DFA::AnalyzeSearch(SearchParams* params) { ResetCache(params->cache_lock); if (!AnalyzeSearchHelper(params, info, flags)) { params->failed = true; - LOG(DFATAL) << "Failed to analyze start state."; + ABSL_LOG(DFATAL) << "Failed to analyze start state."; return false; } } @@ -1769,7 +1769,7 @@ bool DFA::Search(absl::string_view text, absl::string_view context, params.want_earliest_match = want_earliest_match; params.run_forward = run_forward; // matches should be null except when using RE2::Set. - DCHECK(matches == NULL || kind_ == Prog::kManyMatch); + ABSL_DCHECK(matches == NULL || kind_ == Prog::kManyMatch); params.matches = matches; if (!AnalyzeSearch(¶ms)) { diff --git a/re2/filtered_re2.cc b/re2/filtered_re2.cc index 1ef675856..78e4a5675 100644 --- a/re2/filtered_re2.cc +++ b/re2/filtered_re2.cc @@ -8,8 +8,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/prefilter.h" #include "re2/prefilter_tree.h" @@ -53,8 +53,8 @@ RE2::ErrorCode FilteredRE2::Add(absl::string_view pattern, if (!re->ok()) { if (options.log_errors()) { - LOG(ERROR) << "Couldn't compile regular expression, skipping: " - << pattern << " due to error " << re->error(); + ABSL_LOG(ERROR) << "Couldn't compile regular expression, skipping: " + << pattern << " due to error " << re->error(); } delete re; } else { @@ -67,7 +67,7 @@ RE2::ErrorCode FilteredRE2::Add(absl::string_view pattern, void FilteredRE2::Compile(std::vector* atoms) { if (compiled_) { - LOG(ERROR) << "Compile called already."; + ABSL_LOG(ERROR) << "Compile called already."; return; } @@ -96,7 +96,7 @@ int FilteredRE2::SlowFirstMatch(absl::string_view text) const { int FilteredRE2::FirstMatch(absl::string_view text, const std::vector& atoms) const { if (!compiled_) { - LOG(DFATAL) << "FirstMatch called before Compile."; + ABSL_LOG(DFATAL) << "FirstMatch called before Compile."; return -1; } std::vector regexps; diff --git a/re2/mimics_pcre.cc b/re2/mimics_pcre.cc index 1e4d0d751..43860a6a1 100644 --- a/re2/mimics_pcre.cc +++ b/re2/mimics_pcre.cc @@ -22,8 +22,8 @@ // // Regexp::MimicsPCRE checks for any of these conditions. -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/regexp.h" #include "re2/walker-inl.h" @@ -45,7 +45,7 @@ class PCREWalker : public Regexp::Walker { virtual bool ShortVisit(Regexp* re, bool a) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "PCREWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "PCREWalker::ShortVisit called"; #endif return a; } @@ -129,7 +129,7 @@ class EmptyStringWalker : public Regexp::Walker { virtual bool ShortVisit(Regexp* re, bool a) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "EmptyStringWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "EmptyStringWalker::ShortVisit called"; #endif return a; } diff --git a/re2/nfa.cc b/re2/nfa.cc index 3ef8287c6..9ad522c91 100644 --- a/re2/nfa.cc +++ b/re2/nfa.cc @@ -32,8 +32,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "re2/pod_array.h" #include "re2/prog.h" @@ -173,17 +173,17 @@ NFA::Thread* NFA::AllocThread() { } NFA::Thread* NFA::Incref(Thread* t) { - DCHECK(t != NULL); + ABSL_DCHECK(t != NULL); t->ref++; return t; } void NFA::Decref(Thread* t) { - DCHECK(t != NULL); + ABSL_DCHECK(t != NULL); t->ref--; if (t->ref > 0) return; - DCHECK_EQ(t->ref, 0); + ABSL_DCHECK_EQ(t->ref, 0); t->next = freelist_; freelist_ = t; } @@ -209,7 +209,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, absl::string_view context, stk[nstk++] = {id0, NULL}; while (nstk > 0) { - DCHECK_LE(nstk, stack_.size()); + ABSL_DCHECK_LE(nstk, stack_.size()); AddState a = stk[--nstk]; Loop: @@ -239,7 +239,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, absl::string_view context, Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled " << ip->opcode() << " in AddToThreadq"; + ABSL_LOG(DFATAL) << "unhandled " << ip->opcode() << " in AddToThreadq"; break; case kInstFail: @@ -250,7 +250,7 @@ void NFA::AddToThreadq(Threadq* q, int id0, int c, absl::string_view context, t = Incref(t0); *tp = t; - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); a = {id+1, NULL}; goto Loop; @@ -351,7 +351,7 @@ int NFA::Step(Threadq* runq, Threadq* nextq, int c, absl::string_view context, switch (ip->opcode()) { default: // Should only see the values handled below. - LOG(DFATAL) << "Unhandled " << ip->opcode() << " in step"; + ABSL_LOG(DFATAL) << "Unhandled " << ip->opcode() << " in step"; break; case kInstByteRange: @@ -456,7 +456,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, // Sanity check: make sure that text lies within context. if (BeginPtr(text) < BeginPtr(context) || EndPtr(text) > EndPtr(context)) { - LOG(DFATAL) << "context does not contain text"; + ABSL_LOG(DFATAL) << "context does not contain text"; return false; } @@ -471,7 +471,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, } if (nsubmatch < 0) { - LOG(DFATAL) << "Bad args: nsubmatch=" << nsubmatch; + ABSL_LOG(DFATAL) << "Bad args: nsubmatch=" << nsubmatch; return false; } @@ -528,7 +528,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, // This is a no-op the first time around the loop because runq is empty. int id = Step(runq, nextq, p < etext_ ? p[0] & 0xFF : -1, context, p); - DCHECK_EQ(runq->size(), 0); + ABSL_DCHECK_EQ(runq->size(), 0); using std::swap; swap(nextq, runq); nextq->clear(); @@ -539,7 +539,8 @@ bool NFA::Search(absl::string_view text, absl::string_view context, Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "Unexpected opcode in short circuit: " << ip->opcode(); + ABSL_LOG(DFATAL) << "Unexpected opcode in short circuit: " + << ip->opcode(); break; case kInstCapture: @@ -600,7 +601,7 @@ bool NFA::Search(absl::string_view text, absl::string_view context, // This complements the special case in NFA::Step(). if (p == NULL) { (void) Step(runq, nextq, -1, context, p); - DCHECK_EQ(runq->size(), 0); + ABSL_DCHECK_EQ(runq->size(), 0); using std::swap; swap(nextq, runq); nextq->clear(); @@ -656,7 +657,7 @@ bool Prog::SearchNFA(absl::string_view text, absl::string_view context, // fanout holds the results and is also the work queue for the outer iteration. // reachable holds the reached nodes for the inner iteration. void Prog::Fanout(SparseArray* fanout) { - DCHECK_EQ(fanout->max_size(), size()); + ABSL_DCHECK_EQ(fanout->max_size(), size()); SparseSet reachable(size()); fanout->clear(); fanout->set_new(start(), 0); @@ -669,7 +670,8 @@ void Prog::Fanout(SparseArray* fanout) { Prog::Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled " << ip->opcode() << " in Prog::Fanout()"; + ABSL_LOG(DFATAL) << "unhandled " << ip->opcode() + << " in Prog::Fanout()"; break; case kInstByteRange: @@ -683,7 +685,7 @@ void Prog::Fanout(SparseArray* fanout) { break; case kInstAltMatch: - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); reachable.insert(id+1); break; diff --git a/re2/onepass.cc b/re2/onepass.cc index 9831cc828..20edd111d 100644 --- a/re2/onepass.cc +++ b/re2/onepass.cc @@ -59,8 +59,8 @@ #include "absl/container/fixed_array.h" #include "absl/container/inlined_vector.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/utf.h" #include "re2/pod_array.h" @@ -216,7 +216,7 @@ bool Prog::SearchOnePass(absl::string_view text, absl::string_view context, Anchor anchor, MatchKind kind, absl::string_view* match, int nmatch) { if (anchor != kAnchored && kind != kFullMatch) { - LOG(DFATAL) << "Cannot use SearchOnePass for unanchored matches."; + ABSL_LOG(DFATAL) << "Cannot use SearchOnePass for unanchored matches."; return false; } @@ -443,13 +443,13 @@ bool Prog::IsOnePass() { Prog::Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: // TODO(rsc): Ignoring kInstAltMatch optimization. // Should implement it in this engine, but it's subtle. - DCHECK(!ip->last()); + ABSL_DCHECK(!ip->last()); // If already on work queue, (1) is violated: bail out. if (!AddQ(&workq, id+1)) goto fail; @@ -461,7 +461,7 @@ bool Prog::IsOnePass() { if (nextindex == -1) { if (nalloc >= maxnodes) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: hit node limit %d >= %d", nalloc, maxnodes); goto fail; } @@ -486,7 +486,7 @@ bool Prog::IsOnePass() { node->action[b] = newact; } else if (act != newact) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: conflict on byte %#x at state %d", c, *it); goto fail; } @@ -507,7 +507,7 @@ bool Prog::IsOnePass() { node->action[b] = newact; } else if (act != newact) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: conflict on byte %#x at state %d", c, *it); goto fail; } @@ -548,7 +548,7 @@ bool Prog::IsOnePass() { // If already on work queue, (1) is violated: bail out. if (!AddQ(&workq, ip->out())) { if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: multiple paths %d -> %d", *it, ip->out()); goto fail; } @@ -559,7 +559,7 @@ bool Prog::IsOnePass() { if (matched) { // (3) is violated if (ExtraDebug) - LOG(ERROR) << absl::StrFormat( + ABSL_LOG(ERROR) << absl::StrFormat( "Not OnePass: multiple matches from %d", *it); goto fail; } @@ -580,9 +580,9 @@ bool Prog::IsOnePass() { } } - if (ExtraDebug) { // For debugging, dump one-pass NFA to LOG(ERROR). - LOG(ERROR) << "bytemap:\n" << DumpByteMap(); - LOG(ERROR) << "prog:\n" << Dump(); + if (ExtraDebug) { // For debugging, dump one-pass NFA to ABSL_LOG(ERROR). + ABSL_LOG(ERROR) << "bytemap:\n" << DumpByteMap(); + ABSL_LOG(ERROR) << "prog:\n" << Dump(); std::map idmap; for (int i = 0; i < size; i++) @@ -607,7 +607,7 @@ bool Prog::IsOnePass() { idmap[node->action[i] >> kIndexShift]); } } - LOG(ERROR) << "nodes:\n" << dump; + ABSL_LOG(ERROR) << "nodes:\n" << dump; } dfa_mem_ -= nalloc*statesize; diff --git a/re2/parse.cc b/re2/parse.cc index 003b14c86..6b30bcf38 100644 --- a/re2/parse.cc +++ b/re2/parse.cc @@ -26,8 +26,8 @@ #include #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" #include "absl/strings/ascii.h" #include "util/utf.h" #include "re2/pod_array.h" @@ -361,7 +361,7 @@ static void AddFoldedRange(CharClassBuilder* cc, Rune lo, Rune hi, int depth) { // current Unicode tables. make_unicode_casefold.py checks that // the cycles are not too long, and we double-check here using depth. if (depth > 10) { - LOG(DFATAL) << "AddFoldedRange recurses too much."; + ABSL_LOG(DFATAL) << "AddFoldedRange recurses too much."; return; } @@ -580,7 +580,7 @@ int RepetitionWalker::PostVisit(Regexp* re, int parent_arg, int pre_arg, int RepetitionWalker::ShortVisit(Regexp* re, int parent_arg) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "RepetitionWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "RepetitionWalker::ShortVisit called"; #endif return 0; } @@ -868,7 +868,7 @@ void Regexp::RemoveLeadingString(Regexp* re, int n) { case 0: case 1: // Impossible. - LOG(DFATAL) << "Concat of " << re->nsub(); + ABSL_LOG(DFATAL) << "Concat of " << re->nsub(); re->submany_ = NULL; re->op_ = kRegexpEmptyMatch; break; @@ -998,7 +998,7 @@ int Regexp::FactorAlternation(Regexp** sub, int nsub, ParseFlags flags) { i += iter->nsub; break; default: - LOG(DFATAL) << "unknown round: " << round; + ABSL_LOG(DFATAL) << "unknown round: " << round; break; } // If we are done, copy until the end of sub. @@ -1037,7 +1037,7 @@ int Regexp::FactorAlternation(Regexp** sub, int nsub, ParseFlags flags) { continue; } default: - LOG(DFATAL) << "unknown round: " << round; + ABSL_LOG(DFATAL) << "unknown round: " << round; break; } @@ -1214,8 +1214,8 @@ void FactorAlternationImpl::Round3(Regexp** sub, int nsub, ccb.AddRangeFlags(re->rune(), re->rune(), re->parse_flags()); } } else { - LOG(DFATAL) << "RE2: unexpected op: " << re->op() << " " - << re->ToString(); + ABSL_LOG(DFATAL) << "RE2: unexpected op: " << re->op() << " " + << re->ToString(); } re->Decref(); } @@ -1476,7 +1476,7 @@ static int UnHex(int c) { return c - 'A' + 10; if ('a' <= c && c <= 'f') return c - 'a' + 10; - LOG(DFATAL) << "Bad hex digit " << c; + ABSL_LOG(DFATAL) << "Bad hex digit " << c; return 0; } @@ -2096,7 +2096,7 @@ bool Regexp::ParseState::ParsePerlFlags(absl::string_view* s) { // Caller is supposed to check this. if (!(flags_ & PerlX) || t.size() < 2 || t[0] != '(' || t[1] != '?') { status_->set_code(kRegexpInternalError); - LOG(DFATAL) << "Bad call to ParseState::ParsePerlFlags"; + ABSL_LOG(DFATAL) << "Bad call to ParseState::ParsePerlFlags"; return false; } diff --git a/re2/prefilter.cc b/re2/prefilter.cc index 53290b02f..529b58ced 100644 --- a/re2/prefilter.cc +++ b/re2/prefilter.cc @@ -10,8 +10,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/utf.h" #include "re2/re2.h" @@ -301,8 +301,8 @@ void Prefilter::CrossProduct(const SSet& a, const SSet& b, SSet* dst) { Prefilter::Info* Prefilter::Info::Concat(Info* a, Info* b) { if (a == NULL) return b; - DCHECK(a->is_exact_); - DCHECK(b && b->is_exact_); + ABSL_DCHECK(a->is_exact_); + ABSL_DCHECK(b && b->is_exact_); Info *ab = new Info(); CrossProduct(a->exact_, b->exact_, &ab->exact_); @@ -451,9 +451,9 @@ typedef CharClass::iterator CCIter; Prefilter::Info* Prefilter::Info::CClass(CharClass *cc, bool latin1) { if (ExtraDebug) { - LOG(ERROR) << "CharClassInfo:"; + ABSL_LOG(ERROR) << "CharClassInfo:"; for (CCIter i = cc->begin(); i != cc->end(); ++i) - LOG(ERROR) << " " << i->lo << "-" << i->hi; + ABSL_LOG(ERROR) << " " << i->lo << "-" << i->hi; } // If the class is too large, it's okay to overestimate. @@ -474,7 +474,7 @@ Prefilter::Info* Prefilter::Info::CClass(CharClass *cc, a->is_exact_ = true; if (ExtraDebug) - LOG(ERROR) << " = " << a->ToString(); + ABSL_LOG(ERROR) << " = " << a->ToString(); return a; } @@ -502,7 +502,7 @@ class Prefilter::Info::Walker : public Regexp::Walker { Prefilter::Info* Prefilter::BuildInfo(Regexp* re) { if (ExtraDebug) - LOG(ERROR) << "BuildPrefilter::Info: " << re->ToString(); + ABSL_LOG(ERROR) << "BuildPrefilter::Info: " << re->ToString(); bool latin1 = (re->parse_flags() & Regexp::Latin1) != 0; Prefilter::Info::Walker w(latin1); @@ -532,7 +532,7 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit( default: case kRegexpRepeat: info = EmptyString(); - LOG(DFATAL) << "Bad regexp op " << re->op(); + ABSL_LOG(DFATAL) << "Bad regexp op " << re->op(); break; case kRegexpNoMatch: @@ -635,8 +635,8 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit( } if (ExtraDebug) - LOG(ERROR) << "BuildInfo " << re->ToString() - << ": " << (info ? info->ToString() : ""); + ABSL_LOG(ERROR) << "BuildInfo " << re->ToString() + << ": " << (info ? info->ToString() : ""); return info; } @@ -663,7 +663,7 @@ Prefilter* Prefilter::FromRegexp(Regexp* re) { std::string Prefilter::DebugString() const { switch (op_) { default: - LOG(DFATAL) << "Bad op in Prefilter::DebugString: " << op_; + ABSL_LOG(DFATAL) << "Bad op in Prefilter::DebugString: " << op_; return absl::StrFormat("op%d", op_); case NONE: return "*no-matches*"; diff --git a/re2/prefilter.h b/re2/prefilter.h index cf32bd674..2645790cf 100644 --- a/re2/prefilter.h +++ b/re2/prefilter.h @@ -13,8 +13,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" namespace re2 { @@ -43,7 +43,7 @@ class Prefilter { // The children of the Prefilter node. std::vector* subs() { - DCHECK(op_ == AND || op_ == OR); + ABSL_DCHECK(op_ == AND || op_ == OR); return subs_; } diff --git a/re2/prefilter_tree.cc b/re2/prefilter_tree.cc index b7a7408f4..e59608684 100644 --- a/re2/prefilter_tree.cc +++ b/re2/prefilter_tree.cc @@ -12,8 +12,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "re2/prefilter.h" #include "re2/re2.h" @@ -39,7 +39,7 @@ PrefilterTree::~PrefilterTree() { void PrefilterTree::Add(Prefilter* prefilter) { if (compiled_) { - LOG(DFATAL) << "Add called after Compile."; + ABSL_LOG(DFATAL) << "Add called after Compile."; return; } if (prefilter != NULL && !KeepNode(prefilter)) { @@ -52,7 +52,7 @@ void PrefilterTree::Add(Prefilter* prefilter) { void PrefilterTree::Compile(std::vector* atom_vec) { if (compiled_) { - LOG(DFATAL) << "Compile called already."; + ABSL_LOG(DFATAL) << "Compile called already."; return; } @@ -84,7 +84,7 @@ bool PrefilterTree::KeepNode(Prefilter* node) const { switch (node->op()) { default: - LOG(DFATAL) << "Unexpected op in KeepNode: " << node->op(); + ABSL_LOG(DFATAL) << "Unexpected op in KeepNode: " << node->op(); return false; case Prefilter::ALL: @@ -179,7 +179,7 @@ void PrefilterTree::AssignUniqueIds(NodeSet* nodes, int id = prefilter->unique_id(); switch (prefilter->op()) { default: - LOG(DFATAL) << "Unexpected op: " << prefilter->op(); + ABSL_LOG(DFATAL) << "Unexpected op: " << prefilter->op(); return; case Prefilter::ATOM: @@ -213,7 +213,7 @@ void PrefilterTree::AssignUniqueIds(NodeSet* nodes, if (prefilter_vec_[i] == NULL) continue; int id = CanonicalNode(nodes, prefilter_vec_[i])->unique_id(); - DCHECK_LE(0, id); + ABSL_DCHECK_LE(0, id); Entry* entry = &entries_[id]; entry->regexps.push_back(static_cast(i)); } @@ -278,7 +278,7 @@ void PrefilterTree::RegexpsGivenStrings( return; } - LOG(ERROR) << "RegexpsGivenStrings called before Compile."; + ABSL_LOG(ERROR) << "RegexpsGivenStrings called before Compile."; for (size_t i = 0; i < prefilter_vec_.size(); i++) regexps->push_back(static_cast(i)); } else { @@ -332,31 +332,31 @@ void PrefilterTree::PropagateMatch(const std::vector& atom_ids, // Debugging help. void PrefilterTree::PrintPrefilter(int regexpid) { - LOG(ERROR) << DebugNodeString(prefilter_vec_[regexpid]); + ABSL_LOG(ERROR) << DebugNodeString(prefilter_vec_[regexpid]); } void PrefilterTree::PrintDebugInfo(NodeSet* nodes) { - LOG(ERROR) << "#Unique Atoms: " << atom_index_to_id_.size(); - LOG(ERROR) << "#Unique Nodes: " << entries_.size(); + ABSL_LOG(ERROR) << "#Unique Atoms: " << atom_index_to_id_.size(); + ABSL_LOG(ERROR) << "#Unique Nodes: " << entries_.size(); for (size_t i = 0; i < entries_.size(); i++) { const std::vector& parents = entries_[i].parents; const std::vector& regexps = entries_[i].regexps; - LOG(ERROR) << "EntryId: " << i - << " N: " << parents.size() << " R: " << regexps.size(); + ABSL_LOG(ERROR) << "EntryId: " << i + << " N: " << parents.size() << " R: " << regexps.size(); for (int parent : parents) - LOG(ERROR) << parent; + ABSL_LOG(ERROR) << parent; } - LOG(ERROR) << "Set:"; + ABSL_LOG(ERROR) << "Set:"; for (NodeSet::const_iterator iter = nodes->begin(); iter != nodes->end(); ++iter) - LOG(ERROR) << "NodeId: " << (*iter)->unique_id(); + ABSL_LOG(ERROR) << "NodeId: " << (*iter)->unique_id(); } std::string PrefilterTree::DebugNodeString(Prefilter* node) const { std::string node_string = ""; if (node->op() == Prefilter::ATOM) { - DCHECK(!node->atom().empty()); + ABSL_DCHECK(!node->atom().empty()); node_string += node->atom(); } else { // Adding the operation disambiguates AND and OR nodes. diff --git a/re2/prefilter_tree.h b/re2/prefilter_tree.h index ba23282d4..885170df8 100644 --- a/re2/prefilter_tree.h +++ b/re2/prefilter_tree.h @@ -20,8 +20,8 @@ #include #include "absl/container/flat_hash_set.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "re2/prefilter.h" #include "re2/sparse_array.h" @@ -63,15 +63,15 @@ class PrefilterTree { struct PrefilterHash { size_t operator()(const Prefilter* a) const { - DCHECK(a != NULL); + ABSL_DCHECK(a != NULL); return absl::Hash()(*a); } }; struct PrefilterEqual { bool operator()(const Prefilter* a, const Prefilter* b) const { - DCHECK(a != NULL); - DCHECK(b != NULL); + ABSL_DCHECK(a != NULL); + ABSL_DCHECK(b != NULL); return *a == *b; } }; diff --git a/re2/prog.cc b/re2/prog.cc index 423e1769e..277de2602 100644 --- a/re2/prog.cc +++ b/re2/prog.cc @@ -20,8 +20,8 @@ #include #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" #include "absl/strings/str_format.h" #include "re2/bitmap256.h" @@ -30,13 +30,13 @@ namespace re2 { // Constructors per Inst opcode void Prog::Inst::InitAlt(uint32_t out, uint32_t out1) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstAlt); out1_ = out1; } void Prog::Inst::InitByteRange(int lo, int hi, int foldcase, uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstByteRange); lo_ = lo & 0xFF; hi_ = hi & 0xFF; @@ -44,30 +44,30 @@ void Prog::Inst::InitByteRange(int lo, int hi, int foldcase, uint32_t out) { } void Prog::Inst::InitCapture(int cap, uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstCapture); cap_ = cap; } void Prog::Inst::InitEmptyWidth(EmptyOp empty, uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_out_opcode(out, kInstEmptyWidth); empty_ = empty; } void Prog::Inst::InitMatch(int32_t id) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_opcode(kInstMatch); match_id_ = id; } void Prog::Inst::InitNop(uint32_t out) { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_opcode(kInstNop); } void Prog::Inst::InitFail() { - DCHECK_EQ(out_opcode_, 0); + ABSL_DCHECK_EQ(out_opcode_, 0); set_opcode(kInstFail); } @@ -199,7 +199,7 @@ static bool IsMatch(Prog* prog, Prog::Inst* ip) { for (;;) { switch (ip->opcode()) { default: - LOG(DFATAL) << "Unexpected opcode in IsMatch: " << ip->opcode(); + ABSL_LOG(DFATAL) << "Unexpected opcode in IsMatch: " << ip->opcode(); return false; case kInstAlt: @@ -363,11 +363,11 @@ class ByteMapBuilder { }; void ByteMapBuilder::Mark(int lo, int hi) { - DCHECK_GE(lo, 0); - DCHECK_GE(hi, 0); - DCHECK_LE(lo, 255); - DCHECK_LE(hi, 255); - DCHECK_LE(lo, hi); + ABSL_DCHECK_GE(lo, 0); + ABSL_DCHECK_GE(hi, 0); + ABSL_DCHECK_LE(lo, 255); + ABSL_DCHECK_LE(hi, 255); + ABSL_DCHECK_LE(lo, hi); // Ignore any [0-255] ranges. They cause us to recolor every range, which // has no effect on the eventual result and is therefore a waste of time. @@ -512,7 +512,7 @@ void Prog::ComputeByteMap() { builder.Build(bytemap_, &bytemap_range_); if ((0)) { // For debugging, use trivial bytemap. - LOG(ERROR) << "Using trivial bytemap."; + ABSL_LOG(ERROR) << "Using trivial bytemap."; for (int i = 0; i < 256; i++) bytemap_[i] = static_cast(i); bytemap_range_ = 256; @@ -616,12 +616,12 @@ void Prog::Flatten() { size_t total = 0; for (int i = 0; i < kNumInst; i++) total += inst_count_[i]; - CHECK_EQ(total, flat.size()); + ABSL_CHECK_EQ(total, flat.size()); #endif // Remap start_unanchored and start. if (start_unanchored() == 0) { - DCHECK_EQ(start(), 0); + ABSL_DCHECK_EQ(start(), 0); } else if (start_unanchored() == start()) { set_start_unanchored(flatmap[1]); set_start(flatmap[1]); @@ -678,7 +678,7 @@ void Prog::MarkSuccessors(SparseArray* rootmap, Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: @@ -738,7 +738,7 @@ void Prog::MarkDominator(int root, SparseArray* rootmap, Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: @@ -805,7 +805,7 @@ void Prog::EmitList(int root, SparseArray* rootmap, Inst* ip = inst(id); switch (ip->opcode()) { default: - LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); + ABSL_LOG(DFATAL) << "unhandled opcode: " << ip->opcode(); break; case kInstAltMatch: @@ -1106,7 +1106,7 @@ const void* Prog::PrefixAccel_ShiftDFA(const void* data, size_t size) { #if defined(__AVX2__) // Finds the least significant non-zero bit in n. static int FindLSBSet(uint32_t n) { - DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, 0); #if defined(__GNUC__) return __builtin_ctz(n); #elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) @@ -1128,7 +1128,7 @@ static int FindLSBSet(uint32_t n) { #endif const void* Prog::PrefixAccel_FrontAndBack(const void* data, size_t size) { - DCHECK_GE(prefix_size_, 2); + ABSL_DCHECK_GE(prefix_size_, 2); if (size < prefix_size_) return NULL; // Don't bother searching the last prefix_size_-1 bytes for prefix_front_. @@ -1165,7 +1165,7 @@ const void* Prog::PrefixAccel_FrontAndBack(const void* data, size_t size) { const char* p0 = reinterpret_cast(data); for (const char* p = p0;; p++) { - DCHECK_GE(size, static_cast(p-p0)); + ABSL_DCHECK_GE(size, static_cast(p-p0)); p = reinterpret_cast(memchr(p, prefix_front_, size - (p-p0))); if (p == NULL || p[prefix_size_-1] == prefix_back_) return p; diff --git a/re2/prog.h b/re2/prog.h index 5db21c45f..6851832cb 100644 --- a/re2/prog.h +++ b/re2/prog.h @@ -16,8 +16,8 @@ #include #include "absl/base/call_once.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/string_view.h" #include "re2/pod_array.h" #include "re2/re2.h" @@ -80,20 +80,44 @@ class Prog { // Getters int id(Prog* p) { return static_cast(this - p->inst_.data()); } - InstOp opcode() { return static_cast(out_opcode_&7); } - int last() { return (out_opcode_>>3)&1; } - int out() { return out_opcode_>>4; } - int out1() { DCHECK(opcode() == kInstAlt || opcode() == kInstAltMatch); return out1_; } - int cap() { DCHECK_EQ(opcode(), kInstCapture); return cap_; } - int lo() { DCHECK_EQ(opcode(), kInstByteRange); return lo_; } - int hi() { DCHECK_EQ(opcode(), kInstByteRange); return hi_; } - int foldcase() { DCHECK_EQ(opcode(), kInstByteRange); return hint_foldcase_&1; } - int hint() { DCHECK_EQ(opcode(), kInstByteRange); return hint_foldcase_>>1; } - int match_id() { DCHECK_EQ(opcode(), kInstMatch); return match_id_; } - EmptyOp empty() { DCHECK_EQ(opcode(), kInstEmptyWidth); return empty_; } + InstOp opcode() { return static_cast(out_opcode_ & 7); } + int last() { return (out_opcode_ >> 3) & 1; } + int out() { return out_opcode_ >> 4; } + int out1() { + ABSL_DCHECK(opcode() == kInstAlt || opcode() == kInstAltMatch); + return out1_; + } + int cap() { + ABSL_DCHECK_EQ(opcode(), kInstCapture); + return cap_; + } + int lo() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return lo_; + } + int hi() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return hi_; + } + int foldcase() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return hint_foldcase_ & 1; + } + int hint() { + ABSL_DCHECK_EQ(opcode(), kInstByteRange); + return hint_foldcase_ >> 1; + } + int match_id() { + ABSL_DCHECK_EQ(opcode(), kInstMatch); + return match_id_; + } + EmptyOp empty() { + ABSL_DCHECK_EQ(opcode(), kInstEmptyWidth); + return empty_; + } bool greedy(Prog* p) { - DCHECK_EQ(opcode(), kInstAltMatch); + ABSL_DCHECK_EQ(opcode(), kInstAltMatch); return p->inst(out())->opcode() == kInstByteRange || (p->inst(out())->opcode() == kInstNop && p->inst(p->inst(out())->out())->opcode() == kInstByteRange); @@ -101,7 +125,7 @@ class Prog { // Does this inst (an kInstByteRange) match c? inline bool Matches(int c) { - DCHECK_EQ(opcode(), kInstByteRange); + ABSL_DCHECK_EQ(opcode(), kInstByteRange); if (foldcase() && 'A' <= c && c <= 'Z') c += 'a' - 'A'; return lo_ <= c && c <= hi_; @@ -222,7 +246,7 @@ class Prog { // Accelerates to the first likely occurrence of the prefix. // Returns a pointer to the first byte or NULL if not found. const void* PrefixAccel(const void* data, size_t size) { - DCHECK(can_prefix_accel()); + ABSL_DCHECK(can_prefix_accel()); if (prefix_foldcase_) { return PrefixAccel_ShiftDFA(data, size); } else if (prefix_size_ != 1) { diff --git a/re2/re2.cc b/re2/re2.cc index 332157ebc..74b75265b 100644 --- a/re2/re2.cc +++ b/re2/re2.cc @@ -26,8 +26,8 @@ #include "absl/base/macros.h" #include "absl/container/fixed_array.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/ascii.h" #include "absl/strings/str_format.h" #include "util/strutil.h" @@ -159,7 +159,7 @@ int RE2::Options::ParseFlags() const { switch (encoding()) { default: if (log_errors()) - LOG(ERROR) << "Unknown encoding " << encoding(); + ABSL_LOG(ERROR) << "Unknown encoding " << encoding(); break; case RE2::Options::EncodingUTF8: break; @@ -230,8 +230,8 @@ void RE2::Init(absl::string_view pattern, const Options& options) { &status); if (entire_regexp_ == NULL) { if (options_.log_errors()) { - LOG(ERROR) << "Error parsing '" << trunc(*pattern_) << "': " - << status.Text(); + ABSL_LOG(ERROR) << "Error parsing '" << trunc(*pattern_) << "': " + << status.Text(); } error_ = new std::string(status.Text()); error_code_ = RegexpErrorToRE2(status.code()); @@ -255,7 +255,7 @@ void RE2::Init(absl::string_view pattern, const Options& options) { prog_ = suffix_regexp_->CompileToProg(options_.max_mem()*2/3); if (prog_ == NULL) { if (options_.log_errors()) - LOG(ERROR) << "Error compiling '" << trunc(*pattern_) << "'"; + ABSL_LOG(ERROR) << "Error compiling '" << trunc(*pattern_) << "'"; error_ = new std::string("pattern too large - compile failed"); error_code_ = RE2::ErrorPatternTooLarge; return; @@ -281,8 +281,8 @@ re2::Prog* RE2::ReverseProg() const { re->suffix_regexp_->CompileToReverseProg(re->options_.max_mem() / 3); if (re->rprog_ == NULL) { if (re->options_.log_errors()) - LOG(ERROR) << "Error reverse compiling '" << trunc(*re->pattern_) - << "'"; + ABSL_LOG(ERROR) << "Error reverse compiling '" << trunc(*re->pattern_) + << "'"; // We no longer touch error_ and error_code_ because failing to compile // the reverse Prog is not a showstopper: falling back to NFA execution // is fine. More importantly, an RE2 object is supposed to be logically @@ -328,7 +328,7 @@ int RE2::ReverseProgramSize() const { // Finds the most significant non-zero bit in n. static int FindMSBSet(uint32_t n) { - DCHECK_NE(n, 0); + ABSL_DCHECK_NE(n, 0); #if defined(__GNUC__) return 31 ^ __builtin_clz(n); #elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) @@ -454,8 +454,8 @@ bool RE2::Replace(std::string* str, if (!re.Rewrite(&s, rewrite, vec, nvec)) return false; - DCHECK_GE(vec[0].data(), str->data()); - DCHECK_LE(vec[0].data() + vec[0].size(), str->data() + str->size()); + ABSL_DCHECK_GE(vec[0].data(), str->data()); + ABSL_DCHECK_LE(vec[0].data() + vec[0].size(), str->data() + str->size()); str->replace(vec[0].data() - str->data(), vec[0].size(), s); return true; } @@ -654,16 +654,16 @@ bool RE2::Match(absl::string_view text, int nsubmatch) const { if (!ok()) { if (options_.log_errors()) - LOG(ERROR) << "Invalid RE2: " << *error_; + ABSL_LOG(ERROR) << "Invalid RE2: " << *error_; return false; } if (startpos > endpos || endpos > text.size()) { if (options_.log_errors()) - LOG(ERROR) << "RE2: invalid startpos, endpos pair. [" - << "startpos: " << startpos << ", " - << "endpos: " << endpos << ", " - << "text size: " << text.size() << "]"; + ABSL_LOG(ERROR) << "RE2: invalid startpos, endpos pair. [" + << "startpos: " << startpos << ", " + << "endpos: " << endpos << ", " + << "text size: " << text.size() << "]"; return false; } @@ -733,7 +733,7 @@ bool RE2::Match(absl::string_view text, bool skipped_test = false; switch (re_anchor) { default: - LOG(DFATAL) << "Unexpected re_anchor value: " << re_anchor; + ABSL_LOG(DFATAL) << "Unexpected re_anchor value: " << re_anchor; return false; case UNANCHORED: { @@ -751,11 +751,11 @@ bool RE2::Match(absl::string_view text, Prog::kLongestMatch, matchp, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog->size() << ", " - << "list count " << prog->list_count() << ", " - << "bytemap range " << prog->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog->size() << ", " + << "list count " << prog->list_count() << ", " + << "bytemap range " << prog->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; @@ -771,11 +771,11 @@ bool RE2::Match(absl::string_view text, matchp, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog_->size() << ", " - << "list count " << prog_->list_count() << ", " - << "bytemap range " << prog_->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog_->size() << ", " + << "list count " << prog_->list_count() << ", " + << "bytemap range " << prog_->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; @@ -797,17 +797,17 @@ bool RE2::Match(absl::string_view text, Prog::kLongestMatch, &match, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog->size() << ", " - << "list count " << prog->list_count() << ", " - << "bytemap range " << prog->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog->size() << ", " + << "list count " << prog->list_count() << ", " + << "bytemap range " << prog->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; } if (options_.log_errors()) - LOG(ERROR) << "SearchDFA inconsistency"; + ABSL_LOG(ERROR) << "SearchDFA inconsistency"; return false; } break; @@ -840,11 +840,11 @@ bool RE2::Match(absl::string_view text, &match, &dfa_failed, NULL)) { if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "pattern length " << pattern_->size() << ", " - << "program size " << prog_->size() << ", " - << "list count " << prog_->list_count() << ", " - << "bytemap range " << prog_->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "pattern length " << pattern_->size() << ", " + << "program size " << prog_->size() << ", " + << "list count " << prog_->list_count() << ", " + << "bytemap range " << prog_->bytemap_range(); // Fall back to NFA below. skipped_test = true; break; @@ -876,20 +876,20 @@ bool RE2::Match(absl::string_view text, if (can_one_pass && anchor != Prog::kUnanchored) { if (!prog_->SearchOnePass(subtext1, text, anchor, kind, submatch, ncap)) { if (!skipped_test && options_.log_errors()) - LOG(ERROR) << "SearchOnePass inconsistency"; + ABSL_LOG(ERROR) << "SearchOnePass inconsistency"; return false; } } else if (can_bit_state && subtext1.size() <= bit_state_text_max_size) { if (!prog_->SearchBitState(subtext1, text, anchor, kind, submatch, ncap)) { if (!skipped_test && options_.log_errors()) - LOG(ERROR) << "SearchBitState inconsistency"; + ABSL_LOG(ERROR) << "SearchBitState inconsistency"; return false; } } else { if (!prog_->SearchNFA(subtext1, text, anchor, kind, submatch, ncap)) { if (!skipped_test && options_.log_errors()) - LOG(ERROR) << "SearchNFA inconsistency"; + ABSL_LOG(ERROR) << "SearchNFA inconsistency"; return false; } } @@ -914,7 +914,7 @@ bool RE2::DoMatch(absl::string_view text, int n) const { if (!ok()) { if (options_.log_errors()) - LOG(ERROR) << "Invalid RE2: " << *error_; + ABSL_LOG(ERROR) << "Invalid RE2: " << *error_; return false; } @@ -1034,8 +1034,8 @@ bool RE2::Rewrite(std::string* out, int n = (c - '0'); if (n >= veclen) { if (options_.log_errors()) { - LOG(ERROR) << "invalid substitution \\" << n - << " from " << veclen << " groups"; + ABSL_LOG(ERROR) << "invalid substitution \\" << n + << " from " << veclen << " groups"; } return false; } @@ -1046,7 +1046,7 @@ bool RE2::Rewrite(std::string* out, out->push_back('\\'); } else { if (options_.log_errors()) - LOG(ERROR) << "invalid rewrite pattern: " << rewrite.data(); + ABSL_LOG(ERROR) << "invalid rewrite pattern: " << rewrite.data(); return false; } } diff --git a/re2/re2.h b/re2/re2.h index 13bf39fbe..0f859a179 100644 --- a/re2/re2.h +++ b/re2/re2.h @@ -50,10 +50,10 @@ // supplied pattern exactly. // // Example: successful match -// CHECK(RE2::FullMatch("hello", "h.*o")); +// ABSL_CHECK(RE2::FullMatch("hello", "h.*o")); // // Example: unsuccessful match (requires full match): -// CHECK(!RE2::FullMatch("hello", "e")); +// ABSL_CHECK(!RE2::FullMatch("hello", "e")); // // ----------------------------------------------------------------------- // UTF-8 AND THE MATCHING INTERFACE: @@ -62,8 +62,9 @@ // The RE2::Latin1 option causes them to be interpreted as Latin-1. // // Example: -// CHECK(RE2::FullMatch(utf8_string, RE2(utf8_pattern))); -// CHECK(RE2::FullMatch(latin1_string, RE2(latin1_pattern, RE2::Latin1))); +// ABSL_CHECK(RE2::FullMatch(utf8_string, RE2(utf8_pattern))); +// ABSL_CHECK(RE2::FullMatch(latin1_string, RE2(latin1_pattern, +// RE2::Latin1))); // // ----------------------------------------------------------------------- // SUBMATCH EXTRACTION: @@ -83,27 +84,27 @@ // Example: extracts "ruby" into "s" and 1234 into "i" // int i; // std::string s; -// CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); +// ABSL_CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); // // Example: extracts "ruby" into "s" and no value into "i" // absl::optional i; // std::string s; -// CHECK(RE2::FullMatch("ruby", "(\\w+)(?::(\\d+))?", &s, &i)); +// ABSL_CHECK(RE2::FullMatch("ruby", "(\\w+)(?::(\\d+))?", &s, &i)); // // Example: fails because string cannot be stored in integer -// CHECK(!RE2::FullMatch("ruby", "(.*)", &i)); +// ABSL_CHECK(!RE2::FullMatch("ruby", "(.*)", &i)); // // Example: fails because there aren't enough sub-patterns -// CHECK(!RE2::FullMatch("ruby:1234", "\\w+:\\d+", &s)); +// ABSL_CHECK(!RE2::FullMatch("ruby:1234", "\\w+:\\d+", &s)); // // Example: does not try to extract any extra sub-patterns -// CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); +// ABSL_CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); // // Example: does not try to extract into NULL -// CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); +// ABSL_CHECK(RE2::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); // // Example: integer overflow causes failure -// CHECK(!RE2::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); +// ABSL_CHECK(!RE2::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); // // NOTE(rsc): Asking for submatches slows successful matches quite a bit. // This may get a little faster in the future, but right now is slower @@ -117,12 +118,12 @@ // to match any substring of the text. // // Example: simple search for a string: -// CHECK(RE2::PartialMatch("hello", "ell")); +// ABSL_CHECK(RE2::PartialMatch("hello", "ell")); // // Example: find first number in a string // int number; -// CHECK(RE2::PartialMatch("x*100 + 20", "(\\d+)", &number)); -// CHECK_EQ(number, 100); +// ABSL_CHECK(RE2::PartialMatch("x*100 + 20", "(\\d+)", &number)); +// ABSL_CHECK_EQ(number, 100); // // ----------------------------------------------------------------------- // PRE-COMPILED REGULAR EXPRESSIONS @@ -203,7 +204,7 @@ // // Example: // int a, b, c, d; -// CHECK(RE2::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", +// ABSL_CHECK(RE2::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", // RE2::Octal(&a), RE2::Hex(&b), RE2::CRadix(&c), RE2::CRadix(&d)); // will leave 64 in a, b, c, and d. @@ -469,7 +470,7 @@ class RE2 { // text. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(RE2::Replace(&s, "b+", "d")); + // ABSL_CHECK(RE2::Replace(&s, "b+", "d")); // // will leave "s" containing "yada dabba doo" // @@ -483,7 +484,7 @@ class RE2 { // of the pattern in the string with the rewrite. E.g. // // std::string s = "yabba dabba doo"; - // CHECK(RE2::GlobalReplace(&s, "b+", "d")); + // ABSL_CHECK(RE2::GlobalReplace(&s, "b+", "d")); // // will leave "s" containing "yada dada doo" // Replacements are not subject to re-matching. diff --git a/re2/regexp.cc b/re2/regexp.cc index f374c1546..d07756164 100644 --- a/re2/regexp.cc +++ b/re2/regexp.cc @@ -18,8 +18,8 @@ #include "absl/base/call_once.h" #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 "absl/synchronization/mutex.h" #include "util/utf.h" #include "re2/pod_array.h" @@ -46,7 +46,7 @@ Regexp::Regexp(RegexpOp op, ParseFlags parse_flags) // required Decref() to have handled them for us. Regexp::~Regexp() { if (nsub_ > 0) - LOG(DFATAL) << "Regexp not destroyed."; + ABSL_LOG(DFATAL) << "Regexp not destroyed."; switch (op_) { default: @@ -155,7 +155,7 @@ void Regexp::Destroy() { Regexp* re = stack; stack = re->down_; if (re->ref_ != 0) - LOG(DFATAL) << "Bad reference count " << re->ref_; + ABSL_LOG(DFATAL) << "Bad reference count " << re->ref_; if (re->nsub_ > 0) { Regexp** subs = re->sub(); for (int i = 0; i < re->nsub_; i++) { @@ -180,7 +180,7 @@ void Regexp::Destroy() { } void Regexp::AddRuneToString(Rune r) { - DCHECK(op_ == kRegexpLiteralString); + ABSL_DCHECK(op_ == kRegexpLiteralString); if (nrunes_ == 0) { // start with 8 runes_ = new Rune[8]; @@ -422,7 +422,7 @@ static bool TopEqual(Regexp* a, Regexp* b) { } } - LOG(DFATAL) << "Unexpected op in Regexp::Equal: " << a->op(); + ABSL_LOG(DFATAL) << "Unexpected op in Regexp::Equal: " << a->op(); return 0; } @@ -497,7 +497,7 @@ bool Regexp::Equal(Regexp* a, Regexp* b) { if (n == 0) break; - DCHECK_GE(n, 2); + ABSL_DCHECK_GE(n, 2); a = stk[n-2]; b = stk[n-1]; stk.resize(n-2); @@ -563,7 +563,7 @@ class NumCapturesWalker : public Regexp::Walker { virtual Ignored ShortVisit(Regexp* re, Ignored ignored) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "NumCapturesWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "NumCapturesWalker::ShortVisit called"; #endif return ignored; } @@ -610,7 +610,7 @@ class NamedCapturesWalker : public Regexp::Walker { virtual Ignored ShortVisit(Regexp* re, Ignored ignored) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "NamedCapturesWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "NamedCapturesWalker::ShortVisit called"; #endif return ignored; } @@ -654,7 +654,7 @@ class CaptureNamesWalker : public Regexp::Walker { virtual Ignored ShortVisit(Regexp* re, Ignored ignored) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "CaptureNamesWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "CaptureNamesWalker::ShortVisit called"; #endif return ignored; } @@ -994,7 +994,7 @@ CharClass* CharClassBuilder::GetCharClass() { for (iterator it = begin(); it != end(); ++it) cc->ranges_[n++] = *it; cc->nranges_ = n; - DCHECK_LE(n, static_cast(ranges_.size())); + ABSL_DCHECK_LE(n, static_cast(ranges_.size())); cc->nrunes_ = nrunes_; cc->folds_ascii_ = FoldsASCII(); return cc; diff --git a/re2/regexp.h b/re2/regexp.h index 9c05cc855..a782b2a6e 100644 --- a/re2/regexp.h +++ b/re2/regexp.h @@ -92,8 +92,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/string_view.h" #include "util/utf.h" @@ -333,15 +333,42 @@ class Regexp { return submany_; } - int min() { DCHECK_EQ(op_, kRegexpRepeat); return min_; } - int max() { DCHECK_EQ(op_, kRegexpRepeat); return max_; } - Rune rune() { DCHECK_EQ(op_, kRegexpLiteral); return rune_; } - CharClass* cc() { DCHECK_EQ(op_, kRegexpCharClass); return cc_; } - int cap() { DCHECK_EQ(op_, kRegexpCapture); return cap_; } - const std::string* name() { DCHECK_EQ(op_, kRegexpCapture); return name_; } - Rune* runes() { DCHECK_EQ(op_, kRegexpLiteralString); return runes_; } - int nrunes() { DCHECK_EQ(op_, kRegexpLiteralString); return nrunes_; } - int match_id() { DCHECK_EQ(op_, kRegexpHaveMatch); return match_id_; } + int min() { + ABSL_DCHECK_EQ(op_, kRegexpRepeat); + return min_; + } + int max() { + ABSL_DCHECK_EQ(op_, kRegexpRepeat); + return max_; + } + Rune rune() { + ABSL_DCHECK_EQ(op_, kRegexpLiteral); + return rune_; + } + CharClass* cc() { + ABSL_DCHECK_EQ(op_, kRegexpCharClass); + return cc_; + } + int cap() { + ABSL_DCHECK_EQ(op_, kRegexpCapture); + return cap_; + } + const std::string* name() { + ABSL_DCHECK_EQ(op_, kRegexpCapture); + return name_; + } + Rune* runes() { + ABSL_DCHECK_EQ(op_, kRegexpLiteralString); + return runes_; + } + int nrunes() { + ABSL_DCHECK_EQ(op_, kRegexpLiteralString); + return nrunes_; + } + int match_id() { + ABSL_DCHECK_EQ(op_, kRegexpHaveMatch); + return match_id_; + } // Increments reference count, returns object as convenience. Regexp* Incref(); @@ -516,7 +543,7 @@ class Regexp { // Allocate space for n sub-regexps. void AllocSub(int n) { - DCHECK(n >= 0 && static_cast(n) == n); + ABSL_DCHECK(n >= 0 && static_cast(n) == n); if (n > 1) submany_ = new Regexp*[n]; nsub_ = static_cast(n); diff --git a/re2/set.cc b/re2/set.cc index 4f269075e..b6ff03019 100644 --- a/re2/set.cc +++ b/re2/set.cc @@ -9,8 +9,8 @@ #include #include -#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/re2.h" @@ -53,7 +53,7 @@ RE2::Set& RE2::Set::operator=(Set&& other) { int RE2::Set::Add(absl::string_view pattern, std::string* error) { if (compiled_) { - LOG(DFATAL) << "RE2::Set::Add() called after compiling"; + ABSL_LOG(DFATAL) << "RE2::Set::Add() called after compiling"; return -1; } @@ -65,7 +65,7 @@ int RE2::Set::Add(absl::string_view pattern, std::string* error) { if (error != NULL) *error = status.Text(); if (options_.log_errors()) - LOG(ERROR) << "Error parsing '" << pattern << "': " << status.Text(); + ABSL_LOG(ERROR) << "Error parsing '" << pattern << "': " << status.Text(); return -1; } @@ -92,7 +92,7 @@ int RE2::Set::Add(absl::string_view pattern, std::string* error) { bool RE2::Set::Compile() { if (compiled_) { - LOG(DFATAL) << "RE2::Set::Compile() called more than once"; + ABSL_LOG(DFATAL) << "RE2::Set::Compile() called more than once"; return false; } compiled_ = true; @@ -129,7 +129,7 @@ bool RE2::Set::Match(absl::string_view text, std::vector* v, if (!compiled_) { if (error_info != NULL) error_info->kind = kNotCompiled; - LOG(DFATAL) << "RE2::Set::Match() called before compiling"; + ABSL_LOG(DFATAL) << "RE2::Set::Match() called before compiling"; return false; } #ifdef RE2_HAVE_THREAD_LOCAL @@ -145,10 +145,10 @@ bool RE2::Set::Match(absl::string_view text, std::vector* v, NULL, &dfa_failed, matches.get()); if (dfa_failed) { if (options_.log_errors()) - LOG(ERROR) << "DFA out of memory: " - << "program size " << prog_->size() << ", " - << "list count " << prog_->list_count() << ", " - << "bytemap range " << prog_->bytemap_range(); + ABSL_LOG(ERROR) << "DFA out of memory: " + << "program size " << prog_->size() << ", " + << "list count " << prog_->list_count() << ", " + << "bytemap range " << prog_->bytemap_range(); if (error_info != NULL) error_info->kind = kOutOfMemory; return false; @@ -162,7 +162,7 @@ bool RE2::Set::Match(absl::string_view text, std::vector* v, if (matches->empty()) { if (error_info != NULL) error_info->kind = kInconsistent; - LOG(DFATAL) << "RE2::Set::Match() matched, but no matches returned?!"; + ABSL_LOG(DFATAL) << "RE2::Set::Match() matched, but no matches returned"; return false; } v->assign(matches->begin(), matches->end()); diff --git a/re2/simplify.cc b/re2/simplify.cc index 06966128d..b88093605 100644 --- a/re2/simplify.cc +++ b/re2/simplify.cc @@ -9,8 +9,8 @@ #include #include -#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/regexp.h" @@ -95,7 +95,7 @@ bool Regexp::ComputeSimple() { case kRegexpRepeat: return false; } - LOG(DFATAL) << "Case not handled in ComputeSimple: " << op_; + ABSL_LOG(DFATAL) << "Case not handled in ComputeSimple: " << op_; return false; } @@ -223,7 +223,7 @@ Regexp* CoalesceWalker::Copy(Regexp* re) { Regexp* CoalesceWalker::ShortVisit(Regexp* re, Regexp* parent_arg) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "CoalesceWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "CoalesceWalker::ShortVisit called"; #endif return re->Incref(); } @@ -373,7 +373,7 @@ void CoalesceWalker::DoCoalesce(Regexp** r1ptr, Regexp** r2ptr) { default: nre->Decref(); - LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op(); + ABSL_LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op(); return; } @@ -434,7 +434,7 @@ void CoalesceWalker::DoCoalesce(Regexp** r1ptr, Regexp** r2ptr) { default: nre->Decref(); - LOG(DFATAL) << "DoCoalesce failed: r2->op() is " << r2->op(); + ABSL_LOG(DFATAL) << "DoCoalesce failed: r2->op() is " << r2->op(); return; } @@ -449,7 +449,7 @@ Regexp* SimplifyWalker::Copy(Regexp* re) { Regexp* SimplifyWalker::ShortVisit(Regexp* re, Regexp* parent_arg) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "SimplifyWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "SimplifyWalker::ShortVisit called"; #endif return re->Incref(); } @@ -565,7 +565,7 @@ Regexp* SimplifyWalker::PostVisit(Regexp* re, } } - LOG(ERROR) << "Simplify case not handled: " << re->op(); + ABSL_LOG(ERROR) << "Simplify case not handled: " << re->op(); return re->Incref(); } @@ -662,7 +662,8 @@ Regexp* SimplifyWalker::SimplifyRepeat(Regexp* re, int min, int max, if (nre == NULL) { // Some degenerate case, like min > max, or min < max < 0. // This shouldn't happen, because the parser rejects such regexps. - LOG(DFATAL) << "Malformed repeat " << re->ToString() << " " << min << " " << max; + ABSL_LOG(DFATAL) << "Malformed repeat of " << re->ToString() + << " min " << min << " max " << max; return new Regexp(kRegexpNoMatch, f); } diff --git a/re2/testing/backtrack.cc b/re2/testing/backtrack.cc index 2ea98e8e6..790a50d02 100644 --- a/re2/testing/backtrack.cc +++ b/re2/testing/backtrack.cc @@ -13,7 +13,7 @@ // THIS CODE SHOULD NEVER BE USED IN PRODUCTION: // - It uses a ton of memory. // - It uses a ton of stack. -// - It uses CHECK and LOG(FATAL). +// - It uses ABSL_CHECK() and ABSL_LOG(FATAL). // - It implements unanchored search by repeated anchored search. // // On the other hand, it is very simple and a good reference @@ -28,8 +28,8 @@ #include #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" #include "re2/pod_array.h" #include "re2/prog.h" #include "re2/regexp.h" @@ -112,7 +112,7 @@ bool Backtracker::Search(absl::string_view text, absl::string_view context, endmatch_ = prog_->anchor_end(); submatch_ = submatch; nsubmatch_ = nsubmatch; - CHECK_LT(2*nsubmatch_, static_cast(ABSL_ARRAYSIZE(cap_))); + ABSL_CHECK_LT(2*nsubmatch_, static_cast(ABSL_ARRAYSIZE(cap_))); memset(cap_, 0, sizeof cap_); // We use submatch_[0] for our own bookkeeping, @@ -158,10 +158,10 @@ bool Backtracker::Visit(int id, const char* p) { // Check bitmap. If we've already explored from here, // either it didn't match or it did but we're hoping for a better match. // Either way, don't go down that road again. - CHECK(p <= text_.data() + text_.size()); + ABSL_CHECK(p <= text_.data() + text_.size()); int n = id * static_cast(text_.size()+1) + static_cast(p-text_.data()); - CHECK_LT(n/32, visited_.size()); + ABSL_CHECK_LT(n/32, visited_.size()); if (visited_[n/32] & (1 << (n&31))) return false; visited_[n/32] |= 1 << (n&31); @@ -189,7 +189,7 @@ bool Backtracker::Try(int id, const char* p) { Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: - LOG(FATAL) << "Unexpected opcode: " << (int)ip->opcode(); + ABSL_LOG(FATAL) << "Unexpected opcode: " << ip->opcode(); return false; // not reached case kInstAltMatch: diff --git a/re2/testing/compile_test.cc b/re2/testing/compile_test.cc index 532f8965b..2f7a94d51 100644 --- a/re2/testing/compile_test.cc +++ b/re2/testing/compile_test.cc @@ -7,8 +7,8 @@ #include #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" #include "gtest/gtest.h" #include "re2/regexp.h" #include "re2/prog.h" @@ -133,13 +133,13 @@ TEST(TestRegexpCompileToProg, Simple) { const re2::Test& t = tests[i]; Regexp* re = Regexp::Parse(t.regexp, Regexp::PerlX|Regexp::Latin1, NULL); if (re == NULL) { - LOG(ERROR) << "Cannot parse: " << t.regexp; + ABSL_LOG(ERROR) << "Cannot parse: " << t.regexp; failed++; continue; } Prog* prog = re->CompileToProg(0); if (prog == NULL) { - LOG(ERROR) << "Cannot compile: " << t.regexp; + ABSL_LOG(ERROR) << "Cannot compile: " << t.regexp; re->Decref(); failed++; continue; @@ -147,9 +147,9 @@ TEST(TestRegexpCompileToProg, Simple) { ASSERT_TRUE(re->CompileToProg(1) == NULL); std::string s = prog->Dump(); if (s != t.code) { - LOG(ERROR) << "Incorrect compiled code for: " << t.regexp; - LOG(ERROR) << "Want:\n" << t.code; - LOG(ERROR) << "Got:\n" << s; + ABSL_LOG(ERROR) << "Incorrect compiled code for: " << t.regexp; + ABSL_LOG(ERROR) << "Want:\n" << t.code; + ABSL_LOG(ERROR) << "Got:\n" << s; failed++; } delete prog; diff --git a/re2/testing/dfa_test.cc b/re2/testing/dfa_test.cc index aa9546569..1b8f0f28c 100644 --- a/re2/testing/dfa_test.cc +++ b/re2/testing/dfa_test.cc @@ -9,8 +9,8 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "util/malloc_counter.h" @@ -112,10 +112,10 @@ TEST(SingleThreaded, BuildEntireDFA) { delete prog; } if (UsingMallocCounter) { - //LOG(INFO) << "limit " << limit << ", " - // << "prog usage " << progusage << ", " - // << "DFA budget " << dfamem << ", " - // << "total " << usage; + //ABSL_LOG(INFO) << "limit " << limit << ", " + // << "prog usage " << progusage << ", " + // << "DFA budget " << dfamem << ", " + // << "total " << usage; // Tolerate +/- 10%. ASSERT_GT(usage, limit*9/10); ASSERT_LT(usage, limit*11/10); @@ -190,8 +190,8 @@ TEST(SingleThreaded, SearchDFA) { delete prog; } if (UsingMallocCounter) { - //LOG(INFO) << "usage " << usage << ", " - // << "peak usage " << peak_usage; + //ABSL_LOG(INFO) << "usage " << usage << ", " + // << "peak usage " << peak_usage; ASSERT_LT(usage, 1<SearchDFA(t.text, absl::string_view(), Prog::kUnanchored, Prog::kFirstMatch, NULL, &failed, NULL); if (matched != t.match) { - LOG(ERROR) << t.regexp << " on " << t.text << ": want " << t.match; + ABSL_LOG(ERROR) << t.regexp << " on " << t.text << ": want " << t.match; nfail++; } delete prog; @@ -361,8 +361,9 @@ TEST(DFA, Callback) { dump += match ? "]]" : "]"; }); if (dump != t.dump) { - LOG(ERROR) << t.regexp << " bytemap:\n" << prog->DumpByteMap(); - LOG(ERROR) << t.regexp << " dump:\ngot " << dump << "\nwant " << t.dump; + ABSL_LOG(ERROR) << t.regexp << " bytemap:\n" << prog->DumpByteMap(); + ABSL_LOG(ERROR) << t.regexp << " dump:\n" << "got " << dump << "\n" + << "want " << t.dump; nfail++; } delete prog; diff --git a/re2/testing/dump.cc b/re2/testing/dump.cc index 074c6a20a..9beda81d5 100644 --- a/re2/testing/dump.cc +++ b/re2/testing/dump.cc @@ -19,8 +19,8 @@ #include #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" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "util/utf.h" @@ -130,7 +130,7 @@ static void DumpRegexpAppending(Regexp* re, std::string* s) { break; case kRegexpCapture: if (re->cap() == 0) - LOG(DFATAL) << "kRegexpCapture cap() == 0"; + ABSL_LOG(DFATAL) << "kRegexpCapture cap() == 0"; if (re->name()) { s->append(*re->name()); s->append(":"); @@ -162,7 +162,7 @@ static void DumpRegexpAppending(Regexp* re, std::string* s) { std::string Regexp::Dump() { // Make sure that we are being called from a unit test. // Should cause a link error if used outside of testing. - CHECK(!::testing::TempDir().empty()); + ABSL_CHECK(!::testing::TempDir().empty()); std::string s; DumpRegexpAppending(this, &s); diff --git a/re2/testing/exhaustive_tester.cc b/re2/testing/exhaustive_tester.cc index 4d1ff0f02..7d63be902 100644 --- a/re2/testing/exhaustive_tester.cc +++ b/re2/testing/exhaustive_tester.cc @@ -15,8 +15,8 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "re2/testing/exhaustive_tester.h" @@ -41,7 +41,7 @@ static char* escape(absl::string_view sp) { *p++ = '\"'; for (size_t i = 0; i < sp.size(); i++) { if(p+5 >= buf+sizeof buf) - LOG(FATAL) << "ExhaustiveTester escape: too long"; + ABSL_LOG(FATAL) << "ExhaustiveTester escape: too long"; if(sp[i] == '\\' || sp[i] == '\"') { *p++ = '\\'; *p++ = sp[i]; @@ -83,7 +83,7 @@ void ExhaustiveTester::HandleRegexp(const std::string& const_regexp) { std::string regexp = const_regexp; if (!topwrapper_.empty()) { auto fmt = absl::ParsedFormat<'s'>::New(topwrapper_); - CHECK(fmt != nullptr); + ABSL_CHECK(fmt != nullptr); regexp = absl::StrFormat(*fmt, regexp); } @@ -96,7 +96,7 @@ void ExhaustiveTester::HandleRegexp(const std::string& const_regexp) { // Write out test cases and answers for use in testing // other implementations, such as Go's regexp package. if (randomstrings_) - LOG(ERROR) << "Cannot log with random strings."; + ABSL_LOG(ERROR) << "Cannot log with random strings."; if (regexps_ == 1) { // first absl::PrintF("strings\n"); strgen_.Reset(); diff --git a/re2/testing/filtered_re2_test.cc b/re2/testing/filtered_re2_test.cc index aea311b58..172389d9e 100644 --- a/re2/testing/filtered_re2_test.cc +++ b/re2/testing/filtered_re2_test.cc @@ -10,8 +10,8 @@ #include #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" #include "gtest/gtest.h" #include "re2/filtered_re2.h" #include "re2/re2.h" @@ -173,13 +173,13 @@ bool CheckExpectedAtoms(const char* atoms[], pass = pass && expected[i] == v->atoms[i]; if (!pass) { - LOG(ERROR) << "Failed " << testname; - LOG(ERROR) << "Expected #atoms = " << expected.size(); + ABSL_LOG(ERROR) << "Failed " << testname; + ABSL_LOG(ERROR) << "Expected #atoms = " << expected.size(); for (size_t i = 0; i < expected.size(); i++) - LOG(ERROR) << expected[i]; - LOG(ERROR) << "Found #atoms = " << v->atoms.size(); + ABSL_LOG(ERROR) << expected[i]; + ABSL_LOG(ERROR) << "Found #atoms = " << v->atoms.size(); for (size_t i = 0; i < v->atoms.size(); i++) - LOG(ERROR) << v->atoms[i]; + ABSL_LOG(ERROR) << v->atoms[i]; } return pass; @@ -274,9 +274,9 @@ TEST(FilteredRE2Test, MatchTests) { atoms.push_back("yyy"); atoms.push_back("yyyzzz"); FindAtomIndices(v.atoms, atoms, &atom_ids); - LOG(INFO) << "S: " << atom_ids.size(); + ABSL_LOG(INFO) << "S: " << atom_ids.size(); for (size_t i = 0; i < atom_ids.size(); i++) - LOG(INFO) << "i: " << i << " : " << atom_ids[i]; + ABSL_LOG(INFO) << "i: " << i << " : " << atom_ids[i]; v.f.AllMatches(text, atom_ids, &matching_regexps); EXPECT_EQ(2, matching_regexps.size()); } diff --git a/re2/testing/mimics_pcre_test.cc b/re2/testing/mimics_pcre_test.cc index d12e511c7..72e7feea5 100644 --- a/re2/testing/mimics_pcre_test.cc +++ b/re2/testing/mimics_pcre_test.cc @@ -3,8 +3,8 @@ // license that can be found in the LICENSE file. #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" #include "gtest/gtest.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/null_walker.cc b/re2/testing/null_walker.cc index 4e64f823c..da54c28b8 100644 --- a/re2/testing/null_walker.cc +++ b/re2/testing/null_walker.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" #include "re2/walker-inl.h" @@ -22,7 +22,7 @@ class NullWalker : public Regexp::Walker { virtual bool ShortVisit(Regexp* re, bool a) { // Should never be called: we use Walk(), not WalkExponential(). #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - LOG(DFATAL) << "NullWalker::ShortVisit called"; + ABSL_LOG(DFATAL) << "NullWalker::ShortVisit called"; #endif return a; } diff --git a/re2/testing/parse_test.cc b/re2/testing/parse_test.cc index 350720081..e7838953e 100644 --- a/re2/testing/parse_test.cc +++ b/re2/testing/parse_test.cc @@ -7,8 +7,8 @@ #include #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" #include "gtest/gtest.h" #include "re2/regexp.h" @@ -521,7 +521,7 @@ TEST(TestToString, EquivalentParse) { std::string ss = nre->Dump(); std::string tt = nre->ToString(); if (s != ss || t != tt) - LOG(INFO) << "ToString(" << tests[i].regexp << ") = " << t; + ABSL_LOG(INFO) << "ToString(" << tests[i].regexp << ") = " << t; EXPECT_EQ(s, ss); EXPECT_EQ(t, tt); nre->Decref(); diff --git a/re2/testing/possible_match_test.cc b/re2/testing/possible_match_test.cc index 16e169d04..e6073ef0d 100644 --- a/re2/testing/possible_match_test.cc +++ b/re2/testing/possible_match_test.cc @@ -7,8 +7,8 @@ #include #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" #include "absl/strings/escaping.h" #include "gtest/gtest.h" #include "re2/prog.h" @@ -114,7 +114,7 @@ TEST(PossibleMatchRange, HandWritten) { const PrefixTest& t = tests[i]; std::string min, max; if (j == 0) { - LOG(INFO) << "Checking regexp=" << absl::CEscape(t.regexp); + ABSL_LOG(INFO) << "Checking regexp=" << absl::CEscape(t.regexp); Regexp* re = Regexp::Parse(t.regexp, Regexp::LikePerl, NULL); ASSERT_TRUE(re != NULL); Prog* prog = re->CompileToProg(0); @@ -203,7 +203,7 @@ class PossibleMatchTester : public RegexpGenerator { void PossibleMatchTester::HandleRegexp(const std::string& regexp) { regexps_++; - VLOG(3) << absl::CEscape(regexp); + ABSL_VLOG(3) << absl::CEscape(regexp); RE2 re(regexp, RE2::Latin1); ASSERT_EQ(re.error(), ""); @@ -215,7 +215,8 @@ void PossibleMatchTester::HandleRegexp(const std::string& regexp) { // complicated expressions. if(strstr(regexp.c_str(), "\\C*")) return; - LOG(QFATAL) << "PossibleMatchRange failed on: " << absl::CEscape(regexp); + ABSL_LOG(QFATAL) << "PossibleMatchRange failed on: " + << absl::CEscape(regexp); } strgen_.Reset(); @@ -242,8 +243,8 @@ TEST(PossibleMatchRange, Exhaustive) { RegexpGenerator::EgrepOps(), stringlen, Explode("ab4")); t.Generate(); - LOG(INFO) << t.regexps() << " regexps, " - << t.tests() << " tests"; + ABSL_LOG(INFO) << t.regexps() << " regexps, " + << t.tests() << " tests"; } } // namespace re2 diff --git a/re2/testing/re2_arg_test.cc b/re2/testing/re2_arg_test.cc index a9b044d73..db1868aeb 100644 --- a/re2/testing/re2_arg_test.cc +++ b/re2/testing/re2_arg_test.cc @@ -11,8 +11,8 @@ #include #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" #include "gtest/gtest.h" #include "re2/re2.h" @@ -138,7 +138,7 @@ TEST(RE2ArgTest, Uint64Test) { TEST(RE2ArgTest, ParseFromTest) { struct { bool ParseFrom(const char* str, size_t n) { - LOG(INFO) << "str = " << str << ", n = " << n; + ABSL_LOG(INFO) << "str = " << str << ", n = " << n; return true; } } obj1; @@ -147,7 +147,7 @@ TEST(RE2ArgTest, ParseFromTest) { struct { bool ParseFrom(const char* str, size_t n) { - LOG(INFO) << "str = " << str << ", n = " << n; + ABSL_LOG(INFO) << "str = " << str << ", n = " << n; return false; } // Ensure that RE2::Arg works even with overloaded ParseFrom(). diff --git a/re2/testing/re2_test.cc b/re2/testing/re2_test.cc index 95bf461fb..0a602070f 100644 --- a/re2/testing/re2_test.cc +++ b/re2/testing/re2_test.cc @@ -19,8 +19,8 @@ #endif #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" #include "absl/strings/str_format.h" #include "gtest/gtest.h" #include "re2/re2.h" @@ -774,7 +774,7 @@ TEST(RE2, NULTerminated) { v = static_cast(mmap(NULL, 2*pagesize, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0)); ASSERT_TRUE(v != reinterpret_cast(-1)); - LOG(INFO) << "Memory at " << (void*)v; + ABSL_LOG(INFO) << "Memory at " << reinterpret_cast(v); ASSERT_EQ(munmap(v + pagesize, pagesize), 0) << " error " << errno; v[pagesize - 1] = '1'; @@ -1563,7 +1563,7 @@ TEST(RE2, Bug18391750) { TEST(RE2, Bug18458852) { // Bug in parser accepting invalid (too large) rune, - // causing compiler to fail in DCHECK in UTF-8 + // causing compiler to fail in ABSL_DCHECK() in UTF-8 // character class code. const char b[] = { (char)0x28, (char)0x05, (char)0x05, (char)0x41, (char)0x41, (char)0x28, @@ -1599,7 +1599,7 @@ TEST(RE2, Bug18523943) { TEST(RE2, Bug21371806) { // Bug in parser accepting Unicode groups in Latin-1 mode, - // causing compiler to fail in DCHECK in prog.cc. + // causing compiler to fail in ABSL_DCHECK() in prog.cc. RE2::Options opt; opt.set_encoding(RE2::Options::EncodingLatin1); diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc index 319289558..33211fe0d 100644 --- a/re2/testing/regexp_benchmark.cc +++ b/re2/testing/regexp_benchmark.cc @@ -13,8 +13,8 @@ #include "absl/container/flat_hash_map.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "absl/synchronization/mutex.h" #include "benchmark/benchmark.h" @@ -35,21 +35,22 @@ namespace re2 { void Test() { Regexp* re = Regexp::Parse("(\\d+)-(\\d+)-(\\d+)", Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->CanBitState()); const char* text = "650-253-0001"; absl::string_view sp[4]; - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); - CHECK_EQ(sp[0], "650-253-0001"); - CHECK_EQ(sp[1], "650"); - CHECK_EQ(sp[2], "253"); - CHECK_EQ(sp[3], "0001"); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, + sp, 4)); + ABSL_CHECK_EQ(sp[0], "650-253-0001"); + ABSL_CHECK_EQ(sp[1], "650"); + ABSL_CHECK_EQ(sp[2], "253"); + ABSL_CHECK_EQ(sp[3], "0001"); delete prog; re->Decref(); - LOG(INFO) << "test passed\n"; + ABSL_LOG(INFO) << "test passed\n"; } void MemoryUsage() { @@ -58,23 +59,25 @@ void MemoryUsage() { { MallocCounter mc(MallocCounter::THIS_THREAD_ONLY); Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); - // Can't pass mc.HeapGrowth() and mc.PeakHeapGrowth() to LOG(INFO) directly, - // because LOG(INFO) might do a big allocation before they get evaluated. + ABSL_CHECK(re); + // Can't pass mc.HeapGrowth() and mc.PeakHeapGrowth() to ABSL_LOG(INFO) + // directly because ABSL_LOG(INFO) might do a big allocation before they + // get evaluated. absl::FPrintF(stderr, "Regexp: %7d bytes (peak=%d)\n", mc.HeapGrowth(), mc.PeakHeapGrowth()); mc.Reset(); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->CanBitState()); absl::FPrintF(stderr, "Prog: %7d bytes (peak=%d)\n", mc.HeapGrowth(), mc.PeakHeapGrowth()); mc.Reset(); absl::string_view sp[4]; - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); absl::FPrintF(stderr, "Search: %7d bytes (peak=%d)\n", mc.HeapGrowth(), mc.PeakHeapGrowth()); delete prog; @@ -169,7 +172,7 @@ std::string RandomText(int64_t nbytes) { } return text; }(); - CHECK_LE(nbytes, 16<<20); + ABSL_CHECK_LE(nbytes, 16<<20); return text->substr(0, nbytes); } @@ -320,8 +323,8 @@ void FindAndConsume(benchmark::State& state) { for (auto _ : state) { absl::string_view t = s; absl::string_view u; - CHECK(RE2::FindAndConsume(&t, re, &u)); - CHECK_EQ(u, "Hello World"); + ABSL_CHECK(RE2::FindAndConsume(&t, re, &u)); + ABSL_CHECK_EQ(u, "Hello World"); } state.SetBytesProcessed(state.iterations() * state.range(0)); } @@ -661,7 +664,7 @@ BENCHMARK(Parse_CachedSplitBig2_RE2)->ThreadRange(1, NumCPUs()); void ParseRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); re->Decref(); } } @@ -669,9 +672,9 @@ void ParseRegexp(benchmark::State& state, const std::string& regexp) { void SimplifyRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Regexp* sre = re->Simplify(); - CHECK(sre); + ABSL_CHECK(sre); sre->Decref(); re->Decref(); } @@ -679,7 +682,7 @@ void SimplifyRegexp(benchmark::State& state, const std::string& regexp) { void NullWalkRegexp(benchmark::State& state, const std::string& regexp) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); for (auto _ : state) { re->NullWalk(); } @@ -689,11 +692,11 @@ void NullWalkRegexp(benchmark::State& state, const std::string& regexp) { void SimplifyCompileRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Regexp* sre = re->Simplify(); - CHECK(sre); + ABSL_CHECK(sre); Prog* prog = sre->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); delete prog; sre->Decref(); re->Decref(); @@ -703,9 +706,9 @@ void SimplifyCompileRegexp(benchmark::State& state, const std::string& regexp) { void CompileRegexp(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); delete prog; re->Decref(); } @@ -713,10 +716,10 @@ void CompileRegexp(benchmark::State& state, const std::string& regexp) { void CompileToProg(benchmark::State& state, const std::string& regexp) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); for (auto _ : state) { Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); delete prog; } re->Decref(); @@ -724,9 +727,9 @@ void CompileToProg(benchmark::State& state, const std::string& regexp) { void CompileByteMap(benchmark::State& state, const std::string& regexp) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); for (auto _ : state) { prog->ComputeByteMap(); } @@ -737,14 +740,14 @@ void CompileByteMap(benchmark::State& state, const std::string& regexp) { void CompilePCRE(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); } } void CompileRE2(benchmark::State& state, const std::string& regexp) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); } } @@ -863,14 +866,14 @@ void SearchDFA(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); bool failed = false; - CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, - Prog::kFirstMatch, NULL, &failed, NULL), - expect_match); - CHECK(!failed); + ABSL_CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, + Prog::kFirstMatch, NULL, &failed, NULL), + expect_match); + ABSL_CHECK(!failed); delete prog; re->Decref(); } @@ -881,12 +884,12 @@ void SearchNFA(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, - Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK(prog); + ABSL_CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, + Prog::kFirstMatch, NULL, 0), + expect_match); delete prog; re->Decref(); } @@ -897,12 +900,13 @@ void SearchOnePass(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); - CHECK_EQ(prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); + ABSL_CHECK_EQ( + prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); delete prog; re->Decref(); } @@ -913,12 +917,13 @@ void SearchBitState(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->CanBitState()); - CHECK_EQ(prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK(prog); + ABSL_CHECK(prog->CanBitState()); + ABSL_CHECK_EQ( + prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); delete prog; re->Decref(); } @@ -929,11 +934,12 @@ void SearchPCRE(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); - if (anchor == Prog::kAnchored) - CHECK_EQ(PCRE::FullMatch(text, re), expect_match); - else - CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + ABSL_CHECK_EQ(re.error(), ""); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(PCRE::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + } } } @@ -942,11 +948,12 @@ void SearchRE2(benchmark::State& state, const char* regexp, bool expect_match) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); - if (anchor == Prog::kAnchored) - CHECK_EQ(RE2::FullMatch(text, re), expect_match); - else - CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + ABSL_CHECK_EQ(re.error(), ""); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(RE2::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + } } } @@ -961,9 +968,9 @@ Prog* GetCachedProg(const char* regexp) { Prog* prog = cache[regexp]; if (prog == NULL) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); prog = re->CompileToProg(int64_t{1}<<31); // mostly for the DFA - CHECK(prog); + ABSL_CHECK(prog); cache[regexp] = prog; re->Decref(); // We must call this here - while we have exclusive access. @@ -979,7 +986,7 @@ PCRE* GetCachedPCRE(const char* regexp) { PCRE* re = cache[regexp]; if (re == NULL) { re = new PCRE(regexp, PCRE::UTF8); - CHECK_EQ(re->error(), ""); + ABSL_CHECK_EQ(re->error(), ""); cache[regexp] = re; } return re; @@ -992,7 +999,7 @@ RE2* GetCachedRE2(const char* regexp) { RE2* re = cache[regexp]; if (re == NULL) { re = new RE2(regexp); - CHECK_EQ(re->error(), ""); + ABSL_CHECK_EQ(re->error(), ""); cache[regexp] = re; } return re; @@ -1004,10 +1011,10 @@ void SearchCachedDFA(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); for (auto _ : state) { bool failed = false; - CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, + ABSL_CHECK_EQ(prog->SearchDFA(text, absl::string_view(), anchor, Prog::kFirstMatch, NULL, &failed, NULL), expect_match); - CHECK(!failed); + ABSL_CHECK(!failed); } } @@ -1016,7 +1023,7 @@ void SearchCachedNFA(benchmark::State& state, const char* regexp, bool expect_match) { Prog* prog = GetCachedProg(regexp); for (auto _ : state) { - CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, + ABSL_CHECK_EQ(prog->SearchNFA(text, absl::string_view(), anchor, Prog::kFirstMatch, NULL, 0), expect_match); } @@ -1026,10 +1033,11 @@ void SearchCachedOnePass(benchmark::State& state, const char* regexp, absl::string_view text, Prog::Anchor anchor, bool expect_match) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->IsOnePass()); for (auto _ : state) { - CHECK_EQ(prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK_EQ( + prog->SearchOnePass(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); } } @@ -1037,10 +1045,11 @@ void SearchCachedBitState(benchmark::State& state, const char* regexp, absl::string_view text, Prog::Anchor anchor, bool expect_match) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog->CanBitState()); for (auto _ : state) { - CHECK_EQ(prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), - expect_match); + ABSL_CHECK_EQ( + prog->SearchBitState(text, text, anchor, Prog::kFirstMatch, NULL, 0), + expect_match); } } @@ -1049,10 +1058,11 @@ void SearchCachedPCRE(benchmark::State& state, const char* regexp, bool expect_match) { PCRE& re = *GetCachedPCRE(regexp); for (auto _ : state) { - if (anchor == Prog::kAnchored) - CHECK_EQ(PCRE::FullMatch(text, re), expect_match); - else - CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(PCRE::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(PCRE::PartialMatch(text, re), expect_match); + } } } @@ -1061,10 +1071,11 @@ void SearchCachedRE2(benchmark::State& state, const char* regexp, bool expect_match) { RE2& re = *GetCachedRE2(regexp); for (auto _ : state) { - if (anchor == Prog::kAnchored) - CHECK_EQ(RE2::FullMatch(text, re), expect_match); - else - CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + if (anchor == Prog::kAnchored) { + ABSL_CHECK_EQ(RE2::FullMatch(text, re), expect_match); + } else { + ABSL_CHECK_EQ(RE2::PartialMatch(text, re), expect_match); + } } } @@ -1075,11 +1086,11 @@ void Parse3NFA(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); @@ -1090,12 +1101,13 @@ void Parse3OnePass(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); } @@ -1105,12 +1117,13 @@ void Parse3BitState(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); } @@ -1120,11 +1133,12 @@ void Parse3Backtrack(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); absl::string_view sp[4]; // 4 because sp[0] is whole match. - CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); delete prog; re->Decref(); } @@ -1134,9 +1148,9 @@ void Parse3PCRE(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1, sp2, sp3; - CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1144,9 +1158,9 @@ void Parse3RE2(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1, sp2, sp3; - CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1155,7 +1169,7 @@ void Parse3CachedNFA(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, Prog::kFullMatch, sp, 4)); } } @@ -1163,20 +1177,22 @@ void Parse3CachedNFA(benchmark::State& state, const char* regexp, void Parse3CachedOnePass(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); } } void Parse3CachedBitState(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); } } @@ -1185,7 +1201,8 @@ void Parse3CachedBacktrack(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[4]; // 4 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 4)); + ABSL_CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 4)); } } @@ -1194,7 +1211,7 @@ void Parse3CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); absl::string_view sp1, sp2, sp3; for (auto _ : state) { - CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1203,7 +1220,7 @@ void Parse3CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); absl::string_view sp1, sp2, sp3; for (auto _ : state) { - CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1, &sp2, &sp3)); } } @@ -1214,12 +1231,12 @@ void Parse1NFA(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); + ABSL_CHECK(prog); absl::string_view sp[2]; // 2 because sp[0] is whole match. - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, - Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + Prog::kFullMatch, sp, 2)); delete prog; re->Decref(); } @@ -1229,12 +1246,13 @@ void Parse1OnePass(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[2]; // 2 because sp[0] is whole match. - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); delete prog; re->Decref(); } @@ -1244,12 +1262,13 @@ void Parse1BitState(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { Regexp* re = Regexp::Parse(regexp, Regexp::LikePerl, NULL); - CHECK(re); + ABSL_CHECK(re); Prog* prog = re->CompileToProg(0); - CHECK(prog); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[2]; // 2 because sp[0] is whole match. - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); delete prog; re->Decref(); } @@ -1259,9 +1278,9 @@ void Parse1PCRE(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { PCRE re(regexp, PCRE::UTF8); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1; - CHECK(PCRE::FullMatch(text, re, &sp1)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1)); } } @@ -1269,9 +1288,9 @@ void Parse1RE2(benchmark::State& state, const char* regexp, absl::string_view text) { for (auto _ : state) { RE2 re(regexp); - CHECK_EQ(re.error(), ""); + ABSL_CHECK_EQ(re.error(), ""); absl::string_view sp1; - CHECK(RE2::FullMatch(text, re, &sp1)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1)); } } @@ -1280,7 +1299,7 @@ void Parse1CachedNFA(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, + ABSL_CHECK(prog->SearchNFA(text, absl::string_view(), Prog::kAnchored, Prog::kFullMatch, sp, 2)); } } @@ -1288,20 +1307,22 @@ void Parse1CachedNFA(benchmark::State& state, const char* regexp, void Parse1CachedOnePass(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->IsOnePass()); + ABSL_CHECK(prog->IsOnePass()); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchOnePass(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); } } void Parse1CachedBitState(benchmark::State& state, const char* regexp, absl::string_view text) { Prog* prog = GetCachedProg(regexp); - CHECK(prog->CanBitState()); + ABSL_CHECK(prog->CanBitState()); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->SearchBitState(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->SearchBitState(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); } } @@ -1310,7 +1331,8 @@ void Parse1CachedBacktrack(benchmark::State& state, const char* regexp, Prog* prog = GetCachedProg(regexp); absl::string_view sp[2]; // 2 because sp[0] is whole match. for (auto _ : state) { - CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, Prog::kFullMatch, sp, 2)); + ABSL_CHECK(prog->UnsafeSearchBacktrack(text, text, Prog::kAnchored, + Prog::kFullMatch, sp, 2)); } } @@ -1319,7 +1341,7 @@ void Parse1CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); absl::string_view sp1; for (auto _ : state) { - CHECK(PCRE::FullMatch(text, re, &sp1)); + ABSL_CHECK(PCRE::FullMatch(text, re, &sp1)); } } @@ -1328,7 +1350,7 @@ void Parse1CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); absl::string_view sp1; for (auto _ : state) { - CHECK(RE2::FullMatch(text, re, &sp1)); + ABSL_CHECK(RE2::FullMatch(text, re, &sp1)); } } @@ -1337,7 +1359,7 @@ void SearchParse2CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); for (auto _ : state) { absl::string_view sp1, sp2; - CHECK(PCRE::PartialMatch(text, re, &sp1, &sp2)); + ABSL_CHECK(PCRE::PartialMatch(text, re, &sp1, &sp2)); } } @@ -1346,7 +1368,7 @@ void SearchParse2CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); for (auto _ : state) { absl::string_view sp1, sp2; - CHECK(RE2::PartialMatch(text, re, &sp1, &sp2)); + ABSL_CHECK(RE2::PartialMatch(text, re, &sp1, &sp2)); } } @@ -1355,7 +1377,7 @@ void SearchParse1CachedPCRE(benchmark::State& state, const char* regexp, PCRE& re = *GetCachedPCRE(regexp); for (auto _ : state) { absl::string_view sp1; - CHECK(PCRE::PartialMatch(text, re, &sp1)); + ABSL_CHECK(PCRE::PartialMatch(text, re, &sp1)); } } @@ -1364,7 +1386,7 @@ void SearchParse1CachedRE2(benchmark::State& state, const char* regexp, RE2& re = *GetCachedRE2(regexp); for (auto _ : state) { absl::string_view sp1; - CHECK(RE2::PartialMatch(text, re, &sp1)); + ABSL_CHECK(RE2::PartialMatch(text, re, &sp1)); } } @@ -1500,7 +1522,7 @@ void FullMatchPCRE(benchmark::State& state, const char *regexp) { s += "ABCDEFGHIJ"; PCRE re(regexp); for (auto _ : state) { - CHECK(PCRE::FullMatch(s, re)); + ABSL_CHECK(PCRE::FullMatch(s, re)); } state.SetBytesProcessed(state.iterations() * state.range(0)); } @@ -1510,19 +1532,31 @@ void FullMatchRE2(benchmark::State& state, const char *regexp) { s += "ABCDEFGHIJ"; RE2 re(regexp, RE2::Latin1); for (auto _ : state) { - CHECK(RE2::FullMatch(s, re)); + ABSL_CHECK(RE2::FullMatch(s, re)); } state.SetBytesProcessed(state.iterations() * state.range(0)); } -void FullMatch_DotStar_CachedPCRE(benchmark::State& state) { FullMatchPCRE(state, "(?s).*"); } -void FullMatch_DotStar_CachedRE2(benchmark::State& state) { FullMatchRE2(state, "(?s).*"); } +void FullMatch_DotStar_CachedPCRE(benchmark::State& state) { + FullMatchPCRE(state, "(?s).*"); +} +void FullMatch_DotStar_CachedRE2(benchmark::State& state) { + FullMatchRE2(state, "(?s).*"); +} -void FullMatch_DotStarDollar_CachedPCRE(benchmark::State& state) { FullMatchPCRE(state, "(?s).*$"); } -void FullMatch_DotStarDollar_CachedRE2(benchmark::State& state) { FullMatchRE2(state, "(?s).*$"); } +void FullMatch_DotStarDollar_CachedPCRE(benchmark::State& state) { + FullMatchPCRE(state, "(?s).*$"); +} +void FullMatch_DotStarDollar_CachedRE2(benchmark::State& state) { + FullMatchRE2(state, "(?s).*$"); +} -void FullMatch_DotStarCapture_CachedPCRE(benchmark::State& state) { FullMatchPCRE(state, "(?s)((.*)()()($))"); } -void FullMatch_DotStarCapture_CachedRE2(benchmark::State& state) { FullMatchRE2(state, "(?s)((.*)()()($))"); } +void FullMatch_DotStarCapture_CachedPCRE(benchmark::State& state) { + FullMatchPCRE(state, "(?s)((.*)()()($))"); +} +void FullMatch_DotStarCapture_CachedRE2(benchmark::State& state) { + FullMatchRE2(state, "(?s)((.*)()()($))"); +} #ifdef USEPCRE BENCHMARK_RANGE(FullMatch_DotStar_CachedPCRE, 8, 2<<20); @@ -1545,7 +1579,7 @@ void PossibleMatchRangeCommon(benchmark::State& state, const char* regexp) { std::string max; const int kMaxLen = 16; for (auto _ : state) { - CHECK(re.PossibleMatchRange(&min, &max, kMaxLen)); + ABSL_CHECK(re.PossibleMatchRange(&min, &max, kMaxLen)); } } diff --git a/re2/testing/regexp_generator.cc b/re2/testing/regexp_generator.cc index 4d9346fb6..baf73d2d3 100644 --- a/re2/testing/regexp_generator.cc +++ b/re2/testing/regexp_generator.cc @@ -30,8 +30,8 @@ #include #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" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" #include "gtest/gtest.h" @@ -197,13 +197,13 @@ void RegexpGenerator::RunPostfix(const std::vector& post) { for (size_t i = 0; i < post.size(); i++) { switch (CountArgs(post[i])) { default: - LOG(FATAL) << "Bad operator: " << post[i]; + ABSL_LOG(FATAL) << "Bad operator: " << post[i]; case 0: regexps.push(post[i]); break; case 1: { auto fmt = absl::ParsedFormat<'s'>::New(post[i]); - CHECK(fmt != nullptr); + ABSL_CHECK(fmt != nullptr); std::string a = regexps.top(); regexps.pop(); regexps.push("(?:" + absl::StrFormat(*fmt, a) + ")"); @@ -211,7 +211,7 @@ void RegexpGenerator::RunPostfix(const std::vector& post) { } case 2: { auto fmt = absl::ParsedFormat<'s', 's'>::New(post[i]); - CHECK(fmt != nullptr); + ABSL_CHECK(fmt != nullptr); std::string b = regexps.top(); regexps.pop(); std::string a = regexps.top(); @@ -233,7 +233,7 @@ void RegexpGenerator::RunPostfix(const std::vector& post) { absl::PrintF(" %s\n", absl::CEscape(regexps.top())); regexps.pop(); } - LOG(FATAL) << "Bad regexp program."; + ABSL_LOG(FATAL) << "Bad regexp program."; } HandleRegexp(regexps.top()); diff --git a/re2/testing/regexp_test.cc b/re2/testing/regexp_test.cc index 54aa8ada9..1403a7477 100644 --- a/re2/testing/regexp_test.cc +++ b/re2/testing/regexp_test.cc @@ -9,8 +9,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/regexp.h" diff --git a/re2/testing/required_prefix_test.cc b/re2/testing/required_prefix_test.cc index 83e2c3e8e..bf46f7aa1 100644 --- a/re2/testing/required_prefix_test.cc +++ b/re2/testing/required_prefix_test.cc @@ -5,8 +5,8 @@ #include #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" #include "gtest/gtest.h" #include "re2/prog.h" #include "re2/regexp.h" diff --git a/re2/testing/set_test.cc b/re2/testing/set_test.cc index abd0fa48b..f8d301887 100644 --- a/re2/testing/set_test.cc +++ b/re2/testing/set_test.cc @@ -7,8 +7,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/re2.h" #include "re2/set.h" diff --git a/re2/testing/simplify_test.cc b/re2/testing/simplify_test.cc index 4a182d1a0..9c4e38c14 100644 --- a/re2/testing/simplify_test.cc +++ b/re2/testing/simplify_test.cc @@ -8,8 +8,8 @@ #include #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" #include "gtest/gtest.h" #include "re2/regexp.h" @@ -265,7 +265,7 @@ static Test tests[] = { TEST(TestSimplify, SimpleRegexps) { for (size_t i = 0; i < ABSL_ARRAYSIZE(tests); i++) { RegexpStatus status; - VLOG(1) << "Testing " << tests[i].regexp; + ABSL_VLOG(1) << "Testing " << tests[i].regexp; Regexp* re = Regexp::Parse(tests[i].regexp, Regexp::MatchNL | (Regexp::LikePerl & ~Regexp::OneLine), diff --git a/re2/testing/string_generator.cc b/re2/testing/string_generator.cc index 90ec46f1d..24397df1b 100644 --- a/re2/testing/string_generator.cc +++ b/re2/testing/string_generator.cc @@ -11,8 +11,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "gtest/gtest.h" #include "re2/testing/string_generator.h" @@ -83,7 +83,7 @@ bool StringGenerator::RandomDigits() { // after computing the string, so that it knows the answer // for subsequent HasNext() calls. absl::string_view StringGenerator::Next() { - CHECK(hasnext_); + ABSL_CHECK(hasnext_); if (generate_null_) { generate_null_ = false; sp_ = absl::string_view(); @@ -113,8 +113,8 @@ void StringGenerator::GenerateNULL() { } std::string DeBruijnString(int n) { - CHECK_GE(n, 1); - CHECK_LE(n, 29); + ABSL_CHECK_GE(n, 1); + ABSL_CHECK_LE(n, 29); const size_t size = size_t{1} << static_cast(n); const size_t mask = size - 1; std::vector did(size, false); @@ -132,10 +132,10 @@ std::string DeBruijnString(int n) { } else { s += '0'; } - CHECK(!did[bits]); + ABSL_CHECK(!did[bits]); did[bits] = true; } - CHECK_EQ(s.size(), static_cast(n - 1) + size); + ABSL_CHECK_EQ(s.size(), static_cast(n - 1) + size); return s; } diff --git a/re2/testing/tester.cc b/re2/testing/tester.cc index e0161be09..fc68a8a5a 100644 --- a/re2/testing/tester.cc +++ b/re2/testing/tester.cc @@ -11,8 +11,8 @@ #include "absl/base/macros.h" #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" #include "re2/testing/tester.h" @@ -51,9 +51,9 @@ const char* engine_names[kEngineMax] = { // Returns the name of the engine. static const char* EngineName(Engine e) { - CHECK_GE(e, 0); - CHECK_LT(e, ABSL_ARRAYSIZE(engine_names)); - CHECK(engine_names[e] != NULL); + ABSL_CHECK_GE(e, 0); + ABSL_CHECK_LT(e, ABSL_ARRAYSIZE(engine_names)); + ABSL_CHECK(engine_names[e] != NULL); return engine_names[e]; } @@ -74,12 +74,12 @@ static uint32_t Engines() { } if (cached_engines == 0) - LOG(INFO) << "Warning: no engines enabled."; + ABSL_LOG(INFO) << "Warning: no engines enabled."; if (!UsingPCRE) cached_engines &= ~(1<(0); i < kEngineMax; i++) { if (cached_engines & (1<NumCaptures(); prog_ = regexp_->CompileToProg(0); if (prog_ == NULL) { - LOG(INFO) << "Cannot compile: " << absl::CEscape(regexp_str_); + ABSL_LOG(INFO) << "Cannot compile: " << absl::CEscape(regexp_str_); error_ = true; return; } if (absl::GetFlag(FLAGS_dump_prog)) { - LOG(INFO) << "Prog for " - << " regexp " - << absl::CEscape(regexp_str_) - << " (" << FormatKind(kind_) - << ", " << FormatMode(flags_) - << ")\n" - << prog_->Dump(); + ABSL_LOG(INFO) << "Prog for " + << " regexp " + << absl::CEscape(regexp_str_) + << " (" << FormatKind(kind_) + << ", " << FormatMode(flags_) + << ")\n" + << prog_->Dump(); } // Compile regexp to reversed prog. Only needed for DFA engines. if (Engines() & ((1<CompileToReverseProg(0); if (rprog_ == NULL) { - LOG(INFO) << "Cannot reverse compile: " << absl::CEscape(regexp_str_); + ABSL_LOG(INFO) << "Cannot reverse compile: " + << absl::CEscape(regexp_str_); error_ = true; return; } if (absl::GetFlag(FLAGS_dump_rprog)) - LOG(INFO) << rprog_->Dump(); + ABSL_LOG(INFO) << rprog_->Dump(); } // Create re string that will be used for RE and RE2. @@ -258,7 +259,7 @@ TestInstance::TestInstance(absl::string_view regexp_str, Prog::MatchKind kind, options.set_longest_match(true); re2_ = new RE2(re, options); if (!re2_->error().empty()) { - LOG(INFO) << "Cannot RE2: " << absl::CEscape(re); + ABSL_LOG(INFO) << "Cannot RE2: " << absl::CEscape(re); error_ = true; return; } @@ -284,7 +285,7 @@ TestInstance::TestInstance(absl::string_view regexp_str, Prog::MatchKind kind, // add one more layer of parens. re_ = new PCRE("("+re+")", o); if (!re_->error().empty()) { - LOG(INFO) << "Cannot PCRE: " << absl::CEscape(re); + ABSL_LOG(INFO) << "Cannot PCRE: " << absl::CEscape(re); error_ = true; return; } @@ -319,7 +320,7 @@ void TestInstance::RunSearch(Engine type, absl::string_view orig_text, switch (type) { default: - LOG(FATAL) << "Bad RunSearch type: " << (int)type; + ABSL_LOG(FATAL) << "Bad RunSearch type: " << (int)type; case kEngineBacktrack: if (prog_ == NULL) { @@ -367,9 +368,9 @@ void TestInstance::RunSearch(Engine type, absl::string_view orig_text, Prog::kAnchored, Prog::kLongestMatch, result->submatch, &result->skipped, NULL)) { - LOG(ERROR) << "Reverse DFA inconsistency: " - << absl::CEscape(regexp_str_) - << " on " << absl::CEscape(text); + ABSL_LOG(ERROR) << "Reverse DFA inconsistency: " + << absl::CEscape(regexp_str_) + << " on " << absl::CEscape(text); result->matched = false; } } @@ -521,16 +522,16 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, if (correct.skipped) { if (regexp_ == NULL) return true; - LOG(ERROR) << "Skipped backtracking! " << absl::CEscape(regexp_str_) - << " " << FormatMode(flags_); + ABSL_LOG(ERROR) << "Skipped backtracking! " << absl::CEscape(regexp_str_) + << " " << FormatMode(flags_); return false; } - VLOG(1) << "Try: regexp " << absl::CEscape(regexp_str_) - << " text " << absl::CEscape(text) - << " (" << FormatKind(kind_) - << ", " << FormatAnchor(anchor) - << ", " << FormatMode(flags_) - << ")"; + ABSL_VLOG(1) << "Try: regexp " << absl::CEscape(regexp_str_) + << " text " << absl::CEscape(text) + << " (" << FormatKind(kind_) + << ", " << FormatAnchor(anchor) + << ", " << FormatMode(flags_) + << ")"; // Compare the others. bool all_okay = true; @@ -561,22 +562,22 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, context, anchor); if (r.matched != correct.matched) { if (r.matched) { - LOG(INFO) << " Should not match (but does)."; + ABSL_LOG(INFO) << " Should not match (but does)."; } else { - LOG(INFO) << " Should match (but does not)."; + ABSL_LOG(INFO) << " Should match (but does not)."; continue; } } for (int i = 0; i < 1+num_captures_; i++) { if (r.submatch[i].data() != correct.submatch[i].data() || r.submatch[i].size() != correct.submatch[i].size()) { - LOG(INFO) << + ABSL_LOG(INFO) << absl::StrFormat(" $%d: should be %s is %s", i, FormatCapture(text, correct.submatch[i]), FormatCapture(text, r.submatch[i])); } else { - LOG(INFO) << + ABSL_LOG(INFO) << absl::StrFormat(" $%d: %s ok", i, FormatCapture(text, r.submatch[i])); } @@ -588,7 +589,7 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, // and that is desirable because we want to enforce a global limit. static int max_regexp_failures = absl::GetFlag(FLAGS_max_regexp_failures); if (max_regexp_failures > 0 && --max_regexp_failures == 0) - LOG(QFATAL) << "Too many regexp failures."; + ABSL_LOG(QFATAL) << "Too many regexp failures."; } return all_okay; @@ -597,7 +598,7 @@ bool TestInstance::RunCase(absl::string_view text, absl::string_view context, void TestInstance::LogMatch(const char* prefix, Engine e, absl::string_view text, absl::string_view context, Prog::Anchor anchor) { - LOG(INFO) << prefix + ABSL_LOG(INFO) << prefix << EngineName(e) << " regexp " << absl::CEscape(regexp_str_) diff --git a/re2/tostring.cc b/re2/tostring.cc index e1e870ba7..c1ec69926 100644 --- a/re2/tostring.cc +++ b/re2/tostring.cc @@ -8,8 +8,8 @@ #include #include -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/utf.h" #include "re2/regexp.h" @@ -102,7 +102,7 @@ int ToStringWalker::PreVisit(Regexp* re, int parent_arg, bool* stop) { case kRegexpCapture: t_->append("("); if (re->cap() == 0) - LOG(DFATAL) << "kRegexpCapture cap() == 0"; + ABSL_LOG(DFATAL) << "kRegexpCapture cap() == 0"; if (re->name()) { t_->append("?P<"); t_->append(*re->name()); @@ -185,7 +185,7 @@ int ToStringWalker::PostVisit(Regexp* re, int parent_arg, int pre_arg, if ((*t_)[t_->size()-1] == '|') t_->erase(t_->size()-1); else - LOG(DFATAL) << "Bad final char: " << t_; + ABSL_LOG(DFATAL) << "Bad final char: " << t_; if (prec < PrecAlternate) t_->append(")"); break; diff --git a/re2/walker-inl.h b/re2/walker-inl.h index fe0dc8c7b..2283d6daf 100644 --- a/re2/walker-inl.h +++ b/re2/walker-inl.h @@ -16,8 +16,8 @@ #include #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" #include "re2/regexp.h" namespace re2 { @@ -148,7 +148,7 @@ template Regexp::Walker::~Walker() { // Logs DFATAL if stack is not already clear. template void Regexp::Walker::Reset() { if (!stack_.empty()) { - LOG(DFATAL) << "Stack not empty."; + ABSL_LOG(DFATAL) << "Stack not empty."; while (!stack_.empty()) { if (stack_.top().re->nsub_ > 1) delete[] stack_.top().child_args; @@ -162,7 +162,7 @@ template T Regexp::Walker::WalkInternal(Regexp* re, T top_arg, Reset(); if (re == NULL) { - LOG(DFATAL) << "Walk NULL"; + ABSL_LOG(DFATAL) << "Walk NULL"; return top_arg; } diff --git a/util/pcre.cc b/util/pcre.cc index 71e5329a4..94a88b7c9 100644 --- a/util/pcre.cc +++ b/util/pcre.cc @@ -16,8 +16,8 @@ #include #include "absl/flags/flag.h" -#include "absl/log/check.h" -#include "absl/log/log.h" +#include "absl/log/absl_check.h" +#include "absl/log/absl_log.h" #include "absl/strings/str_format.h" #include "util/pcre.h" @@ -26,7 +26,7 @@ #pragma GCC diagnostic ignored "-Wmisleading-indentation" #endif -#define PCREPORT(level) LOG(level) +#define PCREPORT(level) ABSL_LOG(level) // Default PCRE limits. // Defaults chosen to allow a plausible amount of CPU and diff --git a/util/pcre.h b/util/pcre.h index 846f30019..c0e944e02 100644 --- a/util/pcre.h +++ b/util/pcre.h @@ -39,10 +39,10 @@ // supplied pattern exactly. // // Example: successful match -// CHECK(PCRE::FullMatch("hello", "h.*o")); +// ABSL_CHECK(PCRE::FullMatch("hello", "h.*o")); // // Example: unsuccessful match (requires full match): -// CHECK(!PCRE::FullMatch("hello", "e")); +// ABSL_CHECK(!PCRE::FullMatch("hello", "e")); // // ----------------------------------------------------------------------- // UTF-8 AND THE MATCHING INTERFACE: @@ -58,7 +58,7 @@ // // Example: // PCRE re(utf8_pattern, PCRE::UTF8); -// CHECK(PCRE::FullMatch(utf8_string, re)); +// ABSL_CHECK(PCRE::FullMatch(utf8_string, re)); // // ----------------------------------------------------------------------- // MATCHING WITH SUBSTRING EXTRACTION: @@ -68,22 +68,22 @@ // Example: extracts "ruby" into "s" and 1234 into "i" // int i; // std::string s; -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s, &i)); // // Example: fails because string cannot be stored in integer -// CHECK(!PCRE::FullMatch("ruby", "(.*)", &i)); +// ABSL_CHECK(!PCRE::FullMatch("ruby", "(.*)", &i)); // // Example: fails because there aren't enough sub-patterns: -// CHECK(!PCRE::FullMatch("ruby:1234", "\\w+:\\d+", &s)); +// ABSL_CHECK(!PCRE::FullMatch("ruby:1234", "\\w+:\\d+", &s)); // // Example: does not try to extract any extra sub-patterns -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", &s)); // // Example: does not try to extract into NULL -// CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); +// ABSL_CHECK(PCRE::FullMatch("ruby:1234", "(\\w+):(\\d+)", NULL, &i)); // // Example: integer overflow causes failure -// CHECK(!PCRE::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); +// ABSL_CHECK(!PCRE::FullMatch("ruby:1234567891234", "\\w+:(\\d+)", &i)); // // ----------------------------------------------------------------------- // PARTIAL MATCHES @@ -92,12 +92,12 @@ // to match any substring of the text. // // Example: simple search for a string: -// CHECK(PCRE::PartialMatch("hello", "ell")); +// ABSL_CHECK(PCRE::PartialMatch("hello", "ell")); // // Example: find first number in a string // int number; -// CHECK(PCRE::PartialMatch("x*100 + 20", "(\\d+)", &number)); -// CHECK_EQ(number, 100); +// ABSL_CHECK(PCRE::PartialMatch("x*100 + 20", "(\\d+)", &number)); +// ABSL_CHECK_EQ(number, 100); // // ----------------------------------------------------------------------- // PPCRE-COMPILED PCREGULAR EXPPCRESSIONS @@ -157,7 +157,7 @@ // // Example: // int a, b, c, d; -// CHECK(PCRE::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", +// ABSL_CHECK(PCRE::FullMatch("100 40 0100 0x40", "(.*) (.*) (.*) (.*)", // Octal(&a), Hex(&b), CRadix(&c), CRadix(&d)); // will leave 64 in a, b, c, and d. @@ -379,7 +379,7 @@ class PCRE { // text. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(PCRE::Replace(&s, "b+", "d")); + // ABSL_CHECK(PCRE::Replace(&s, "b+", "d")); // // will leave "s" containing "yada dabba doo" // @@ -393,7 +393,7 @@ class PCRE { // re-matching. E.g., // // std::string s = "yabba dabba doo"; - // CHECK(PCRE::GlobalReplace(&s, "b+", "d")); + // ABSL_CHECK(PCRE::GlobalReplace(&s, "b+", "d")); // // will leave "s" containing "yada dada doo" // @@ -417,7 +417,7 @@ class PCRE { // * The @p rewrite string doesn't have any syntax errors // ('\' followed by anything besides [0-9] and '\'). // Making this test will guarantee that "replace" and "extract" - // operations won't LOG(ERROR) or fail because of a bad rewrite + // operations won't ABSL_LOG(ERROR) or fail because of a bad rewrite // string. // @param rewrite The proposed rewrite string. // @param error An error message is recorded here, iff we return false.