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

Side by Side Diff: base/logging.h

Issue 2617283002: Add Clang static analyzer to Clang toolchain defs in GN (Closed)
Patch Set: sylvain feedback 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
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 #elif defined(__clang_analyzer__)
730
731 // Keeps the static analyzer from proceeding along the current codepath,
732 // otherwise false positive errors may be generated by null pointer checks.
Nico 2017/01/11 20:20:05 this is getting reviewed separately, right?
Wez 2017/01/14 00:04:58 Rather than have duplicate D[P]CHECK definitions,
Kevin M 2017/01/18 23:04:23 Yeah, I had patched it in to verify that it is WAI
Kevin M 2017/01/18 23:04:23 Will address this in the other CL.
733 inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
734 return false;
735 }
736
737 #define DCHECK(condition) \
738 LAZY_STREAM( \
739 LOG_STREAM(DCHECK), \
740 DCHECK_IS_ON() ? (logging::AnalyzerNoReturn(), !(condition)) : false) \
741 << "Check failed: " #condition ". "
742
743 #define DPCHECK(condition) \
744 LAZY_STREAM( \
745 PLOG_STREAM(DCHECK), \
746 DCHECK_IS_ON() ? (logging::AnalyzerNoReturn(), !(condition)) : false) \
747 << "Check failed: " #condition ". "
748
749 #else
730 750
731 #define DCHECK(condition) \ 751 #define DCHECK(condition) \
732 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 752 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
733 << "Check failed: " #condition ". " 753 << "Check failed: " #condition ". "
734 754
735 #define DPCHECK(condition) \ 755 #define DPCHECK(condition) \
736 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \ 756 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
737 << "Check failed: " #condition ". " 757 << "Check failed: " #condition ". "
738 758
739 #endif // _PREFAST_ 759 #endif
740 760
741 // Helper macro for binary operators. 761 // Helper macro for binary operators.
742 // Don't use this macro directly in your code, use DCHECK_EQ et al below. 762 // 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 763 // The 'switch' is used to prevent the 'else' from being ambiguous when the
744 // macro is used in an 'if' clause such as: 764 // macro is used in an 'if' clause such as:
745 // if (a == 1) 765 // if (a == 1)
746 // DCHECK_EQ(2, a); 766 // DCHECK_EQ(2, a);
747 #define DCHECK_OP(name, op, val1, val2) \ 767 #define DCHECK_OP(name, op, val1, val2) \
748 switch (0) case 0: default: \ 768 switch (0) case 0: default: \
749 if (::logging::CheckOpResult true_if_passed = \ 769 if (::logging::CheckOpResult true_if_passed = \
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 #elif NOTIMPLEMENTED_POLICY == 5 1038 #elif NOTIMPLEMENTED_POLICY == 5
1019 #define NOTIMPLEMENTED() do {\ 1039 #define NOTIMPLEMENTED() do {\
1020 static bool logged_once = false;\ 1040 static bool logged_once = false;\
1021 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1041 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1022 logged_once = true;\ 1042 logged_once = true;\
1023 } while(0);\ 1043 } while(0);\
1024 EAT_STREAM_PARAMETERS 1044 EAT_STREAM_PARAMETERS
1025 #endif 1045 #endif
1026 1046
1027 #endif // BASE_LOGGING_H_ 1047 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | build/toolchain/clang_static_analyzer.gni » ('j') | build/toolchain/clang_static_analyzer.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698