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

Side by Side Diff: base/compiler_specific.h

Issue 12310041: experiment with -Wimplicit-fallthrough Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase Created 6 years, 12 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/json/json_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 #elif defined(__clang__) 142 #elif defined(__clang__)
143 #define OVERRIDE override 143 #define OVERRIDE override
144 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ 144 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
145 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 145 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
146 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. 146 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
147 #define OVERRIDE override 147 #define OVERRIDE override
148 #else 148 #else
149 #define OVERRIDE 149 #define OVERRIDE
150 #endif 150 #endif
151 151
152 // XXX amazing comment
153 #if defined(__clang__) && defined(__has_warning)
154 #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
155 #define FALLTHROUGH_INTENDED [[clang::fallthrough]] // NOLINT
156 #endif
157 #endif
158
159 #ifndef FALLTHROUGH_INTENDED
160 #define FALLTHROUGH_INTENDED do { } while (0)
161
152 // Annotate a virtual method indicating that subclasses must not override it, 162 // Annotate a virtual method indicating that subclasses must not override it,
153 // or annotate a class to indicate that it cannot be subclassed. 163 // or annotate a class to indicate that it cannot be subclassed.
154 // Use like: 164 // Use like:
155 // virtual void foo() FINAL; 165 // virtual void foo() FINAL;
156 // class B FINAL : public A {}; 166 // class B FINAL : public A {};
157 #if defined(COMPILER_MSVC) 167 #if defined(COMPILER_MSVC)
158 // TODO(jered): Change this to "final" when chromium no longer uses MSVC 2010. 168 // TODO(jered): Change this to "final" when chromium no longer uses MSVC 2010.
159 #define FINAL sealed 169 #define FINAL sealed
160 #elif defined(__clang__) 170 #elif defined(__clang__)
161 #define FINAL final 171 #define FINAL final
162 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ 172 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
163 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 173 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
164 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. 174 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
165 #define FINAL final 175 #define FINAL final
166 #else 176 #else
167 #define FINAL 177 #define FINAL
168 #endif 178 #endif
169 179
180 // Annotate a virtual method indicating it must be overriding a virtual
181 // method in the parent class.
182 // Use like:
183 // virtual void foo() OVERRIDE;
184 #if defined(COMPILER_MSVC)
185 #define OVERRIDE override
186 #elif defined(__clang__)
187 #define OVERRIDE override
188 #else
189 #define OVERRIDE
190 #endif
191
170 // Annotate a function indicating the caller must examine the return value. 192 // Annotate a function indicating the caller must examine the return value.
171 // Use like: 193 // Use like:
172 // int foo() WARN_UNUSED_RESULT; 194 // int foo() WARN_UNUSED_RESULT;
173 // To explicitly ignore a result, see |ignore_result()| in <base/basictypes.h>. 195 // To explicitly ignore a result, see |ignore_result()| in <base/basictypes.h>.
174 #if defined(COMPILER_GCC) 196 #if defined(COMPILER_GCC)
175 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 197 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
176 #else 198 #else
177 #define WARN_UNUSED_RESULT 199 #define WARN_UNUSED_RESULT
178 #endif 200 #endif
179 201
180 // Tell the compiler a function is using a printf-style format string. 202 // Tell the compiler a function is using a printf-style format string.
181 // |format_param| is the one-based index of the format string parameter; 203 // |format_param| is the one-based index of the format string parameter;
182 // |dots_param| is the one-based index of the "..." parameter. 204 // |dots_param| is the one-based index of the "..." parameter.
183 // For v*printf functions (which take a va_list), pass 0 for dots_param. 205 // For v*printf functions (which take a va_list), pass 0 for dots_param.
184 // (This is undocumented but matches what the system C headers do.) 206 // (This is undocumented but matches what the system C headers do.)
185 #if defined(COMPILER_GCC) 207 #if defined(COMPILER_GCC)
186 #define PRINTF_FORMAT(format_param, dots_param) \ 208 #define PRINTF_FORMAT(format_param, dots_param) \
187 __attribute__((format(printf, format_param, dots_param))) 209 __attribute__((format(printf, format_param, dots_param)))
188 #else 210 #else
189 #define PRINTF_FORMAT(format_param, dots_param) 211 #define PRINTF_FORMAT(format_param, dots_param)
190 #endif 212 #endif
191 213
192 // WPRINTF_FORMAT is the same, but for wide format strings. 214 // WPRINTF_FORMAT is the same, but for wide format strings.
193 // This doesn't appear to yet be implemented in any compiler. 215 // This doesn't appear to yet be implemented in any compiler.
194 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 . 216 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38308 .
195 #define WPRINTF_FORMAT(format_param, dots_param) 217 #define WPRINTF_FORMAT(format_param, dots_param)
196 // If available, it would look like: 218 // If available, it would look like:
197 // __attribute__((format(wprintf, format_param, dots_param))) 219 // __attribute__((format(wprintf, format_param, dots_param)))
198 220
199
200 // MemorySanitizer annotations. 221 // MemorySanitizer annotations.
201 #ifdef MEMORY_SANITIZER 222 #ifdef MEMORY_SANITIZER
202 extern "C" { 223 extern "C" {
203 void __msan_unpoison(const void *p, unsigned long s); 224 void __msan_unpoison(const void *p, unsigned long s);
204 } // extern "C" 225 } // extern "C"
205 226
206 // Mark a memory region fully initialized. 227 // Mark a memory region fully initialized.
207 // Use this to annotate code that deliberately reads uninitialized data, for 228 // Use this to annotate code that deliberately reads uninitialized data, for
208 // example a GC scavenging root set pointers from the stack. 229 // example a GC scavenging root set pointers from the stack.
209 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s) 230 #define MSAN_UNPOISON(p, s) __msan_unpoison(p, s)
210 #else // MEMORY_SANITIZER 231 #else // MEMORY_SANITIZER
211 #define MSAN_UNPOISON(p, s) 232 #define MSAN_UNPOISON(p, s)
212 #endif // MEMORY_SANITIZER 233 #endif // MEMORY_SANITIZER
213 234
214 // Macro useful for writing cross-platform function pointers. 235 // Macro useful for writing cross-platform function pointers.
215 #if !defined(CDECL) 236 #if !defined(CDECL)
216 #if defined(OS_WIN) 237 #if defined(OS_WIN)
217 #define CDECL __cdecl 238 #define CDECL __cdecl
218 #else // defined(OS_WIN) 239 #else // defined(OS_WIN)
219 #define CDECL 240 #define CDECL
220 #endif // defined(OS_WIN) 241 #endif // defined(OS_WIN)
221 #endif // !defined(CDECL) 242 #endif // !defined(CDECL)
222 243
223 #endif // BASE_COMPILER_SPECIFIC_H_ 244 #endif // BASE_COMPILER_SPECIFIC_H_
OLDNEW
« no previous file with comments | « no previous file | base/json/json_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698