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

Side by Side Diff: base/logging.h

Issue 2653993002: Ensure all code is removed for DCHECK on Windows Official (Closed)
Patch Set: comments Created 3 years, 11 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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 #define DCHECK(condition) \ 719 #define DCHECK(condition) \
720 __analysis_assume(!!(condition)), \ 720 __analysis_assume(!!(condition)), \
721 LAZY_STREAM(LOG_STREAM(DCHECK), false) \ 721 LAZY_STREAM(LOG_STREAM(DCHECK), false) \
722 << "Check failed: " #condition ". " 722 << "Check failed: " #condition ". "
723 723
724 #define DPCHECK(condition) \ 724 #define DPCHECK(condition) \
725 __analysis_assume(!!(condition)), \ 725 __analysis_assume(!!(condition)), \
726 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \ 726 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
727 << "Check failed: " #condition ". " 727 << "Check failed: " #condition ". "
728 728
729 #else // _PREFAST_ 729 #else // _PREFAST_ && OS_WIN
730 730
731 #define DCHECK(condition) \ 731 #if DCHECK_IS_ON()
danakj 2017/01/24 21:10:52 nested #ifs are such a joy, can u use elif here
732 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 732
733 #define DCHECK(condition) \
734 LAZY_STREAM(LOG_STREAM(DCHECK), !(condition)) \
733 << "Check failed: " #condition ". " 735 << "Check failed: " #condition ". "
734 736
735 #define DPCHECK(condition) \ 737 #define DPCHECK(condition) \
736 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 738 LAZY_STREAM(PLOG_STREAM(DCHECK), !(condition)) \
737 << "Check failed: " #condition ". " 739 << "Check failed: " #condition ". "
738 740
739 #endif // _PREFAST_ 741 #else // DCHECK_IS_ON()
742
743 // A separate block (as opposed to a conditional in the LAZY_STREAM) is required
744 // to ensure that all code is remove on MSVC. See the comment near
745 // EAT_STREAM_PARAMETERS for more detail.
746 #define DCHECK(condition) (void)(condition), EAT_STREAM_PARAMETERS
747 #define DPCHECK(condition) (void)(condition), EAT_STREAM_PARAMETERS
748
749 #endif // DCHECK_IS_ON()
750
751 #endif // _PREFAST_ && OS_WIN
740 752
741 // Helper macro for binary operators. 753 // Helper macro for binary operators.
742 // Don't use this macro directly in your code, use DCHECK_EQ et al below. 754 // Don't use this macro directly in your code, use DCHECK_EQ et al below.
743 // The 'switch' is used to prevent the 'else' from being ambiguous when the 755 // The 'switch' is used to prevent the 'else' from being ambiguous when the
744 // macro is used in an 'if' clause such as: 756 // macro is used in an 'if' clause such as:
745 // if (a == 1) 757 // if (a == 1)
746 // DCHECK_EQ(2, a); 758 // DCHECK_EQ(2, a);
747 #define DCHECK_OP(name, op, val1, val2) \ 759 #define DCHECK_OP(name, op, val1, val2) \
748 switch (0) case 0: default: \ 760 switch (0) case 0: default: \
749 if (::logging::CheckOpResult true_if_passed = \ 761 if (::logging::CheckOpResult true_if_passed = \
750 DCHECK_IS_ON() ? \ 762 DCHECK_IS_ON() ? \
danakj 2017/01/24 21:10:52 What about these
751 ::logging::Check##name##Impl((val1), (val2), \ 763 ::logging::Check##name##Impl((val1), (val2), \
752 #val1 " " #op " " #val2) : nullptr) \ 764 #val1 " " #op " " #val2) : nullptr) \
753 ; \ 765 ; \
754 else \ 766 else \
755 ::logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \ 767 ::logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \
756 true_if_passed.message()).stream() 768 true_if_passed.message()).stream()
757 769
758 // Equality/Inequality checks - compare two values, and log a 770 // Equality/Inequality checks - compare two values, and log a
759 // LOG_DCHECK message including the two values when the result is not 771 // LOG_DCHECK message including the two values when the result is not
760 // as expected. The values must have operator<<(ostream, ...) 772 // as expected. The values must have operator<<(ostream, ...)
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 #elif NOTIMPLEMENTED_POLICY == 5 1030 #elif NOTIMPLEMENTED_POLICY == 5
1019 #define NOTIMPLEMENTED() do {\ 1031 #define NOTIMPLEMENTED() do {\
1020 static bool logged_once = false;\ 1032 static bool logged_once = false;\
1021 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1033 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1022 logged_once = true;\ 1034 logged_once = true;\
1023 } while(0);\ 1035 } while(0);\
1024 EAT_STREAM_PARAMETERS 1036 EAT_STREAM_PARAMETERS
1025 #endif 1037 #endif
1026 1038
1027 #endif // BASE_LOGGING_H_ 1039 #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