[clang] Update GoogleTest to v1.14.0 (PR #65823)

Zero Omega via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 15:25:25 PDT 2023


zeroomega wrote:

I looked into the "unused functions" issue shown up in bots like: https://lab.llvm.org/buildbot/#/builders/57/builds/29853 .

The root cause is that GoogleTest changed the way it converts an arbitrary object into string. In the past, any object that cannot be printed to the string will eventually matched to function at https://github.com/llvm/llvm-project/blob/58d50b0cadafe118faf2e7d7bf738d2daa38bb73/third-party/unittest/googletest/include/gtest/gtest-printers.h#L264 . Then the call to the llvm_gtest::printable will use `OS << V.V;` to print the value to the stream, if the object overrides its `<<` operator, like https://github.com/llvm/llvm-project/blob/58d50b0cadafe118faf2e7d7bf738d2daa38bb73/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp#L457 , it will be used to convert the object to string. If not, a build error will happen. In GoogleTest v1.14.0, the object to string logic is re-written and for an arbitrary  object, it will eventually matched to `RawBytesPrinter` defined at https://github.com/llvm/llvm-project/blob/54c1a9b20d89e85cd60d002c77b34c00f36520f4/third-party/unittest/googletest/include/gtest/gtest-printers.h#L290 . Therefore, the `operator<<` override won't be used and a unused function warnig(error) will be thrown. 

So deleting these `llvm::raw_ostream &operator<<` functions won't cause any test failure but it will degrade the error message output since now the objects were printed as raw bytes. @bogner FYI.

https://github.com/llvm/llvm-project/pull/65823


More information about the cfe-commits mailing list