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

Unified Diff: src/parsing/scanner.h

Issue 2135573002: Address compilation warnings for android build. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update comment. Created 4 years, 5 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 | « src/interpreter/bytecode-generator.cc ('k') | src/uri.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/scanner.h
diff --git a/src/parsing/scanner.h b/src/parsing/scanner.h
index 610091c52ec51fe52af9241dba844359a429585b..276bbe79f6a07a0f427ce7545393644a9ce5cc15 100644
--- a/src/parsing/scanner.h
+++ b/src/parsing/scanner.h
@@ -162,7 +162,7 @@ class LiteralBuffer {
INLINE(void AddChar(char code_unit)) {
if (position_ >= backing_store_.length()) ExpandBuffer();
DCHECK(is_one_byte_);
- DCHECK(0 <= code_unit && code_unit <= kMaxAscii);
+ DCHECK(IsValidAscii(code_unit));
backing_store_[position_] = static_cast<byte>(code_unit);
position_ += kOneByteSize;
return;
@@ -251,6 +251,15 @@ class LiteralBuffer {
static const int kGrowthFactory = 4;
static const int kMinConversionSlack = 256;
static const int kMaxGrowth = 1 * MB;
+
+ inline bool IsValidAscii(char code_unit) {
+ // Control characters and printable characters span the range of
+ // valid ASCII characters (0-127). Chars are unsigned on some
+ // platforms which causes compiler warnings if the validity check
+ // tests the lower bound >= 0 as it's always true.
+ return iscntrl(code_unit) || isprint(code_unit);
+ }
+
inline int NewCapacity(int min_capacity) {
int capacity = Max(min_capacity, backing_store_.length());
int new_capacity = Min(capacity * kGrowthFactory, capacity + kMaxGrowth);
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/uri.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698