[clang-tools-extra] 9d99cf5 - [clang-tidy] Restore test parameter operator<< function (NFC)

via cfe-commits cfe-commits at lists.llvm.org
Sat May 14 13:05:13 PDT 2022


Author: Richard
Date: 2022-05-14T14:04:32-06:00
New Revision: 9d99cf59a151a715ebebf3a4c4782dfdb48d7f4b

URL: https://github.com/llvm/llvm-project/commit/9d99cf59a151a715ebebf3a4c4782dfdb48d7f4b
DIFF: https://github.com/llvm/llvm-project/commit/9d99cf59a151a715ebebf3a4c4782dfdb48d7f4b.diff

LOG: [clang-tidy] Restore test parameter operator<< function (NFC)

Clang erroneously flagged the function as "unused", but it is most
definitely used by gtest to pretty print the parameter value when
a test fails.

Make the pretty printing function a friend function in the parameter
class similar to other clang unit tests.

Added: 
    

Modified: 
    clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp b/clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp
index 65bf0691372cc..b772c0054de40 100644
--- a/clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp
@@ -48,6 +48,11 @@ namespace {
 struct Param {
   bool Matched;
   const char *Text;
+
+  friend std::ostream &operator<<(std::ostream &Str, const Param &Value) {
+    return Str << "Matched: " << std::boolalpha << Value.Matched << ", Text: '"
+               << Value.Text << "'";
+  }
 };
 
 class MatcherTest : public ::testing::TestWithParam<Param> {};


        


More information about the cfe-commits mailing list