aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Support/Compiler.h15
-rw-r--r--include/llvm/Support/ErrorHandling.h2
2 files changed, 16 insertions, 1 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
diff --git a/include/llvm/Support/ErrorHandling.h b/include/llvm/Support/ErrorHandling.h
index 5eca438d8b..fb0c88d8d8 100644
--- a/include/llvm/Support/ErrorHandling.h
+++ b/include/llvm/Support/ErrorHandling.h
@@ -97,7 +97,7 @@ namespace llvm {
#define llvm_unreachable(msg) \
::llvm::llvm_unreachable_internal(msg, __FILE__, __LINE__)
#else
-#define llvm_unreachable(msg) ::llvm::llvm_unreachable_internal()
+#define llvm_unreachable(msg) LLVM_BUILTIN_UNREACHABLE
#endif
#endif