Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions googletest/include/gtest/internal/gtest-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
4 changes: 4 additions & 0 deletions googletest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down