0
Files
src/base/check_example.cc
Peter Boström 25c6ec7881 Rename IMMEDIATE_CRASH() -> base::ImmediateCrash()
This is now a [[noreturn]] function instead of a macro. The macro itself
is kept around for now to avoid having to revert this change in case
another IMMEDIATE_CRASH() is added or there exists such calls somewhere
outside src/ that I'm unaware of.

Bug: None
Change-Id: Ibc7921bf7302c94ce151c83a230af5f11fb7b71d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3999129
Reviewed-by: danakj <danakj@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1066781}
2022-11-02 23:25:19 +00:00

40 lines
1.2 KiB
C++

// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is meant for analyzing the code generated by the CHECK
// macros in a small executable file that's easy to disassemble.
#include <ostream>
#include "base/check_op.h"
#include "base/compiler_specific.h"
// An official build shouldn't generate code to print out messages for
// the CHECK* macros, nor should it have the strings in the
// executable. It is also important that the CHECK() function collapse to the
// same implementation as RELEASE_ASSERT(), in particular on Windows x86.
// Historically, the stream eating caused additional unnecessary instructions.
// See https://crbug.com/672699.
#define BLINK_RELEASE_ASSERT_EQUIVALENT(assertion) \
(UNLIKELY(!(assertion)) ? (base::ImmediateCrash()) : (void)0)
void DoCheck(bool b) {
CHECK(b) << "DoCheck " << b;
}
void DoBlinkReleaseAssert(bool b) {
BLINK_RELEASE_ASSERT_EQUIVALENT(b);
}
void DoCheckEq(int x, int y) {
CHECK_EQ(x, y);
}
int main(int argc, const char* argv[]) {
DoCheck(argc > 1);
DoCheckEq(argc, 1);
DoBlinkReleaseAssert(argc > 1);
}