Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: base/check_example.cc

Issue 2532513002: base: Make CHECK great again
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/logging.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file is meant for analyzing the code generated by the CHECK 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. 6 // macros in a small executable file that's easy to disassemble.
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 // An official build shouldn't generate code to print out messages for 10 // An official build shouldn't generate code to print out messages for
11 // the CHECK* macros, nor should it have the strings in the 11 // the CHECK* macros, nor should it have the strings in the
12 // executable. 12 // executable.
13 13
14 void DoCheck(bool b) { 14 // TODO remove this crap before landing, adding only to see the effect on a real build target.
15
16 #define BLINK_IMMEDIATE_CRASH() ((void)(*(volatile char*)0 = 0))
17 #define BLINK_RELEASE_ASSERT(condition) !(condition) ? IMMEDIATE_CRASH() : (void ) 0;
18
19
20 void __declspec(dllexport) DoCheck(bool b) {
15 CHECK(b) << "DoCheck " << b; 21 CHECK(b) << "DoCheck " << b;
16 } 22 }
17 23
18 void DoCheckEq(int x, int y) { 24 void DoCheckEq(int x, int y) {
19 CHECK_EQ(x, y); 25 CHECK_EQ(x, y);
20 } 26 }
21 27
28 void __declspec(dllexport) DoBlinkCheck(bool b) {
29 BLINK_RELEASE_ASSERT(b);
30 }
31
32 void __declspec(dllexport) DoBaseCheck(bool b) {
33 CHECK(b) << "DoCheck " << b;
34 }
35
22 int main(int argc, const char* argv[]) { 36 int main(int argc, const char* argv[]) {
23 DoCheck(argc > 1); 37 DoCheck(argc > 1);
24 DoCheckEq(argc, 1); 38 DoCheckEq(argc, 1);
25 } 39 }
OLDNEW
« no previous file with comments | « no previous file | base/logging.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698