Skip to content

Commit

Permalink
Add patch file for gtest so it works with HIP compiler in C++20 mode
Browse files Browse the repository at this point in the history
See report here: google/googletest#3659
  • Loading branch information
crtrott committed Jan 27, 2023
1 parent fe6df2a commit ab31507
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions scripts/snl/gtest-hip-patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 7d7e77c1..025ed642 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -473,7 +473,7 @@ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
inline void PrintTo(char16_t c, ::std::ostream* os) {
PrintTo(ImplicitCast_<char32_t>(c), os);
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
inline void PrintTo(char8_t c, ::std::ostream* os) {
PrintTo(ImplicitCast_<char32_t>(c), os);
}
@@ -586,7 +586,7 @@ inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
inline void PrintTo(unsigned char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const void*>(s), os);
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// Overloads for u8 strings.
GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os);
inline void PrintTo(char8_t* s, ::std::ostream* os) {
@@ -906,7 +906,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
GTEST_API_ void UniversalPrintArray(const char* begin, size_t len,
::std::ostream* os);

-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// This overload prints a (const) char8_t array compactly.
GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,
::std::ostream* os);
@@ -1002,7 +1002,7 @@ template <>
class UniversalTersePrinter<char*> : public UniversalTersePrinter<const char*> {
};

-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
template <>
class UniversalTersePrinter<const char8_t*> {
public:
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index b4fa3f07..594a038c 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -1939,7 +1939,7 @@ inline bool IsUpper(char ch) {
inline bool IsXDigit(char ch) {
return isxdigit(static_cast<unsigned char>(ch)) != 0;
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
inline bool IsXDigit(char8_t ch) {
return isxdigit(static_cast<unsigned char>(ch)) != 0;
}
diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc
index d475ad36..7ccd181d 100644
--- a/googletest/src/gtest-printers.cc
+++ b/googletest/src/gtest-printers.cc
@@ -214,7 +214,7 @@ static const char* GetCharWidthPrefix(signed char) { return ""; }

static const char* GetCharWidthPrefix(unsigned char) { return ""; }

-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
static const char* GetCharWidthPrefix(char8_t) { return "u8"; }
#endif

@@ -230,7 +230,7 @@ static CharFormat PrintAsStringLiteralTo(char c, ostream* os) {
return PrintAsStringLiteralTo(ToChar32(c), os);
}

-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
static CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) {
return PrintAsStringLiteralTo(ToChar32(c), os);
}
@@ -393,7 +393,7 @@ void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
UniversalPrintCharArray(begin, len, os);
}

-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// Prints a (const) char8_t array of 'len' elements, starting at address
// 'begin'.
void UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) {
@@ -436,7 +436,7 @@ void PrintCStringTo(const Char* s, ostream* os) {

void PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); }

-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
void PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); }
#endif

@@ -528,7 +528,7 @@ void PrintStringTo(const ::std::string& s, ostream* os) {
}
}

-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
void PrintU8StringTo(const ::std::u8string& s, ostream* os) {
PrintCharsAsStringTo(s.data(), s.size(), os);
}

0 comments on commit ab31507

Please sign in to comment.