[llvm] r237766 - Support: Introduce LLVM_FALLTHROUGH macro.

Pete Cooper peter_cooper at apple.com
Thu May 21 09:37:34 PDT 2015


Hi Peter

Are you planning on using this in the LLVM/clang codebases?

I’m in favour of using it, but there was discussion a few years ago where some doubts were raised.  In particular (http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-July/052103.html <http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-July/052103.html>):

"I don't really see that the tradeoff here is worthwhile.  It is possible that we have some fallthrough bugs, but the cost of sprinkling this macro everywhere doesn't seem like the right tradeoff.

-Chris”

It would be worth revising that discussion before making use of this throughout the codebase.

Cheers,
Pete
> On May 19, 2015, at 7:44 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> 
> Author: pcc
> Date: Tue May 19 21:44:14 2015
> New Revision: 237766
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=237766&view=rev
> Log:
> Support: Introduce LLVM_FALLTHROUGH macro.
> 
> Modified:
>    llvm/trunk/include/llvm/Support/Compiler.h
> 
> Modified: llvm/trunk/include/llvm/Support/Compiler.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=237766&r1=237765&r2=237766&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/Compiler.h (original)
> +++ llvm/trunk/include/llvm/Support/Compiler.h Tue May 19 21:44:14 2015
> @@ -29,6 +29,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
> @@ -401,4 +405,12 @@
> #define LLVM_THREAD_LOCAL
> #endif
> 
> +/// \macro LLVM_FALLTHROUGH
> +/// \brief Marks an empty statement preceding a deliberate switch fallthrough.
> +#if __has_cpp_attribute(clang::fallthrough)
> +#define LLVM_FALLTHROUGH [[clang::fallthrough]]
> +#else
> +#define LLVM_FALLTHROUGH
> +#endif
> +
> #endif
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150521/88a5f080/attachment.html>


More information about the llvm-commits mailing list