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
|
// with clang/gcc we can achieve the same effect on x86 by invoking int3
|
||||||
asm("int3");
|
asm("int3");
|
||||||
#else
|
#else
|
||||||
// Dereference nullptr through a volatile pointer to prevent the compiler
|
// While some debuggers don't correctly trap abort(), we can't perform
|
||||||
// from removing. We use this rather than abort() or __builtin_trap() for
|
// volatile store to null since it will be removed by clang and not trap.
|
||||||
// portability: some debuggers don't correctly trap abort().
|
__builtin_trap();
|
||||||
*static_cast<volatile int*>(nullptr) = 1;
|
|
||||||
#endif // GTEST_OS_WINDOWS
|
#endif // GTEST_OS_WINDOWS
|
||||||
} else if (GTEST_FLAG(throw_on_failure)) {
|
} else if (GTEST_FLAG(throw_on_failure)) {
|
||||||
#if GTEST_HAS_EXCEPTIONS
|
#if GTEST_HAS_EXCEPTIONS
|
||||||
|
|
Loading…
Reference in New Issue