Chromium Code Reviews| Index: base/compiler_specific.h |
| diff --git a/base/compiler_specific.h b/base/compiler_specific.h |
| index 0f4c058b3be43963d76c23b0b3b8ec89fc8b3767..287e51184a3a902f3a495e284fc642a5b3192d88 100644 |
| --- a/base/compiler_specific.h |
| +++ b/base/compiler_specific.h |
| @@ -71,15 +71,27 @@ |
| #endif // COMPILER_MSVC |
| - |
| // Annotate a variable indicating it's ok if the variable is not used. |
| // (Typically used to silence a compiler warning when the assignment |
| // is important for some other reason.) |
| // Use like: |
| // int x = ...; |
| // ALLOW_UNUSED_LOCAL(x); |
| +// |
| +// The common-case implementation references |x| in such a way that it's never |
| +// evaluated. Static analysis builds still see this as not referencing |x|, so |
| +// in such cases we reference it directly to make the compiler happy, at the |
| +// risk of unintended side effects. |
| +#if defined(__clang_analyzer__) |
| + |
| +#define ALLOW_UNUSED_LOCAL(x) (void)x |
| + |
| +#else // !defined(__clang_analyzer__) |
| + |
| #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 |
|
Nico
2017/04/25 15:48:52
What was the problem with making this use `(void)x
Kevin Marshall
2017/04/25 17:17:31
When I asked pkasting (author of the original #def
|
| +#endif // defined(__clang_analyzer__) |
| + |
| // Annotate a typedef or function indicating it's ok if it's not used. |
| // Use like: |
| // typedef Foo Bar ALLOW_UNUSED_TYPE; |