Skip to content
Permalink
Browse files

src: introduce DCHECK macro

This commit adds a DCHECK macro for consistency with the
other DCHECK_* macros.

PR-URL: #25207
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information...
cjihrig authored and targos committed Dec 24, 2018
1 parent e2a01ca commit 99a5af65df5d87b209f5722c55a3566722067e61
Showing with 5 additions and 13 deletions.
  1. +1 −3 src/aliased_buffer.h
  2. +1 −3 src/base_object-inl.h
  3. +0 −4 src/inspector/node_string.h
  4. +1 −3 src/string_decoder.cc
  5. +2 −0 src/util.h
@@ -231,9 +231,7 @@ class AliasedBuffer {
void reserve(size_t new_capacity) {
DCHECK_GE(new_capacity, count_);
DCHECK_EQ(byte_offset_, 0);
#if defined(DEBUG) && DEBUG
CHECK(free_buffer_);
#endif
DCHECK(free_buffer_);
const v8::HandleScope handle_scope(isolate_);

const size_t old_size_in_bytes = sizeof(NativeT) * count_;
@@ -113,9 +113,7 @@ void BaseObject::ClearWeak() {
v8::Local<v8::FunctionTemplate>
BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
#ifdef DEBUG
CHECK(args.IsConstructCall());
#endif
DCHECK(args.IsConstructCall());
DCHECK_GT(args.This()->InternalFieldCount(), 0);
args.This()->SetAlignedPointerInInternalField(0, nullptr);
};
@@ -73,8 +73,4 @@ extern size_t kNotFound;
} // namespace inspector
} // namespace node

#ifndef DCHECK
#define DCHECK CHECK
#define DCHECK_LT CHECK_LT
#endif // DCHECK
#endif // SRC_INSPECTOR_NODE_STRING_H_
@@ -44,9 +44,7 @@ MaybeLocal<String> MakeString(Isolate* isolate,
isolate->ThrowException(error);
}

#ifdef DEBUG
CHECK(ret.IsEmpty() || ret.ToLocalChecked()->IsString());
#endif
DCHECK(ret.IsEmpty() || ret.ToLocalChecked()->IsString());
return ret.FromMaybe(Local<Value>()).As<String>();
}

@@ -130,6 +130,7 @@ void DumpBacktrace(FILE* fp);
#define CHECK_IMPLIES(a, b) CHECK(!(a) || (b))

#ifdef DEBUG
#define DCHECK(expr) CHECK(expr)
#define DCHECK_EQ(a, b) CHECK((a) == (b))
#define DCHECK_GE(a, b) CHECK((a) >= (b))
#define DCHECK_GT(a, b) CHECK((a) > (b))
@@ -140,6 +141,7 @@ void DumpBacktrace(FILE* fp);
#define DCHECK_NOT_NULL(val) CHECK((val) != nullptr)
#define DCHECK_IMPLIES(a, b) CHECK(!(a) || (b))
#else
#define DCHECK(expr)
#define DCHECK_EQ(a, b)
#define DCHECK_GE(a, b)
#define DCHECK_GT(a, b)

0 comments on commit 99a5af6

Please sign in to comment.
You can’t perform that action at this time.