[S] Change in code/re2[abseil]: Address some more `-Wunreachable-code` warnings.

5 views
Skip to first unread message

Paul Wankadia (Gerrit)

unread,
Aug 8, 2022, 3:09:51 PM8/8/22
to Paul Wankadia, re2...@googlegroups.com

Paul Wankadia has uploaded this change for review.

View Change

Address some more `-Wunreachable-code` warnings.

Fixes #384.

Change-Id: I6b9e6e84017f78338ea0f916932a1af0c2668fa6
---
M re2/dfa.cc
M re2/parse.cc
M re2/prefilter.cc
M re2/prog.cc
M re2/set.cc
M re2/simplify.cc
6 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/re2/dfa.cc b/re2/dfa.cc
index 57256e4..334732e 100644
--- a/re2/dfa.cc
+++ b/re2/dfa.cc
@@ -1677,8 +1677,8 @@
if (!AnalyzeSearchHelper(params, info, flags)) {
ResetCache(params->cache_lock);
if (!AnalyzeSearchHelper(params, info, flags)) {
- LOG(DFATAL) << "Failed to analyze start state.";
params->failed = true;
+ LOG(DFATAL) << "Failed to analyze start state.";
return false;
}
}
diff --git a/re2/parse.cc b/re2/parse.cc
index bce76fb..67a4857 100644
--- a/re2/parse.cc
+++ b/re2/parse.cc
@@ -1586,8 +1586,6 @@
// return true;
}

- LOG(DFATAL) << "Not reached in ParseEscape.";
-
BadEscape:
// Unrecognized escape sequence.
status->set_code(kRegexpBadEscape);
@@ -2056,8 +2054,8 @@

// Caller is supposed to check this.
if (!(flags_ & PerlX) || t.size() < 2 || t[0] != '(' || t[1] != '?') {
- LOG(DFATAL) << "Bad call to ParseState::ParsePerlFlags";
status_->set_code(kRegexpInternalError);
+ LOG(DFATAL) << "Bad call to ParseState::ParsePerlFlags";
return false;
}

