Skip to content

Commit

Permalink
re2: Remove comparisons of this with NULL.
Browse files Browse the repository at this point in the history
BUG=381910
TBR=cpu@chromium.org

Review URL: https://codereview.chromium.org/334313003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277592 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Jun 17, 2014
1 parent a972c53 commit 79ea00c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 16 deletions.
2 changes: 2 additions & 0 deletions third_party/re2/README.chromium
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ Local Modifications (to be applied in this order):
for this (https://code.google.com/p/re2/issues/detail?id=77) which is rendered
ineffective by patches/remove-valgrind-code.patch
(patches/re2-msan.patch)
- Remove comparisons of this with NULL (patches/this-null.patch), sent upstream
at https://codereview.appspot.com/107100043/
71 changes: 71 additions & 0 deletions third_party/re2/patches/this-null.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Index: re2/prefilter.cc
===================================================================
--- a/re2/prefilter.cc
+++ b/re2/prefilter.cc
@@ -265,14 +265,6 @@

// Format a Info in string form.
string Prefilter::Info::ToString() {
- if (this == NULL) {
- // Sometimes when iterating on children of a node,
- // some children might have NULL Info. Adding
- // the check here for NULL to take care of cases where
- // the caller is not checking.
- return "";
- }
-
if (is_exact_) {
int n = 0;
string s;
@@ -640,7 +632,7 @@

if (Trace) {
VLOG(0) << "BuildInfo " << re->ToString()
- << ": " << info->ToString();
+ << ": " << (info ? info->ToString() : "");
}

return info;
@@ -665,9 +657,6 @@
}

string Prefilter::DebugString() const {
- if (this == NULL)
- return "<nil>";
-
switch (op_) {
default:
LOG(DFATAL) << "Bad op in Prefilter::DebugString: " << op_;
@@ -683,7 +672,8 @@
for (int i = 0; i < subs_->size(); i++) {
if (i > 0)
s += " ";
- s += (*subs_)[i]->DebugString();
+ Prefilter* sub = (*subs_)[i];
+ s += sub ? sub->DebugString() : "<nil>";
}
return s;
}
@@ -692,7 +682,8 @@
for (int i = 0; i < subs_->size(); i++) {
if (i > 0)
s += "|";
- s += (*subs_)[i]->DebugString();
+ Prefilter* sub = (*subs_)[i];
+ s += sub ? sub->DebugString() : "<nil>";
}
s += ")";
return s;
Index: re2/regexp.cc
===================================================================
--- a/re2/regexp.cc
+++ b/re2/regexp.cc
@@ -873,8 +873,6 @@
}

void CharClass::Delete() {
- if (this == NULL)
- return;
uint8 *data = reinterpret_cast<uint8*>(this);
delete[] data;
}
19 changes: 5 additions & 14 deletions third_party/re2/re2/prefilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,6 @@ Prefilter* Prefilter::Info::TakeMatch() {

// Format a Info in string form.
string Prefilter::Info::ToString() {
if (this == NULL) {
// Sometimes when iterating on children of a node,
// some children might have NULL Info. Adding
// the check here for NULL to take care of cases where
// the caller is not checking.
return "";
}

if (is_exact_) {
int n = 0;
string s;
Expand Down Expand Up @@ -640,7 +632,7 @@ Prefilter::Info* Prefilter::Info::Walker::PostVisit(

if (Trace) {
VLOG(0) << "BuildInfo " << re->ToString()
<< ": " << info->ToString();
<< ": " << (info ? info->ToString() : "");
}

return info;
Expand All @@ -665,9 +657,6 @@ Prefilter* Prefilter::FromRegexp(Regexp* re) {
}

string Prefilter::DebugString() const {
if (this == NULL)
return "<nil>";

switch (op_) {
default:
LOG(DFATAL) << "Bad op in Prefilter::DebugString: " << op_;
Expand All @@ -683,7 +672,8 @@ string Prefilter::DebugString() const {
for (int i = 0; i < subs_->size(); i++) {
if (i > 0)
s += " ";
s += (*subs_)[i]->DebugString();
Prefilter* sub = (*subs_)[i];
s += sub ? sub->DebugString() : "<nil>";
}
return s;
}
Expand All @@ -692,7 +682,8 @@ string Prefilter::DebugString() const {
for (int i = 0; i < subs_->size(); i++) {
if (i > 0)
s += "|";
s += (*subs_)[i]->DebugString();
Prefilter* sub = (*subs_)[i];
s += sub ? sub->DebugString() : "<nil>";
}
s += ")";
return s;
Expand Down
2 changes: 0 additions & 2 deletions third_party/re2/re2/regexp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,6 @@ CharClass* CharClass::New(int maxranges) {
}

void CharClass::Delete() {
if (this == NULL)
return;
uint8 *data = reinterpret_cast<uint8*>(this);
delete[] data;
}
Expand Down

0 comments on commit 79ea00c

Please sign in to comment.