diff options
author | John McCall <rjmccall@apple.com> | 2011-03-14 20:01:21 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-03-14 20:01:21 +0000 |
commit | 2f9a9ed785416a7350f30141fcc405b69a1b9d5d (patch) | |
tree | 04c3811dcf74f84b4eefbe4593cc3d3cd840d2ca /include/llvm/Support/Compiler.h | |
parent | 766faf4b2b7fe2835181777fb50d9f4d1814aba5 (diff) |
Make llvm_unreachable evaluate to __builtin_unreachable() in -Asserts
builds, which was the apparent consensus of PR8973 and llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/Compiler.h')
-rw-r--r-- | include/llvm/Support/Compiler.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 67f0fd7e0d..2d2a0b124a 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -126,4 +126,19 @@ decl #endif +// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands +// to an expression which states that it is undefined behavior for the +// compiler to reach this point. +#if defined(__clang__) || (__GNUC__ > 4) \ + || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) +# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() +#else +#ifdef __cplusplus +extern "C" LLVM_ATTRIBUTE_NORETURN void abort(); +#else +extern LLVM_ATTRIBUTE_NORETURN void abort(); +#endif +# define LLVM_BUILTIN_UNREACHABLE abort() +#endif + #endif |