diff options
| author | Justin Bogner <mail@justinbogner.com> | 2016-08-16 23:24:13 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2016-08-16 23:24:13 +0000 |
| commit | a36f4a25b313ddddeceb77ebc2328e22ac4fdc5b (patch) | |
| tree | d0b9ccf78c090765aca1e755ad1fd7df629c5b53 | |
| parent | 7ad324b3965699cd52fb4b133f3ab7eb39c656e5 (diff) | |
| download | bcm5719-llvm-a36f4a25b313ddddeceb77ebc2328e22ac4fdc5b.tar.gz bcm5719-llvm-a36f4a25b313ddddeceb77ebc2328e22ac4fdc5b.zip | |
Introduce LLVM_FALLTHROUGH, which expands to the C++17 attribute.
This allows you to annotate switch case fallthrough in a better way
than a "// FALLTHROUGH" comment. Eventually it would be nice to turn
on -Wimplicit-fallthrough, if we can get the code base clean.
llvm-svn: 278868
| -rw-r--r-- | llvm/include/llvm/Support/Compiler.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index 516691f29de..6b00ff91cb0 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -33,6 +33,10 @@ # define __has_attribute(x) 0 #endif +#ifndef __has_cpp_attribute +# define __has_cpp_attribute(x) 0 +#endif + #ifndef __has_builtin # define __has_builtin(x) 0 #endif @@ -228,6 +232,15 @@ #define LLVM_ATTRIBUTE_RETURNS_NOALIAS #endif +/// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements. +#if __has_cpp_attribute(fallthrough) +#define LLVM_FALLTHROUGH [[fallthrough]] +#elif __has_cpp_attribute(clang::fallthrough) +#define LLVM_FALLTHROUGH [[clang::fallthrough]] +#else +#define LLVM_FALLTHROUGH +#endif + /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress /// pedantic diagnostics. #ifdef __GNUC__ |

