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

Unified Diff: base/compiler_specific.h

Issue 2838713002: Simplify ALLOW_UNUSED_LOCAL to use (void)x directly instead of conditionally. (Closed)
Patch Set: Created 3 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/compiler_specific.h
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index 0f4c058b3be43963d76c23b0b3b8ec89fc8b3767..7e77296b93c0ff4b8866d148b1903d6717ae4f85 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -78,8 +78,19 @@
// Use like:
// int x = ...;
// ALLOW_UNUSED_LOCAL(x);
+#if defined(__clang_analyzer__)
+
+// Voidify 'x' on codepath-sensitive static analyzer builds, potentially
+// producing side effects.
+#define ALLOW_UNUSED_LOCAL(x) (void)x
+
+#else // !defined(__clang_analyzer__)
+
+// Voidify 'x' without side effects.
#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
+#endif // defined(__clang_analyzer__)
Peter Kasting 2017/04/24 21:59:25 Nit: I think this would be easier to read with com
Kevin M 2017/04/24 22:37:39 Yes, that's an improvement. Thanks, done.
+
// Annotate a typedef or function indicating it's ok if it's not used.
// Use like:
// typedef Foo Bar ALLOW_UNUSED_TYPE;
« 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