[cleanup] Fix (D)CHECK macros in src/{debug,inspector}
Use the (D)CHECK_{EQ,NE,GT,...} macros instead of (D)CHECK with an embedded comparison. This gives better error messages and also does the right comparison for signed/unsigned mismatches. This will allow us to reenable the readability/check cpplint check. R=yangguo@chromium.org Bug: v8:6837 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel Change-Id: I88e5afea1ad0fdf23a81b380e64ff356bbc20112 Reviewed-on: https://chromium-review.googlesource.com/681374 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#48138}
This commit is contained in:
parent
76ba883bfa
commit
8d38c15e04
@ -61,8 +61,8 @@ bool CompareSharedFunctionInfo(SharedFunctionInfo* a, SharedFunctionInfo* b) {
|
||||
}
|
||||
|
||||
bool CompareCoverageBlock(const CoverageBlock& a, const CoverageBlock& b) {
|
||||
DCHECK(a.start != kNoSourcePosition);
|
||||
DCHECK(b.start != kNoSourcePosition);
|
||||
DCHECK_NE(kNoSourcePosition, a.start);
|
||||
DCHECK_NE(kNoSourcePosition, b.start);
|
||||
if (a.start == b.start) return a.end > b.end;
|
||||
return a.start < b.start;
|
||||
}
|
||||
@ -83,7 +83,7 @@ std::vector<CoverageBlock> GetSortedBlockData(Isolate* isolate,
|
||||
const int until_pos = coverage_info->EndSourcePosition(i);
|
||||
const int count = coverage_info->BlockCount(i);
|
||||
|
||||
DCHECK(start_pos != kNoSourcePosition);
|
||||
DCHECK_NE(kNoSourcePosition, start_pos);
|
||||
result.emplace_back(start_pos, until_pos, count);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ FrameInspector::FrameInspector(StandardFrame* frame, int inlined_frame_index,
|
||||
|
||||
// Calculate the deoptimized frame.
|
||||
if (is_optimized_) {
|
||||
DCHECK(js_frame != nullptr);
|
||||
DCHECK_NOT_NULL(js_frame);
|
||||
// TODO(turbofan): Deoptimization from AstGraphBuilder is not supported.
|
||||
if (js_frame->LookupCode()->is_turbofanned() &&
|
||||
!js_frame->function()->shared()->HasBytecodeArray()) {
|
||||
|
@ -169,8 +169,8 @@ void BreakIterator::Next() {
|
||||
if (source_position_iterator_.is_statement()) {
|
||||
statement_position_ = position_;
|
||||
}
|
||||
DCHECK(position_ >= 0);
|
||||
DCHECK(statement_position_ >= 0);
|
||||
DCHECK_LE(0, position_);
|
||||
DCHECK_LE(0, statement_position_);
|
||||
|
||||
DebugBreakType type = GetDebugBreakType();
|
||||
if (type != NOT_DEBUG_BREAK) break;
|
||||
@ -559,13 +559,13 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function,
|
||||
CHECK(PrepareFunctionForBreakPoints(shared));
|
||||
Handle<DebugInfo> debug_info(shared->GetDebugInfo());
|
||||
// Source positions starts with zero.
|
||||
DCHECK(*source_position >= 0);
|
||||
DCHECK_LE(0, *source_position);
|
||||
|
||||
// Find the break point and change it.
|
||||
*source_position = FindBreakablePosition(debug_info, *source_position);
|
||||
DebugInfo::SetBreakPoint(debug_info, *source_position, break_point_object);
|
||||
// At least one active break point now.
|
||||
DCHECK(debug_info->GetBreakPointCount() > 0);
|
||||
DCHECK_LT(0, debug_info->GetBreakPointCount());
|
||||
|
||||
ClearBreakPoints(debug_info);
|
||||
ApplyBreakPoints(debug_info);
|
||||
@ -608,7 +608,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
|
||||
*source_position = FindBreakablePosition(debug_info, *source_position);
|
||||
DebugInfo::SetBreakPoint(debug_info, *source_position, break_point_object);
|
||||
// At least one active break point now.
|
||||
DCHECK(debug_info->GetBreakPointCount() > 0);
|
||||
DCHECK_LT(0, debug_info->GetBreakPointCount());
|
||||
|
||||
ClearBreakPoints(debug_info);
|
||||
ApplyBreakPoints(debug_info);
|
||||
|
@ -163,7 +163,7 @@ class Differencer {
|
||||
|
||||
// Each cell keeps a value plus direction. Value is multiplied by 4.
|
||||
void set_value4_and_dir(int i1, int i2, int value4, Direction dir) {
|
||||
DCHECK((value4 & kDirectionMask) == 0);
|
||||
DCHECK_EQ(0, value4 & kDirectionMask);
|
||||
get_cell(i1, i2) = value4 | dir;
|
||||
}
|
||||
|
||||
@ -813,7 +813,7 @@ bool NeedsDeoptimization(SharedFunctionInfo* function_info, Code* code) {
|
||||
SharedFunctionInfo::cast(table->SharedFunctionInfo());
|
||||
if (sfi == function_info) return true;
|
||||
DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION);
|
||||
DCHECK(table->length() != 0);
|
||||
DCHECK_NE(0, table->length());
|
||||
FixedArray* const literals = table->LiteralArray();
|
||||
int const inlined_count = table->InlinedFunctionCount()->value();
|
||||
for (int i = 0; i < inlined_count; i++) {
|
||||
|
@ -15,7 +15,7 @@ namespace {
|
||||
|
||||
String16 findMagicComment(const String16& content, const String16& name,
|
||||
bool multiline) {
|
||||
DCHECK(name.find("=") == String16::kNotFound);
|
||||
DCHECK_EQ(String16::kNotFound, name.find("="));
|
||||
size_t length = content.length();
|
||||
size_t nameLength = name.length();
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace v8_inspector {
|
||||
|
||||
v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String16& string) {
|
||||
if (string.isEmpty()) return v8::String::Empty(isolate);
|
||||
DCHECK(string.length() < v8::String::kMaxLength);
|
||||
DCHECK_GT(v8::String::kMaxLength, string.length());
|
||||
return v8::String::NewFromTwoByte(
|
||||
isolate, reinterpret_cast<const uint16_t*>(string.characters16()),
|
||||
v8::NewStringType::kNormal, static_cast<int>(string.length()))
|
||||
@ -22,7 +22,7 @@ v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String16& string) {
|
||||
v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate,
|
||||
const String16& string) {
|
||||
if (string.isEmpty()) return v8::String::Empty(isolate);
|
||||
DCHECK(string.length() < v8::String::kMaxLength);
|
||||
DCHECK_GT(v8::String::kMaxLength, string.length());
|
||||
return v8::String::NewFromTwoByte(
|
||||
isolate, reinterpret_cast<const uint16_t*>(string.characters16()),
|
||||
v8::NewStringType::kInternalized,
|
||||
@ -39,7 +39,7 @@ v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate,
|
||||
v8::Local<v8::String> toV8String(v8::Isolate* isolate,
|
||||
const StringView& string) {
|
||||
if (!string.length()) return v8::String::Empty(isolate);
|
||||
DCHECK(string.length() < v8::String::kMaxLength);
|
||||
DCHECK_GT(v8::String::kMaxLength, string.length());
|
||||
if (string.is8Bit())
|
||||
return v8::String::NewFromOneByte(
|
||||
isolate, reinterpret_cast<const uint8_t*>(string.characters8()),
|
||||
|
@ -70,7 +70,7 @@ void V8ConsoleAgentImpl::reportAllMessages() {
|
||||
|
||||
bool V8ConsoleAgentImpl::reportMessage(V8ConsoleMessage* message,
|
||||
bool generatePreview) {
|
||||
DCHECK(message->origin() == V8MessageOrigin::kConsole);
|
||||
DCHECK_EQ(V8MessageOrigin::kConsole, message->origin());
|
||||
message->reportToFrontend(&m_frontend);
|
||||
m_frontend.flush();
|
||||
return m_session->inspector()->hasConsoleMessageStorage(
|
||||
|
@ -204,7 +204,7 @@ void V8ConsoleMessage::setLocation(const String16& url, unsigned lineNumber,
|
||||
|
||||
void V8ConsoleMessage::reportToFrontend(
|
||||
protocol::Console::Frontend* frontend) const {
|
||||
DCHECK(m_origin == V8MessageOrigin::kConsole);
|
||||
DCHECK_EQ(V8MessageOrigin::kConsole, m_origin);
|
||||
String16 level = protocol::Console::ConsoleMessage::LevelEnum::Log;
|
||||
if (m_type == ConsoleAPIType::kDebug || m_type == ConsoleAPIType::kCount ||
|
||||
m_type == ConsoleAPIType::kTimeEnd)
|
||||
|
@ -618,7 +618,7 @@ void V8Console::queryObjectsCallback(
|
||||
|
||||
void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info,
|
||||
int sessionId, unsigned num) {
|
||||
DCHECK(num < V8InspectorSessionImpl::kInspectedObjectBufferSize);
|
||||
DCHECK_GT(V8InspectorSessionImpl::kInspectedObjectBufferSize, num);
|
||||
v8::debug::ConsoleCallArguments args(info);
|
||||
ConsoleHelper helper(args, v8::debug::ConsoleContext(), m_inspector);
|
||||
if (V8InspectorSessionImpl* session = helper.session(sessionId)) {
|
||||
|
@ -105,7 +105,7 @@ v8::Local<v8::Object> V8InjectedScriptHost::create(
|
||||
|
||||
void V8InjectedScriptHost::nullifyPrototypeCallback(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||
CHECK(info.Length() == 1);
|
||||
CHECK_EQ(1, info.Length());
|
||||
DCHECK(info[0]->IsObject());
|
||||
if (!info[0]->IsObject()) return;
|
||||
v8::Isolate* isolate = info.GetIsolate();
|
||||
|
@ -96,8 +96,8 @@ StackFrame::StackFrame(v8::Local<v8::StackFrame> v8Frame)
|
||||
m_sourceURL(toProtocolString(v8Frame->GetScriptNameOrSourceURL())),
|
||||
m_lineNumber(v8Frame->GetLineNumber() - 1),
|
||||
m_columnNumber(v8Frame->GetColumn() - 1) {
|
||||
DCHECK(m_lineNumber + 1 != v8::Message::kNoLineNumberInfo);
|
||||
DCHECK(m_columnNumber + 1 != v8::Message::kNoColumnInfo);
|
||||
DCHECK_NE(v8::Message::kNoLineNumberInfo, m_lineNumber + 1);
|
||||
DCHECK_NE(v8::Message::kNoColumnInfo, m_columnNumber + 1);
|
||||
}
|
||||
|
||||
void StackFrame::translate(WasmTranslation* wasmTranslation) {
|
||||
|
@ -78,7 +78,7 @@ void TaskRunner::RunMessageLoop(bool only_protocol) {
|
||||
}
|
||||
|
||||
void TaskRunner::QuitMessageLoop() {
|
||||
DCHECK(nested_loop_count_ > 0);
|
||||
DCHECK_LT(0, nested_loop_count_);
|
||||
--nested_loop_count_;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user