Skip to content

Commit 99a5af6

Browse files
cjihrigtargos
authored andcommitted
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 <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent e2a01ca commit 99a5af6

File tree

5 files changed

+5
-13
lines changed

5 files changed

+5
-13
lines changed

src/aliased_buffer.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,7 @@ class AliasedBuffer {
231231
void reserve(size_t new_capacity) {
232232
DCHECK_GE(new_capacity, count_);
233233
DCHECK_EQ(byte_offset_, 0);
234-
#if defined(DEBUG) && DEBUG
235-
CHECK(free_buffer_);
236-
#endif
234+
DCHECK(free_buffer_);
237235
const v8::HandleScope handle_scope(isolate_);
238236

239237
const size_t old_size_in_bytes = sizeof(NativeT) * count_;

src/base_object-inl.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ void BaseObject::ClearWeak() {
113113
v8::Local<v8::FunctionTemplate>
114114
BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
115115
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
116-
#ifdef DEBUG
117-
CHECK(args.IsConstructCall());
118-
#endif
116+
DCHECK(args.IsConstructCall());
119117
DCHECK_GT(args.This()->InternalFieldCount(), 0);
120118
args.This()->SetAlignedPointerInInternalField(0, nullptr);
121119
};

src/inspector/node_string.h

-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,4 @@ extern size_t kNotFound;
7373
} // namespace inspector
7474
} // namespace node
7575

76-
#ifndef DCHECK
77-
#define DCHECK CHECK
78-
#define DCHECK_LT CHECK_LT
79-
#endif // DCHECK
8076
#endif // SRC_INSPECTOR_NODE_STRING_H_

src/string_decoder.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ MaybeLocal<String> MakeString(Isolate* isolate,
4444
isolate->ThrowException(error);
4545
}
4646

47-
#ifdef DEBUG
48-
CHECK(ret.IsEmpty() || ret.ToLocalChecked()->IsString());
49-
#endif
47+
DCHECK(ret.IsEmpty() || ret.ToLocalChecked()->IsString());
5048
return ret.FromMaybe(Local<Value>()).As<String>();
5149
}
5250

src/util.h

+2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ void DumpBacktrace(FILE* fp);
130130
#define CHECK_IMPLIES(a, b) CHECK(!(a) || (b))
131131

132132
#ifdef DEBUG
133+
#define DCHECK(expr) CHECK(expr)
133134
#define DCHECK_EQ(a, b) CHECK((a) == (b))
134135
#define DCHECK_GE(a, b) CHECK((a) >= (b))
135136
#define DCHECK_GT(a, b) CHECK((a) > (b))
@@ -140,6 +141,7 @@ void DumpBacktrace(FILE* fp);
140141
#define DCHECK_NOT_NULL(val) CHECK((val) != nullptr)
141142
#define DCHECK_IMPLIES(a, b) CHECK(!(a) || (b))
142143
#else
144+
#define DCHECK(expr)
143145
#define DCHECK_EQ(a, b)
144146
#define DCHECK_GE(a, b)
145147
#define DCHECK_GT(a, b)

0 commit comments

Comments
 (0)