Commit 2ec7399c by Eric Fiselier

Improve BENCHMARK_UNREACHABLE() implementation.

This patch primarily changes the BENCHMARK_UNREACHABLE() implementation under MSVC to use __assume(false) instead of being a NORETURN function, which ironically caused unreachable code warnings. Second, since the NOTHROW function attempt generated the warnings we meant to avoid, it has been replaced with a dummy null statement.
parent 11dc3682
...@@ -108,14 +108,6 @@ namespace internal { ...@@ -108,14 +108,6 @@ namespace internal {
void UseCharPointer(char const volatile*) {} void UseCharPointer(char const volatile*) {}
#ifdef BENCHMARK_HAS_NO_BUILTIN_UNREACHABLE
BENCHMARK_NORETURN void UnreachableImp(const char* FName, int Line) {
std::cerr << FName << ":" << Line << " executing unreachable code!"
<< std::endl;
std::abort();
}
#endif
class ThreadManager { class ThreadManager {
public: public:
ThreadManager(int num_threads) ThreadManager(int num_threads)
......
...@@ -67,15 +67,10 @@ ...@@ -67,15 +67,10 @@
#if defined(COMPILER_GCC) || __has_builtin(__builtin_unreachable) #if defined(COMPILER_GCC) || __has_builtin(__builtin_unreachable)
#define BENCHMARK_UNREACHABLE() __builtin_unreachable() #define BENCHMARK_UNREACHABLE() __builtin_unreachable()
#elif defined(COMPILER_MSVC)
#define BENCHMARK_UNREACHABLE() __assume(false)
#else #else
#define BENCHMARK_HAS_NO_BUILTIN_UNREACHABLE #define BENCHMARK_UNREACHABLE() ((void)0)
namespace benchmark {
namespace internal {
BENCHMARK_NORETURN void UnreachableImp(const char* FName, int Line);
}
} // namespace benchmark
#define BENCHMARK_UNREACHABLE() \
::benchmark::internal::UnreachableImp(__FILE__, __LINE__)
#endif #endif
#endif // BENCHMARK_INTERNAL_MACROS_H_ #endif // BENCHMARK_INTERNAL_MACROS_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment