Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(990)

Unified Diff: src/regexp/jsregexp.cc

Issue 1776013003: [regexp] fix bogus assertion in CharacterRange constructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/regexp/regexp-ast.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/jsregexp.cc
diff --git a/src/regexp/jsregexp.cc b/src/regexp/jsregexp.cc
index 982846f158d38c993732e4b5a6dd5dc89d156e6a..158e4a2a38562770540fbb9d340a2c703b9478b8 100644
--- a/src/regexp/jsregexp.cc
+++ b/src/regexp/jsregexp.cc
@@ -4901,16 +4901,18 @@ UnicodeRangeSplitter::UnicodeRangeSplitter(Zone* zone,
table_.AddRange(base->at(i), kBase, zone_);
}
// Add overlay ranges.
- table_.AddRange(CharacterRange(0, kLeadSurrogateStart - 1), kBmpCodePoints,
- zone_);
- table_.AddRange(CharacterRange(kLeadSurrogateStart, kLeadSurrogateEnd),
- kLeadSurrogates, zone_);
- table_.AddRange(CharacterRange(kTrailSurrogateStart, kTrailSurrogateEnd),
- kTrailSurrogates, zone_);
- table_.AddRange(CharacterRange(kTrailSurrogateEnd + 1, kNonBmpStart - 1),
+ table_.AddRange(CharacterRange::Range(0, kLeadSurrogateStart - 1),
kBmpCodePoints, zone_);
- table_.AddRange(CharacterRange(kNonBmpStart, kNonBmpEnd), kNonBmpCodePoints,
- zone_);
+ table_.AddRange(CharacterRange::Range(kLeadSurrogateStart, kLeadSurrogateEnd),
+ kLeadSurrogates, zone_);
+ table_.AddRange(
+ CharacterRange::Range(kTrailSurrogateStart, kTrailSurrogateEnd),
+ kTrailSurrogates, zone_);
+ table_.AddRange(
+ CharacterRange::Range(kTrailSurrogateEnd + 1, kNonBmpStart - 1),
+ kBmpCodePoints, zone_);
+ table_.AddRange(CharacterRange::Range(kNonBmpStart, kNonBmpEnd),
+ kNonBmpCodePoints, zone_);
table_.ForEach(this);
}
@@ -5797,7 +5799,7 @@ static void AddClass(const int* elmv,
DCHECK(elmv[elmc] == kRangeEndMarker);
for (int i = 0; i < elmc; i += 2) {
DCHECK(elmv[i] < elmv[i + 1]);
- ranges->Add(CharacterRange(elmv[i], elmv[i + 1] - 1), zone);
+ ranges->Add(CharacterRange::Range(elmv[i], elmv[i + 1] - 1), zone);
}
}
@@ -5814,10 +5816,10 @@ static void AddClassNegated(const int *elmv,
for (int i = 0; i < elmc; i += 2) {
DCHECK(last <= elmv[i] - 1);
DCHECK(elmv[i] < elmv[i + 1]);
- ranges->Add(CharacterRange(last, elmv[i] - 1), zone);
+ ranges->Add(CharacterRange::Range(last, elmv[i] - 1), zone);
last = elmv[i + 1];
}
- ranges->Add(CharacterRange(last, String::kMaxCodePoint), zone);
+ ranges->Add(CharacterRange::Range(last, String::kMaxCodePoint), zone);
}
@@ -5935,7 +5937,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone,
uc32 range_from = c - (block_end - pos);
uc32 range_to = c - (block_end - end);
if (!(bottom <= range_from && range_to <= top)) {
- ranges->Add(CharacterRange(range_from, range_to), zone);
+ ranges->Add(CharacterRange::Range(range_from, range_to), zone);
}
}
pos = end + 1;
@@ -6029,7 +6031,7 @@ static int InsertRangeInCanonicalList(ZoneList<CharacterRange>* list,
CharacterRange to_replace = list->at(start_pos);
int new_from = Min(to_replace.from(), from);
int new_to = Max(to_replace.to(), to);
- list->at(start_pos) = CharacterRange(new_from, new_to);
+ list->at(start_pos) = CharacterRange::Range(new_from, new_to);
return count;
}
// Replace a number of existing ranges from start_pos to end_pos - 1.
@@ -6040,7 +6042,7 @@ static int InsertRangeInCanonicalList(ZoneList<CharacterRange>* list,
if (end_pos < count) {
MoveRanges(list, end_pos, start_pos + 1, count - end_pos);
}
- list->at(start_pos) = CharacterRange(new_from, new_to);
+ list->at(start_pos) = CharacterRange::Range(new_from, new_to);
return count - (end_pos - start_pos) + 1;
}
@@ -6104,12 +6106,13 @@ void CharacterRange::Negate(ZoneList<CharacterRange>* ranges,
}
while (i < range_count) {
CharacterRange range = ranges->at(i);
- negated_ranges->Add(CharacterRange(from, range.from() - 1), zone);
+ negated_ranges->Add(CharacterRange::Range(from, range.from() - 1), zone);
from = range.to() + 1;
i++;
}
if (from < String::kMaxCodePoint) {
- negated_ranges->Add(CharacterRange(from, String::kMaxCodePoint), zone);
+ negated_ranges->Add(CharacterRange::Range(from, String::kMaxCodePoint),
+ zone);
}
}
@@ -6188,8 +6191,9 @@ void DispatchTable::AddRange(CharacterRange full_range, int value,
if (entry->from() < current.from() && entry->to() >= current.from()) {
// Snap the overlapping range in half around the start point of
// the range we're adding.
- CharacterRange left(entry->from(), current.from() - 1);
- CharacterRange right(current.from(), entry->to());
+ CharacterRange left =
+ CharacterRange::Range(entry->from(), current.from() - 1);
+ CharacterRange right = CharacterRange::Range(current.from(), entry->to());
// The left part of the overlapping range doesn't overlap.
// Truncate the whole entry to be just the left part.
entry->set_to(left.to());
@@ -6495,8 +6499,7 @@ class AddDispatchRange {
void AddDispatchRange::Call(uc32 from, DispatchTable::Entry entry) {
- CharacterRange range(from, entry.to());
- constructor_->AddRange(range);
+ constructor_->AddRange(CharacterRange::Range(from, entry.to()));
}
@@ -6534,7 +6537,7 @@ void DispatchTableConstructor::AddInverse(ZoneList<CharacterRange>* ranges) {
for (int i = 0; i < ranges->length(); i++) {
CharacterRange range = ranges->at(i);
if (last < range.from())
- AddRange(CharacterRange(last, range.from() - 1));
+ AddRange(CharacterRange::Range(last, range.from() - 1));
if (range.to() >= last) {
if (range.to() == String::kMaxUtf16CodeUnit) {
return;
@@ -6543,7 +6546,7 @@ void DispatchTableConstructor::AddInverse(ZoneList<CharacterRange>* ranges) {
}
}
}
- AddRange(CharacterRange(last, String::kMaxUtf16CodeUnit));
+ AddRange(CharacterRange::Range(last, String::kMaxUtf16CodeUnit));
}
@@ -6552,7 +6555,7 @@ void DispatchTableConstructor::VisitText(TextNode* that) {
switch (elm.text_type()) {
case TextElement::ATOM: {
uc16 c = elm.atom()->data()[0];
- AddRange(CharacterRange(c, c));
+ AddRange(CharacterRange::Range(c, c));
break;
}
case TextElement::CHAR_CLASS: {
« no previous file with comments | « no previous file | src/regexp/regexp-ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698