diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index fc65b1f2bd..0f807d8729 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -712,8 +712,15 @@ GTEST_API_ std::string GetCurrentOsStackTraceExceptTop( // Helpers for suppressing warnings on unreachable code or constant // condition. +// Always returns true. +#ifdef __clang_analyzer__ +// For Clang static analyzer we define this inline so Clang knows it +// always returns true. +GTEST_API_ bool AlwaysTrue() { return true; } +#else // Always returns true. GTEST_API_ bool AlwaysTrue(); +#endif // Always returns false. inline bool AlwaysFalse() { return !AlwaysTrue(); } diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index ce6c07fac8..ba679a07eb 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5403,6 +5403,9 @@ class ClassUniqueToAlwaysTrue {}; bool IsTrue(bool condition) { return condition; } +// For Clang static analyzer we define this inline so Clang knows it +// always returns true - see gtest-internal.h +#ifndef __clang_analyzer__ bool AlwaysTrue() { #if GTEST_HAS_EXCEPTIONS // This condition is always false so AlwaysTrue() never actually throws, @@ -5412,6 +5415,7 @@ bool AlwaysTrue() { #endif // GTEST_HAS_EXCEPTIONS return true; } +#endif // If *pstr starts with the given prefix, modifies *pstr to be right // past the prefix and returns true; otherwise leaves *pstr unchanged