From f2d71f0be2ff2230789cfaf37d4c4f38db5b1c7c Mon Sep 17 00:00:00 2001 From: Melroy van den Berg Date: Tue, 25 Jan 2022 22:45:24 +0100 Subject: [PATCH 1/2] Let me give a change to try it again - updating to latest version --- googletest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/README.md b/googletest/README.md index 83ae6cf5..d26b309e 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -94,7 +94,7 @@ include(FetchContent) FetchContent_Declare( googletest # Specify the commit you depend on and update it regularly. - URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip + URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) From 25ad42aabeaba6227f37795cdd2752e128e83827 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 1 Feb 2022 10:44:30 -0800 Subject: [PATCH 2/2] GetCurrentOsStackTraceExceptTop (both the method of UnitTestImpl and the wrapper function in gtest.cc) rely on the fact that the inner call is not getting optimized. This CL annotates them with the appropriate attributes. PiperOrigin-RevId: 425663217 Change-Id: Ib9ec2a69a7dd98d37640b56d4d7798572da66669 --- googletest/include/gtest/internal/gtest-port.h | 14 ++++++++++++++ googletest/src/gtest-internal-inl.h | 3 ++- googletest/src/gtest.cc | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 945b6ec0..929b7090 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -789,6 +789,20 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; # define GTEST_NO_INLINE_ #endif +#if defined(__clang__) +// Nested ifs to avoid triggering MSVC warning. +#if __has_attribute(disable_tail_calls) +// Ask the compiler not to perform tail call optimization inside +// the marked function. +#define GTEST_NO_TAIL_CALL_ __attribute__((disable_tail_calls)) +#endif +#elif __GNUC__ +#define GTEST_NO_TAIL_CALL_ \ + __attribute__((optimize("no-optimize-sibling-calls"))) +#else +#define GTEST_NO_TAIL_CALL_ +#endif + // _LIBCPP_VERSION is defined by the libc++ library from the LLVM project. #if !defined(GTEST_HAS_CXXABI_H_) # if defined(__GLIBCXX__) || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 62b5b10a..3f5551d1 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -623,7 +623,8 @@ class GTEST_API_ UnitTestImpl { // For example, if Foo() calls Bar(), which in turn calls // CurrentOsStackTraceExceptTop(1), Foo() will be included in the // trace but Bar() and CurrentOsStackTraceExceptTop() won't. - std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_; + std::string CurrentOsStackTraceExceptTop(int skip_count) + GTEST_NO_INLINE_ GTEST_NO_TAIL_CALL_; // Finds and returns a TestSuite with the given name. If one doesn't // exist, creates one and returns it. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 04266dca..46c3e7f7 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -6292,8 +6292,8 @@ void UnitTestImpl::UnshuffleTests() { // For example, if Foo() calls Bar(), which in turn calls // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. -std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/, - int skip_count) { +GTEST_NO_INLINE_ GTEST_NO_TAIL_CALL_ std::string +GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/, int skip_count) { // We pass skip_count + 1 to skip this wrapper function in addition // to what the user really wants to skip. return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);