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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/toolchain/clang_static_analyzer.gni » ('j') | build/toolchain/clang_static_analyzer.gni » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.h
diff --git a/base/logging.h b/base/logging.h
index 7854e3934e974b4670930d6855f3ab8699a8376f..07e2a02e2d256a7027f6cf84614cea323eae2f5f 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -726,7 +726,27 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
<< "Check failed: " #condition ". "
-#else // _PREFAST_
+#elif defined(__clang_analyzer__)
+
+// Keeps the static analyzer from proceeding along the current codepath,
+// 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.
+inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {
+ return false;
+}
+
+#define DCHECK(condition) \
+ LAZY_STREAM( \
+ LOG_STREAM(DCHECK), \
+ DCHECK_IS_ON() ? (logging::AnalyzerNoReturn(), !(condition)) : false) \
+ << "Check failed: " #condition ". "
+
+#define DPCHECK(condition) \
+ LAZY_STREAM( \
+ PLOG_STREAM(DCHECK), \
+ DCHECK_IS_ON() ? (logging::AnalyzerNoReturn(), !(condition)) : false) \
+ << "Check failed: " #condition ". "
+
+#else
#define DCHECK(condition) \
LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
@@ -736,7 +756,7 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() ? !(condition) : false) \
<< "Check failed: " #condition ". "
-#endif // _PREFAST_
+#endif
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
« 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