[go: nahoru, domu]

blob: 3bfc18447bbb9b671b674c5bf5ff40111076f01c [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2011 The Chromium Authors
akalin@chromium.orgddb9b332011-12-02 07:31:092// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This file is meant for analyzing the code generated by the CHECK
6// macros in a small executable file that's easy to disassemble.
7
Hans Wennborgc3cffa62020-04-27 10:09:128#include <ostream>
9
10#include "base/check_op.h"
scottmg3c957a52016-12-10 20:57:5911#include "base/compiler_specific.h"
akalin@chromium.orgddb9b332011-12-02 07:31:0912
13// An official build shouldn't generate code to print out messages for
14// the CHECK* macros, nor should it have the strings in the
scottmg3c957a52016-12-10 20:57:5915// executable. It is also important that the CHECK() function collapse to the
16// same implementation as RELEASE_ASSERT(), in particular on Windows x86.
17// Historically, the stream eating caused additional unnecessary instructions.
18// See https://crbug.com/672699.
19
20#define BLINK_RELEASE_ASSERT_EQUIVALENT(assertion) \
Peter Boström25c6ec72022-11-02 23:25:1921 (UNLIKELY(!(assertion)) ? (base::ImmediateCrash()) : (void)0)
akalin@chromium.orgddb9b332011-12-02 07:31:0922
23void DoCheck(bool b) {
24 CHECK(b) << "DoCheck " << b;
25}
26
scottmg3c957a52016-12-10 20:57:5927void DoBlinkReleaseAssert(bool b) {
28 BLINK_RELEASE_ASSERT_EQUIVALENT(b);
29}
30
akalin@chromium.orgddb9b332011-12-02 07:31:0931void DoCheckEq(int x, int y) {
32 CHECK_EQ(x, y);
33}
34
35int main(int argc, const char* argv[]) {
36 DoCheck(argc > 1);
37 DoCheckEq(argc, 1);
scottmg3c957a52016-12-10 20:57:5938 DoBlinkReleaseAssert(argc > 1);
akalin@chromium.orgddb9b332011-12-02 07:31:0939}