forked from OSchip/llvm-project
Speculatively adjust gtest's UnitTest::AddTestPartResult() to not rely on volatile store to null trapping
This fallback path is used at least on PPC. If this doesn't work on some compilers that take this path, then this will have to be changed to either abort, or partitioned to do different things based on the compiler. Please refer to https://reviews.llvm.org/D105338.
This commit is contained in:
parent
2df37d5ddd
commit
aa9f58cc2c
|
@ -4813,10 +4813,9 @@ void UnitTest::AddTestPartResult(
|
|||
// with clang/gcc we can achieve the same effect on x86 by invoking int3
|
||||
asm("int3");
|
||||
#else
|
||||
// Dereference nullptr through a volatile pointer to prevent the compiler
|
||||
// from removing. We use this rather than abort() or __builtin_trap() for
|
||||
// portability: some debuggers don't correctly trap abort().
|
||||
*static_cast<volatile int*>(nullptr) = 1;
|
||||
// While some debuggers don't correctly trap abort(), we can't perform
|
||||
// volatile store to null since it will be removed by clang and not trap.
|
||||
__builtin_trap();
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
} else if (GTEST_FLAG(throw_on_failure)) {
|
||||
#if GTEST_HAS_EXCEPTIONS
|
||||
|
|
Loading…
Reference in New Issue