summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-02-01 18:44:30 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-02-01 18:44:59 (GMT)
commit25ad42aabeaba6227f37795cdd2752e128e83827 (patch)
tree56bc9b13ac10a11a2f933ed74eaca6d34676983d /googletest/include/gtest/internal
parent4517697675fc0d51c89aca61af5c77c4f1e4ee2d (diff)
downloadgoogletest-25ad42aabeaba6227f37795cdd2752e128e83827.zip
googletest-25ad42aabeaba6227f37795cdd2752e128e83827.tar.gz
googletest-25ad42aabeaba6227f37795cdd2752e128e83827.tar.bz2
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
Diffstat (limited to 'googletest/include/gtest/internal')
-rw-r--r--googletest/include/gtest/internal/gtest-port.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 945b6ec..929b709 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))