diff --git a/re2/prefilter.cc b/re2/prefilter.cc
index 0780d00..bb59619 100644
--- a/re2/prefilter.cc
+++ b/re2/prefilter.cc
@@ -531,8 +531,8 @@
switch (re->op()) {
default:
case kRegexpRepeat:
- LOG(DFATAL) << "Bad regexp op " << re->op();
info = EmptyString();
+ LOG(DFATAL) << "Bad regexp op " << re->op();
break;

case kRegexpNoMatch:
diff --git a/re2/prog.cc b/re2/prog.cc
index 9959f7c..6cadcfa 100644
--- a/re2/prog.cc
+++ b/re2/prog.cc
@@ -510,7 +510,7 @@

builder.Build(bytemap_, &bytemap_range_);

- if (0) { // For debugging, use trivial bytemap.
+ if ((0)) { // For debugging, use trivial bytemap.
LOG(ERROR) << "Using trivial bytemap.";
for (int i = 0; i < 256; i++)
bytemap_[i] = static_cast<uint8_t>(i);
diff --git a/re2/set.cc b/re2/set.cc
index c14ef29..b9c918e 100644
--- a/re2/set.cc
+++ b/re2/set.cc
@@ -126,9 +126,9 @@
bool RE2::Set::Match(absl::string_view text, std::vector<int>* v,
ErrorInfo* error_info) const {
if (!compiled_) {
- LOG(DFATAL) << "RE2::Set::Match() called before compiling";
if (error_info != NULL)
error_info->kind = kNotCompiled;
+ LOG(DFATAL) << "RE2::Set::Match() called before compiling";
return false;
}
#ifdef RE2_HAVE_THREAD_LOCAL
@@ -159,9 +159,9 @@
}
if (v != NULL) {
if (matches->empty()) {
- LOG(DFATAL) << "RE2::Set::Match() matched, but no matches returned?!";
if (error_info != NULL)
error_info->kind = kInconsistent;
+ 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 eea3bd7..8cd10cf 100644
--- a/re2/simplify.cc
+++ b/re2/simplify.cc
@@ -370,8 +370,8 @@
break;

default:
- LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op();
nre->Decref();
+ LOG(DFATAL) << "DoCoalesce failed: r1->op() is " << r1->op();
return;
}

@@ -431,8 +431,8 @@
}

default:
- LOG(DFATAL) << "DoCoalesce failed: r2->op() is " << r2->op();
nre->Decref();
+ LOG(DFATAL) << "DoCoalesce failed: r2->op() is " << r2->op();
return;
}


To view, visit change 60371. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: re2
Gerrit-Branch: abseil
Gerrit-Change-Id: I6b9e6e84017f78338ea0f916932a1af0c2668fa6
Gerrit-Change-Number: 60371
Gerrit-PatchSet: 1
Gerrit-Owner: Paul Wankadia <jun...@google.com>
Gerrit-MessageType: newchange

Perry Lorier (Gerrit)

unread,
Aug 9, 2022, 4:50:55 AM8/9/22
to Paul Wankadia, Randall Bosetti, re2...@googlegroups.com

Attention is currently required from: Paul Wankadia.

Patch set 1:Code-Review +1

View Change

    To view, visit change 60371. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: re2
    Gerrit-Branch: abseil
    Gerrit-Change-Id: I6b9e6e84017f78338ea0f916932a1af0c2668fa6
    Gerrit-Change-Number: 60371
    Gerrit-PatchSet: 1
    Gerrit-Owner: Paul Wankadia <jun...@google.com>
    Gerrit-Reviewer: Perry Lorier <per...@google.com>
    Gerrit-CC: Randall Bosetti <r...@google.com>
    Gerrit-Attention: Paul Wankadia <jun...@google.com>
    Gerrit-Comment-Date: Tue, 09 Aug 2022 08:50:51 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Paul Wankadia (Gerrit)

    unread,
    Aug 9, 2022, 7:03:02 AM8/9/22
    to Paul Wankadia, Perry Lorier, Randall Bosetti, re2...@googlegroups.com

    Patch set 1:Code-Review +2

    View Change

      To view, visit change 60371. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: re2
      Gerrit-Branch: abseil
      Gerrit-Change-Id: I6b9e6e84017f78338ea0f916932a1af0c2668fa6
      Gerrit-Change-Number: 60371
      Gerrit-PatchSet: 1
      Gerrit-Owner: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Perry Lorier <per...@google.com>
      Gerrit-CC: Randall Bosetti <r...@google.com>
      Gerrit-Comment-Date: Tue, 09 Aug 2022 11:02:57 +0000

      Paul Wankadia (Gerrit)

      unread,
      Aug 9, 2022, 7:03:06 AM8/9/22
      to Paul Wankadia, Perry Lorier, Randall Bosetti, re2...@googlegroups.com

      Paul Wankadia submitted this change.

      View Change


      Approvals: Paul Wankadia: Looks good to me, approved Perry Lorier: Looks good to me, but someone else must approve
      Address some more `-Wunreachable-code` warnings.

      Fixes #384.

      Change-Id: I6b9e6e84017f78338ea0f916932a1af0c2668fa6
      Reviewed-on: https://code-review.googlesource.com/c/re2/+/60371
      Reviewed-by: Perry Lorier <per...@google.com>
      Reviewed-by: Paul Wankadia <jun...@google.com>

      ---
      M re2/dfa.cc
      M re2/parse.cc
      M re2/prefilter.cc
      M re2/prog.cc
      M re2/set.cc
      M re2/simplify.cc
      6 files changed, 22 insertions(+), 10 deletions(-)

      To view, visit change 60371. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: re2
      Gerrit-Branch: abseil
      Gerrit-Change-Id: I6b9e6e84017f78338ea0f916932a1af0c2668fa6
      Gerrit-Change-Number: 60371
      Gerrit-PatchSet: 2
      Gerrit-Owner: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Paul Wankadia <jun...@google.com>
      Gerrit-Reviewer: Perry Lorier <per...@google.com>
      Gerrit-CC: Randall Bosetti <r...@google.com>
      Gerrit-MessageType: merged
      Reply all
      Reply to author
      Forward
      0 new messages