[compiler-rt] r291042 - fix warning about noreturn in sanitizer_win's internal__exit()

Bob Haarman via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 4 16:37:13 PST 2017


Author: inglorion
Date: Wed Jan  4 18:37:13 2017
New Revision: 291042

URL: http://llvm.org/viewvc/llvm-project?rev=291042&view=rev
Log:
fix warning about noreturn in sanitizer_win's internal__exit()

Summary:
A previous fix used __assume(0), but not all compilers know that control will
not pass that. This patch uses a macro which works in more compilers.

Reviewers: rnk

Subscribers: kubabrecka

Differential Revision: https://reviews.llvm.org/D28268

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=291042&r1=291041&r2=291042&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Wed Jan  4 18:37:13 2017
@@ -31,6 +31,20 @@
 #include "sanitizer_stacktrace.h"
 #include "sanitizer_symbolizer.h"
 
+// A macro to tell the compiler that this part of the code cannot be reached,
+// if the compiler supports this feature. Since we're using this in
+// code that is called when terminating the process, the expansion of the
+// macro should not terminate the process to avoid infinite recursion.
+#if defined(__clang__)
+# define BUILTIN_UNREACHABLE() __builtin_unreachable()
+#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+# define BUILTIN_UNREACHABLE() __builtin_unreachable()
+#elif defined(_MSC_VER)
+# define BUILTIN_UNREACHABLE() __assume(0)
+#else
+# define BUILTIN_UNREACHABLE()
+#endif
+
 namespace __sanitizer {
 
 #include "sanitizer_syscall_generic.inc"
@@ -659,7 +673,7 @@ void internal__exit(int exitcode) {
   if (::IsDebuggerPresent())
     __debugbreak();
   TerminateProcess(GetCurrentProcess(), exitcode);
-  __assume(0);
+  BUILTIN_UNREACHABLE();
 }
 
 uptr internal_ftruncate(fd_t fd, uptr size) {




More information about the llvm-commits mailing list