mirror of
https://github.com/google/benchmark.git
synced 2025-02-26 19:30:12 +08:00
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.
This commit is contained in:
parent
11dc36822b
commit
2ec7399cf1
@ -108,14 +108,6 @@ namespace internal {
|
||||
|
||||
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 {
|
||||
public:
|
||||
ThreadManager(int num_threads)
|
||||
|
@ -67,15 +67,10 @@
|
||||
|
||||
#if defined(COMPILER_GCC) || __has_builtin(__builtin_unreachable)
|
||||
#define BENCHMARK_UNREACHABLE() __builtin_unreachable()
|
||||
#elif defined(COMPILER_MSVC)
|
||||
#define BENCHMARK_UNREACHABLE() __assume(false)
|
||||
#else
|
||||
#define BENCHMARK_HAS_NO_BUILTIN_UNREACHABLE
|
||||
namespace benchmark {
|
||||
namespace internal {
|
||||
BENCHMARK_NORETURN void UnreachableImp(const char* FName, int Line);
|
||||
}
|
||||
} // namespace benchmark
|
||||
#define BENCHMARK_UNREACHABLE() \
|
||||
::benchmark::internal::UnreachableImp(__FILE__, __LINE__)
|
||||
#define BENCHMARK_UNREACHABLE() ((void)0)
|
||||
#endif
|
||||
|
||||
#endif // BENCHMARK_INTERNAL_MACROS_H_
|
||||
|
Loading…
Reference in New Issue
Block a user