OLD | NEW |
---|---|
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_COMPILER_SPECIFIC_H_ | 5 #ifndef BASE_COMPILER_SPECIFIC_H_ |
6 #define BASE_COMPILER_SPECIFIC_H_ | 6 #define BASE_COMPILER_SPECIFIC_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(COMPILER_MSVC) | 10 #if defined(COMPILER_MSVC) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 | 71 |
72 #endif // COMPILER_MSVC | 72 #endif // COMPILER_MSVC |
73 | 73 |
74 | 74 |
75 // Annotate a variable indicating it's ok if the variable is not used. | 75 // Annotate a variable indicating it's ok if the variable is not used. |
76 // (Typically used to silence a compiler warning when the assignment | 76 // (Typically used to silence a compiler warning when the assignment |
77 // is important for some other reason.) | 77 // is important for some other reason.) |
78 // Use like: | 78 // Use like: |
79 // int x = ...; | 79 // int x = ...; |
80 // ALLOW_UNUSED_LOCAL(x); | 80 // ALLOW_UNUSED_LOCAL(x); |
81 #if defined(__clang_analyzer__) | |
82 | |
83 // Voidify 'x' on codepath-sensitive static analyzer builds, potentially | |
84 // producing side effects. | |
85 #define ALLOW_UNUSED_LOCAL(x) (void)x | |
86 | |
87 #else // !defined(__clang_analyzer__) | |
88 | |
89 // Voidify 'x' without side effects. | |
81 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 | 90 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 |
82 | 91 |
92 #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.
| |
93 | |
83 // Annotate a typedef or function indicating it's ok if it's not used. | 94 // Annotate a typedef or function indicating it's ok if it's not used. |
84 // Use like: | 95 // Use like: |
85 // typedef Foo Bar ALLOW_UNUSED_TYPE; | 96 // typedef Foo Bar ALLOW_UNUSED_TYPE; |
86 #if defined(COMPILER_GCC) || defined(__clang__) | 97 #if defined(COMPILER_GCC) || defined(__clang__) |
87 #define ALLOW_UNUSED_TYPE __attribute__((unused)) | 98 #define ALLOW_UNUSED_TYPE __attribute__((unused)) |
88 #else | 99 #else |
89 #define ALLOW_UNUSED_TYPE | 100 #define ALLOW_UNUSED_TYPE |
90 #endif | 101 #endif |
91 | 102 |
92 // Annotate a function indicating it should not be inlined. | 103 // Annotate a function indicating it should not be inlined. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 | 235 |
225 // Compiler feature-detection. | 236 // Compiler feature-detection. |
226 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension | 237 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension |
227 #if defined(__has_feature) | 238 #if defined(__has_feature) |
228 #define HAS_FEATURE(FEATURE) __has_feature(FEATURE) | 239 #define HAS_FEATURE(FEATURE) __has_feature(FEATURE) |
229 #else | 240 #else |
230 #define HAS_FEATURE(FEATURE) 0 | 241 #define HAS_FEATURE(FEATURE) 0 |
231 #endif | 242 #endif |
232 | 243 |
233 #endif // BASE_COMPILER_SPECIFIC_H_ | 244 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |