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

Side by Side Diff: base/logging.h

Issue 576073007: base: Add CHECK_IMPLIES and DCHECK_IMPLIES. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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 | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <cassert> 8 #include <cassert>
9 #include <string> 9 #include <string>
10 #include <cstring> 10 #include <cstring>
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 DEFINE_CHECK_OP_IMPL(GE, >=) 525 DEFINE_CHECK_OP_IMPL(GE, >=)
526 DEFINE_CHECK_OP_IMPL(GT, > ) 526 DEFINE_CHECK_OP_IMPL(GT, > )
527 #undef DEFINE_CHECK_OP_IMPL 527 #undef DEFINE_CHECK_OP_IMPL
528 528
529 #define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) 529 #define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
530 #define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2) 530 #define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
531 #define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2) 531 #define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
532 #define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2) 532 #define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2)
533 #define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) 533 #define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
534 #define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2) 534 #define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
535 #define CHECK_IMPLIES(val1, val2) CHECK(!(val1) || (val2))
535 536
536 #if defined(NDEBUG) 537 #if defined(NDEBUG)
537 #define ENABLE_DLOG 0 538 #define ENABLE_DLOG 0
538 #else 539 #else
539 #define ENABLE_DLOG 1 540 #define ENABLE_DLOG 1
540 #endif 541 #endif
541 542
542 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) 543 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
543 #define DCHECK_IS_ON 0 544 #define DCHECK_IS_ON 0
544 #else 545 #else
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // WARNING: These may not compile correctly if one of the arguments is a pointer 656 // WARNING: These may not compile correctly if one of the arguments is a pointer
656 // and the other is NULL. To work around this, simply static_cast NULL to the 657 // and the other is NULL. To work around this, simply static_cast NULL to the
657 // type of the desired pointer. 658 // type of the desired pointer.
658 659
659 #define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) 660 #define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
660 #define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) 661 #define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
661 #define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) 662 #define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
662 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) 663 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
663 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) 664 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
664 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) 665 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
666 #define DCHECK_IMPLIES(val1, val2) DCHECK(!(val1) || (val2))
665 667
666 #if defined(NDEBUG) && defined(OS_CHROMEOS) 668 #if defined(NDEBUG) && defined(OS_CHROMEOS)
667 #define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \ 669 #define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \
668 __FUNCTION__ << ". " 670 __FUNCTION__ << ". "
669 #else 671 #else
670 #define NOTREACHED() DCHECK(false) 672 #define NOTREACHED() DCHECK(false)
671 #endif 673 #endif
672 674
673 // Redefine the standard assert to use our nice log files 675 // Redefine the standard assert to use our nice log files
674 #undef assert 676 #undef assert
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 #elif NOTIMPLEMENTED_POLICY == 5 892 #elif NOTIMPLEMENTED_POLICY == 5
891 #define NOTIMPLEMENTED() do {\ 893 #define NOTIMPLEMENTED() do {\
892 static bool logged_once = false;\ 894 static bool logged_once = false;\
893 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 895 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
894 logged_once = true;\ 896 logged_once = true;\
895 } while(0);\ 897 } while(0);\
896 EAT_STREAM_PARAMETERS 898 EAT_STREAM_PARAMETERS
897 #endif 899 #endif
898 900
899 #endif // BASE_LOGGING_H_ 901 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698