[email protected] | 2149cc62 | 2012-02-14 01:12:12 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
[email protected] | f1ea2fa | 2008-08-21 22:26:06 | [diff] [blame] | 4 | |
| 5 | #ifndef BASE_COMPILER_SPECIFIC_H_ |
| 6 | #define BASE_COMPILER_SPECIFIC_H_ |
| 7 | |
| 8 | #include "build/build_config.h" |
| 9 | |
Nico Weber | fb053cc | 2020-03-03 13:33:05 | [diff] [blame] | 10 | #if defined(COMPILER_MSVC) && !defined(__clang__) |
Nico Weber | 5979181 | 2019-07-27 04:02:11 | [diff] [blame] | 11 | #error "Only clang-cl is supported on Windows, see https://crbug.com/988071" |
| 12 | #endif |
| 13 | |
Jan Wilken Dörrie | d3742a4 | 2020-10-30 19:44:57 | [diff] [blame] | 14 | // This is a wrapper around `__has_cpp_attribute`, which can be used to test for |
| 15 | // the presence of an attribute. In case the compiler does not support this |
| 16 | // macro it will simply evaluate to 0. |
| 17 | // |
| 18 | // References: |
| 19 | // https://wg21.link/sd6#testing-for-the-presence-of-an-attribute-__has_cpp_attribute |
| 20 | // https://wg21.link/cpp.cond#:__has_cpp_attribute |
| 21 | #if defined(__has_cpp_attribute) |
| 22 | #define HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) |
| 23 | #else |
| 24 | #define HAS_CPP_ATTRIBUTE(x) 0 |
| 25 | #endif |
| 26 | |
[email protected] | f5059510 | 2010-10-08 16:20:32 | [diff] [blame] | 27 | // Annotate a variable indicating it's ok if the variable is not used. |
| 28 | // (Typically used to silence a compiler warning when the assignment |
| 29 | // is important for some other reason.) |
| 30 | // Use like: |
pkasting | 99867ef | 2014-10-16 23:49:24 | [diff] [blame] | 31 | // int x = ...; |
| 32 | // ALLOW_UNUSED_LOCAL(x); |
kmarshall | d10bb7f7 | 2017-04-26 02:55:41 | [diff] [blame] | 33 | #define ALLOW_UNUSED_LOCAL(x) (void)x |
pkasting | 99867ef | 2014-10-16 23:49:24 | [diff] [blame] | 34 | |
| 35 | // Annotate a typedef or function indicating it's ok if it's not used. |
| 36 | // Use like: |
| 37 | // typedef Foo Bar ALLOW_UNUSED_TYPE; |
thakis | 803f983 | 2015-07-20 18:10:55 | [diff] [blame] | 38 | #if defined(COMPILER_GCC) || defined(__clang__) |
pkasting | 99867ef | 2014-10-16 23:49:24 | [diff] [blame] | 39 | #define ALLOW_UNUSED_TYPE __attribute__((unused)) |
[email protected] | f5059510 | 2010-10-08 16:20:32 | [diff] [blame] | 40 | #else |
pkasting | 99867ef | 2014-10-16 23:49:24 | [diff] [blame] | 41 | #define ALLOW_UNUSED_TYPE |
[email protected] | 2149cc62 | 2012-02-14 01:12:12 | [diff] [blame] | 42 | #endif |
| 43 | |
| 44 | // Annotate a function indicating it should not be inlined. |
| 45 | // Use like: |
| 46 | // NOINLINE void DoStuff() { ... } |
| 47 | #if defined(COMPILER_GCC) |
| 48 | #define NOINLINE __attribute__((noinline)) |
| 49 | #elif defined(COMPILER_MSVC) |
| 50 | #define NOINLINE __declspec(noinline) |
| 51 | #else |
[email protected] | 50795a0 | 2011-05-09 20:11:01 | [diff] [blame] | 52 | #define NOINLINE |
[email protected] | f5059510 | 2010-10-08 16:20:32 | [diff] [blame] | 53 | #endif |
| 54 | |
Ivan Krasin | 9c098a0d | 2018-08-05 03:57:57 | [diff] [blame] | 55 | #if defined(COMPILER_GCC) && defined(NDEBUG) |
palmer | 58184a828 | 2016-11-08 19:15:39 | [diff] [blame] | 56 | #define ALWAYS_INLINE inline __attribute__((__always_inline__)) |
Ivan Krasin | 9c098a0d | 2018-08-05 03:57:57 | [diff] [blame] | 57 | #elif defined(COMPILER_MSVC) && defined(NDEBUG) |
palmer | 58184a828 | 2016-11-08 19:15:39 | [diff] [blame] | 58 | #define ALWAYS_INLINE __forceinline |
| 59 | #else |
| 60 | #define ALWAYS_INLINE inline |
| 61 | #endif |
| 62 | |
Olivier Li | 19d8925 | 2020-05-13 17:57:55 | [diff] [blame] | 63 | // Annotate a function indicating it should never be tail called. Useful to make |
| 64 | // sure callers of the annotated function are never omitted from call-stacks. |
| 65 | // To provide the complementary behavior (prevent the annotated function from |
| 66 | // being omitted) look at NOINLINE. Also note that this doesn't prevent code |
| 67 | // folding of multiple identical caller functions into a single signature. To |
| 68 | // prevent code folding, see base::debug::Alias. |
| 69 | // Use like: |
| 70 | // void NOT_TAIL_CALLED FooBar(); |
| 71 | #if defined(__clang__) && __has_attribute(not_tail_called) |
| 72 | #define NOT_TAIL_CALLED __attribute__((not_tail_called)) |
| 73 | #else |
| 74 | #define NOT_TAIL_CALLED |
| 75 | #endif |
| 76 | |
[email protected] | cd924d6 | 2012-02-23 17:52:20 | [diff] [blame] | 77 | // Specify memory alignment for structs, classes, etc. |
| 78 | // Use like: |
| 79 | // class ALIGNAS(16) MyClass { ... } |
| 80 | // ALIGNAS(16) int array[4]; |
brettw | 16289b3e | 2017-06-13 21:58:40 | [diff] [blame] | 81 | // |
| 82 | // In most places you can use the C++11 keyword "alignas", which is preferred. |
| 83 | // |
| 84 | // But compilers have trouble mixing __attribute__((...)) syntax with |
| 85 | // alignas(...) syntax. |
| 86 | // |
| 87 | // Doesn't work in clang or gcc: |
| 88 | // struct alignas(16) __attribute__((packed)) S { char c; }; |
| 89 | // Works in clang but not gcc: |
| 90 | // struct __attribute__((packed)) alignas(16) S2 { char c; }; |
| 91 | // Works in clang and gcc: |
| 92 | // struct alignas(16) S3 { char c; } __attribute__((packed)); |
| 93 | // |
| 94 | // There are also some attributes that must be specified *before* a class |
| 95 | // definition: visibility (used for exporting functions/classes) is one of |
| 96 | // these attributes. This means that it is not possible to use alignas() with a |
| 97 | // class that is marked as exported. |
[email protected] | cd924d6 | 2012-02-23 17:52:20 | [diff] [blame] | 98 | #if defined(COMPILER_MSVC) |
| 99 | #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) |
| 100 | #elif defined(COMPILER_GCC) |
| 101 | #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) |
| 102 | #endif |
| 103 | |
[email protected] | f5059510 | 2010-10-08 16:20:32 | [diff] [blame] | 104 | // Annotate a function indicating the caller must examine the return value. |
| 105 | // Use like: |
| 106 | // int foo() WARN_UNUSED_RESULT; |
toyoshim | 20986cf | 2015-07-03 08:38:07 | [diff] [blame] | 107 | // To explicitly ignore a result, see |ignore_result()| in base/macros.h. |
dcheng | 7764fe9 | 2015-10-10 01:17:26 | [diff] [blame] | 108 | #undef WARN_UNUSED_RESULT |
| 109 | #if defined(COMPILER_GCC) || defined(__clang__) |
[email protected] | dd9afc0b | 2008-11-21 23:58:09 | [diff] [blame] | 110 | #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
[email protected] | f5059510 | 2010-10-08 16:20:32 | [diff] [blame] | 111 | #else |
| 112 | #define WARN_UNUSED_RESULT |
| 113 | #endif |
[email protected] | 34b2b00 | 2009-11-20 06:53:28 | [diff] [blame] | 114 | |
Jan Wilken Dörrie | d3742a4 | 2020-10-30 19:44:57 | [diff] [blame] | 115 | // In case the compiler supports it NO_UNIQUE_ADDRESS evaluates to the C++20 |
| 116 | // attribute [[no_unique_address]]. This allows annotating data members so that |
| 117 | // they need not have an address distinct from all other non-static data members |
| 118 | // of its class. |
| 119 | // |
| 120 | // References: |
| 121 | // * https://en.cppreference.com/w/cpp/language/attributes/no_unique_address |
| 122 | // * https://wg21.link/dcl.attr.nouniqueaddr |
| 123 | #if HAS_CPP_ATTRIBUTE(no_unique_address) |
| 124 | #define NO_UNIQUE_ADDRESS [[no_unique_address]] |
| 125 | #else |
| 126 | #define NO_UNIQUE_ADDRESS |
| 127 | #endif |
| 128 | |
[email protected] | 34b2b00 | 2009-11-20 06:53:28 | [diff] [blame] | 129 | // Tell the compiler a function is using a printf-style format string. |
| 130 | // |format_param| is the one-based index of the format string parameter; |
| 131 | // |dots_param| is the one-based index of the "..." parameter. |
| 132 | // For v*printf functions (which take a va_list), pass 0 for dots_param. |
| 133 | // (This is undocumented but matches what the system C headers do.) |
Nico Weber | fc7c8dd | 2019-02-28 21:28:44 | [diff] [blame] | 134 | // For member functions, the implicit this parameter counts as index 1. |
Bruce Dawson | 73528d1 | 2017-08-09 01:04:29 | [diff] [blame] | 135 | #if defined(COMPILER_GCC) || defined(__clang__) |
[email protected] | 34b2b00 | 2009-11-20 06:53:28 | [diff] [blame] | 136 | #define PRINTF_FORMAT(format_param, dots_param) \ |
Vitaly Buka | 2b79076 | 2019-12-20 21:11:48 | [diff] [blame] | 137 | __attribute__((format(printf, format_param, dots_param))) |
[email protected] | f5059510 | 2010-10-08 16:20:32 | [diff] [blame] | 138 | #else |
| 139 | #define PRINTF_FORMAT(format_param, dots_param) |
| 140 | #endif |
[email protected] | 34b2b00 | 2009-11-20 06:53:28 | [diff] [blame] | 141 | |
| 142 | // WPRINTF_FORMAT is the same, but for wide format strings. |
[email protected] | f5059510 | 2010-10-08 16:20:32 | [diff] [blame] | 143 | // This doesn't appear to yet be implemented in any compiler. |
[email protected] | 34b2b00 | 2009-11-20 06:53:28 | [diff] [blame] | 144 | // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . |
| 145 | #define WPRINTF_FORMAT(format_param, dots_param) |
| 146 | // If available, it would look like: |
| 147 | // __attribute__((format(wprintf, format_param, dots_param))) |
| 148 | |
etienneb | 4e9250a | 2016-11-18 18:47:53 | [diff] [blame] | 149 | // Sanitizers annotations. |
| 150 | #if defined(__has_attribute) |
| 151 | #if __has_attribute(no_sanitize) |
| 152 | #define NO_SANITIZE(what) __attribute__((no_sanitize(what))) |
| 153 | #endif |
| 154 | #endif |
| 155 | #if !defined(NO_SANITIZE) |
| 156 | #define NO_SANITIZE(what) |
| 157 | #endif |
| 158 | |
[email protected] | 75086be | 2013-03-20 21:18:22 | [diff] [blame] | 159 | // MemorySanitizer annotations. |
[email protected] | 36c2b137 | 2014-02-07 18:54:44 | [diff] [blame] | 160 | #if defined(MEMORY_SANITIZER) && !defined(OS_NACL) |
[email protected] | eb82dfb | 2014-02-03 19:51:17 | [diff] [blame] | 161 | #include <sanitizer/msan_interface.h> |
[email protected] | 75086be | 2013-03-20 21:18:22 | [diff] [blame] | 162 | |
| 163 | // Mark a memory region fully initialized. |
| 164 | // Use this to annotate code that deliberately reads uninitialized data, for |
| 165 | // example a GC scavenging root set pointers from the stack. |
Vitaly Buka | 2b79076 | 2019-12-20 21:11:48 | [diff] [blame] | 166 | #define MSAN_UNPOISON(p, size) __msan_unpoison(p, size) |
thestig | 1a42b407 | 2015-03-16 22:36:55 | [diff] [blame] | 167 | |
| 168 | // Check a memory region for initializedness, as if it was being used here. |
| 169 | // If any bits are uninitialized, crash with an MSan report. |
| 170 | // Use this to sanitize data which MSan won't be able to track, e.g. before |
| 171 | // passing data to another process via shared memory. |
| 172 | #define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) \ |
Vitaly Buka | 2b79076 | 2019-12-20 21:11:48 | [diff] [blame] | 173 | __msan_check_mem_is_initialized(p, size) |
[email protected] | 75086be | 2013-03-20 21:18:22 | [diff] [blame] | 174 | #else // MEMORY_SANITIZER |
thestig | 1a42b407 | 2015-03-16 22:36:55 | [diff] [blame] | 175 | #define MSAN_UNPOISON(p, size) |
| 176 | #define MSAN_CHECK_MEM_IS_INITIALIZED(p, size) |
[email protected] | 75086be | 2013-03-20 21:18:22 | [diff] [blame] | 177 | #endif // MEMORY_SANITIZER |
| 178 | |
krasin | 825ce48 | 2016-08-27 11:01:11 | [diff] [blame] | 179 | // DISABLE_CFI_PERF -- Disable Control Flow Integrity for perf reasons. |
| 180 | #if !defined(DISABLE_CFI_PERF) |
krasin | 40f7c78 | 2016-09-22 19:04:27 | [diff] [blame] | 181 | #if defined(__clang__) && defined(OFFICIAL_BUILD) |
krasin | 825ce48 | 2016-08-27 11:01:11 | [diff] [blame] | 182 | #define DISABLE_CFI_PERF __attribute__((no_sanitize("cfi"))) |
| 183 | #else |
| 184 | #define DISABLE_CFI_PERF |
| 185 | #endif |
| 186 | #endif |
| 187 | |
Will Harris | 9a033b0 | 2020-07-11 01:26:54 | [diff] [blame] | 188 | // DISABLE_CFI_ICALL -- Disable Control Flow Integrity indirect call checks. |
| 189 | #if !defined(DISABLE_CFI_ICALL) |
| 190 | #if defined(OS_WIN) |
| 191 | // Windows also needs __declspec(guard(nocf)). |
| 192 | #define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") __declspec(guard(nocf)) |
| 193 | #else |
| 194 | #define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") |
| 195 | #endif |
| 196 | #endif |
| 197 | #if !defined(DISABLE_CFI_ICALL) |
| 198 | #define DISABLE_CFI_ICALL |
| 199 | #endif |
| 200 | |
[email protected] | 5a8d4ce | 2013-12-18 17:42:27 | [diff] [blame] | 201 | // Macro useful for writing cross-platform function pointers. |
| 202 | #if !defined(CDECL) |
| 203 | #if defined(OS_WIN) |
| 204 | #define CDECL __cdecl |
| 205 | #else // defined(OS_WIN) |
| 206 | #define CDECL |
| 207 | #endif // defined(OS_WIN) |
| 208 | #endif // !defined(CDECL) |
| 209 | |
[email protected] | 2bc0c699 | 2014-02-13 16:11:04 | [diff] [blame] | 210 | // Macro for hinting that an expression is likely to be false. |
| 211 | #if !defined(UNLIKELY) |
Vladimir Levin | 6b77771 | 2017-09-09 00:12:05 | [diff] [blame] | 212 | #if defined(COMPILER_GCC) || defined(__clang__) |
[email protected] | 2bc0c699 | 2014-02-13 16:11:04 | [diff] [blame] | 213 | #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 214 | #else |
| 215 | #define UNLIKELY(x) (x) |
| 216 | #endif // defined(COMPILER_GCC) |
| 217 | #endif // !defined(UNLIKELY) |
| 218 | |
palmer | 58184a828 | 2016-11-08 19:15:39 | [diff] [blame] | 219 | #if !defined(LIKELY) |
Vladimir Levin | 6b77771 | 2017-09-09 00:12:05 | [diff] [blame] | 220 | #if defined(COMPILER_GCC) || defined(__clang__) |
Chris Palmer | ad4cb83f | 2016-11-18 20:02:25 | [diff] [blame] | 221 | #define LIKELY(x) __builtin_expect(!!(x), 1) |
palmer | 58184a828 | 2016-11-08 19:15:39 | [diff] [blame] | 222 | #else |
| 223 | #define LIKELY(x) (x) |
| 224 | #endif // defined(COMPILER_GCC) |
| 225 | #endif // !defined(LIKELY) |
| 226 | |
jfb | d81c1ce | 2016-04-05 20:50:35 | [diff] [blame] | 227 | // Compiler feature-detection. |
jfb | a8dc9dd8 | 2016-04-06 20:20:31 | [diff] [blame] | 228 | // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension |
| 229 | #if defined(__has_feature) |
| 230 | #define HAS_FEATURE(FEATURE) __has_feature(FEATURE) |
| 231 | #else |
| 232 | #define HAS_FEATURE(FEATURE) 0 |
jfb | d81c1ce | 2016-04-05 20:50:35 | [diff] [blame] | 233 | #endif |
| 234 | |
Nico Weber | 0ae8836 | 2018-01-25 19:26:02 | [diff] [blame] | 235 | // Macro for telling -Wimplicit-fallthrough that a fallthrough is intentional. |
Nico Weber | 0ae8836 | 2018-01-25 19:26:02 | [diff] [blame] | 236 | #if defined(__clang__) |
| 237 | #define FALLTHROUGH [[clang::fallthrough]] |
| 238 | #else |
| 239 | #define FALLTHROUGH |
| 240 | #endif |
Nico Weber | 0ae8836 | 2018-01-25 19:26:02 | [diff] [blame] | 241 | |
Alex Clarke | 23c6cf7 | 2018-11-21 13:22:27 | [diff] [blame] | 242 | #if defined(COMPILER_GCC) |
| 243 | #define PRETTY_FUNCTION __PRETTY_FUNCTION__ |
| 244 | #elif defined(COMPILER_MSVC) |
| 245 | #define PRETTY_FUNCTION __FUNCSIG__ |
| 246 | #else |
| 247 | // See https://en.cppreference.com/w/c/language/function_definition#func |
| 248 | #define PRETTY_FUNCTION __func__ |
| 249 | #endif |
| 250 | |
Henrique Ferreiro | 6daf71db | 2019-04-03 13:12:42 | [diff] [blame] | 251 | #if !defined(CPU_ARM_NEON) |
| 252 | #if defined(__arm__) |
| 253 | #if !defined(__ARMEB__) && !defined(__ARM_EABI__) && !defined(__EABI__) && \ |
| 254 | !defined(__VFP_FP__) && !defined(_WIN32_WCE) && !defined(ANDROID) |
| 255 | #error Chromium does not support middle endian architecture |
| 256 | #endif |
| 257 | #if defined(__ARM_NEON__) |
| 258 | #define CPU_ARM_NEON 1 |
| 259 | #endif |
| 260 | #endif // defined(__arm__) |
| 261 | #endif // !defined(CPU_ARM_NEON) |
| 262 | |
| 263 | #if !defined(HAVE_MIPS_MSA_INTRINSICS) |
| 264 | #if defined(__mips_msa) && defined(__mips_isa_rev) && (__mips_isa_rev >= 5) |
| 265 | #define HAVE_MIPS_MSA_INTRINSICS 1 |
| 266 | #endif |
| 267 | #endif |
| 268 | |
Vitaly Buka | 2b79076 | 2019-12-20 21:11:48 | [diff] [blame] | 269 | #if defined(__clang__) && __has_attribute(uninitialized) |
| 270 | // Attribute "uninitialized" disables -ftrivial-auto-var-init=pattern for |
| 271 | // the specified variable. |
| 272 | // Library-wide alternative is |
| 273 | // 'configs -= [ "//build/config/compiler:default_init_stack_vars" ]' in .gn |
| 274 | // file. |
| 275 | // |
| 276 | // See "init_stack_vars" in build/config/compiler/BUILD.gn and |
| 277 | // http://crbug.com/977230 |
| 278 | // "init_stack_vars" is enabled for non-official builds and we hope to enable it |
| 279 | // in official build in 2020 as well. The flag writes fixed pattern into |
| 280 | // uninitialized parts of all local variables. In rare cases such initialization |
| 281 | // is undesirable and attribute can be used: |
| 282 | // 1. Degraded performance |
| 283 | // In most cases compiler is able to remove additional stores. E.g. if memory is |
| 284 | // never accessed or properly initialized later. Preserved stores mostly will |
| 285 | // not affect program performance. However if compiler failed on some |
| 286 | // performance critical code we can get a visible regression in a benchmark. |
| 287 | // 2. memset, memcpy calls |
| 288 | // Compiler may replaces some memory writes with memset or memcpy calls. This is |
| 289 | // not -ftrivial-auto-var-init specific, but it can happen more likely with the |
| 290 | // flag. It can be a problem if code is not linked with C run-time library. |
| 291 | // |
| 292 | // Note: The flag is security risk mitigation feature. So in future the |
| 293 | // attribute uses should be avoided when possible. However to enable this |
| 294 | // mitigation on the most of the code we need to be less strict now and minimize |
| 295 | // number of exceptions later. So if in doubt feel free to use attribute, but |
| 296 | // please document the problem for someone who is going to cleanup it later. |
| 297 | // E.g. platform, bot, benchmark or test name in patch description or next to |
| 298 | // the attribute. |
| 299 | #define STACK_UNINITIALIZED __attribute__((uninitialized)) |
| 300 | #else |
| 301 | #define STACK_UNINITIALIZED |
| 302 | #endif |
| 303 | |
Hans Wennborg | 12aea3e | 2020-04-14 15:29:00 | [diff] [blame] | 304 | // The ANALYZER_ASSUME_TRUE(bool arg) macro adds compiler-specific hints |
| 305 | // to Clang which control what code paths are statically analyzed, |
| 306 | // and is meant to be used in conjunction with assert & assert-like functions. |
| 307 | // The expression is passed straight through if analysis isn't enabled. |
| 308 | // |
| 309 | // ANALYZER_SKIP_THIS_PATH() suppresses static analysis for the current |
| 310 | // codepath and any other branching codepaths that might follow. |
| 311 | #if defined(__clang_analyzer__) |
| 312 | |
| 313 | inline constexpr bool AnalyzerNoReturn() __attribute__((analyzer_noreturn)) { |
| 314 | return false; |
| 315 | } |
| 316 | |
| 317 | inline constexpr bool AnalyzerAssumeTrue(bool arg) { |
| 318 | // AnalyzerNoReturn() is invoked and analysis is terminated if |arg| is |
| 319 | // false. |
| 320 | return arg || AnalyzerNoReturn(); |
| 321 | } |
| 322 | |
George Burgess IV | a09d235d | 2020-04-17 13:32:50 | [diff] [blame] | 323 | #define ANALYZER_ASSUME_TRUE(arg) ::AnalyzerAssumeTrue(!!(arg)) |
| 324 | #define ANALYZER_SKIP_THIS_PATH() static_cast<void>(::AnalyzerNoReturn()) |
Hans Wennborg | 12aea3e | 2020-04-14 15:29:00 | [diff] [blame] | 325 | #define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var); |
| 326 | |
| 327 | #else // !defined(__clang_analyzer__) |
| 328 | |
| 329 | #define ANALYZER_ASSUME_TRUE(arg) (arg) |
| 330 | #define ANALYZER_SKIP_THIS_PATH() |
| 331 | #define ANALYZER_ALLOW_UNUSED(var) static_cast<void>(var); |
| 332 | |
| 333 | #endif // defined(__clang_analyzer__) |
| 334 | |
[email protected] | dd9afc0b | 2008-11-21 23:58:09 | [diff] [blame] | 335 | #endif // BASE_COMPILER_SPECIFIC_H_ |