From 8d38c15e04598f9e48e6230327da0e41a2445957 Mon Sep 17 00:00:00 2001 From: Clemens Hammacher Date: Mon, 25 Sep 2017 12:50:12 +0200 Subject: [PATCH] [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 Commit-Queue: Clemens Hammacher Cr-Commit-Position: refs/heads/master@{#48138} --- src/debug/debug-coverage.cc | 6 +++--- src/debug/debug-frames.cc | 2 +- src/debug/debug.cc | 10 +++++----- src/debug/liveedit.cc | 4 ++-- src/inspector/search-util.cc | 2 +- src/inspector/string-util.cc | 6 +++--- src/inspector/v8-console-agent-impl.cc | 2 +- src/inspector/v8-console-message.cc | 2 +- src/inspector/v8-console.cc | 2 +- src/inspector/v8-injected-script-host.cc | 2 +- src/inspector/v8-stack-trace-impl.cc | 4 ++-- test/inspector/task-runner.cc | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/debug/debug-coverage.cc b/src/debug/debug-coverage.cc index a14cdda76a..995ee68a75 100644 --- a/src/debug/debug-coverage.cc +++ b/src/debug/debug-coverage.cc @@ -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 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); } diff --git a/src/debug/debug-frames.cc b/src/debug/debug-frames.cc index c446c33a31..b04f8fc1bc 100644 --- a/src/debug/debug-frames.cc +++ b/src/debug/debug-frames.cc @@ -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()) { diff --git a/src/debug/debug.cc b/src/debug/debug.cc index cd35fd4ff9..ea133d49e8 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -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 function, CHECK(PrepareFunctionForBreakPoints(shared)); Handle 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