[llvm] a2e7f26 - [llvm-profdata] Fix mixed-sign comparison warnings

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 15:21:14 PDT 2023


Author: Kazu Hirata
Date: 2023-06-23T15:21:07-07:00
New Revision: a2e7f26160359ed3913badb5acdd05aa8c663b46

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

LOG: [llvm-profdata] Fix mixed-sign comparison warnings

This patch fixes -Wsign-compare warnings from:

  llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:117:3: note:
  in instantiation of function template specialization
  'testing::internal::EqHelper::Compare<unsigned long, int, nullptr>'
  requested here

  llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:134:3: note:
  in instantiation of function template specialization
  'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>'
  requested here

  llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:144:3: note:
  in instantiation of function template specialization
  'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>'
  requested here

  llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp:160:3: note:
  in instantiation of function template specialization
  'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>'
  requested here

Added: 
    

Modified: 
    llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp b/llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp
index d7fe15a33702f..4ae57cd711c17 100644
--- a/llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp
+++ b/llvm/unittests/tools/llvm-profdata/MD5CollisionTest.cpp
@@ -114,7 +114,7 @@ TEST(MD5CollisionTest, TestCollision) {
   ASSERT_FALSE(Reader->read());
 
   std::vector<StringRef> &NameTable = *Reader->getNameTable();
-  ASSERT_EQ(NameTable.size(), 2);
+  ASSERT_EQ(NameTable.size(), 2U);
   StringRef S1 = NameTable[0];
   StringRef S2 = NameTable[1];
   ASSERT_NE(S1, S2);
@@ -131,7 +131,7 @@ TEST(MD5CollisionTest, TestCollision) {
   ExpectedFS.addBodySamples(9, 0, 0);
 
   SampleProfileMap &Profiles = Reader->getProfiles();
-  EXPECT_EQ(Profiles.size(), 1);
+  EXPECT_EQ(Profiles.size(), 1U);
   if (Profiles.size()) {
     auto &[Hash, FS] = *Profiles.begin();
     EXPECT_EQ(Hash, ExpectedHash);
@@ -141,7 +141,7 @@ TEST(MD5CollisionTest, TestCollision) {
   // Inserting S2 again should fail, returning the existing sample unchanged.
   auto [It1, Inserted1] = Profiles.try_emplace(S2, FunctionSamples());
   EXPECT_FALSE(Inserted1);
-  EXPECT_EQ(Profiles.size(), 1);
+  EXPECT_EQ(Profiles.size(), 1U);
   if (Profiles.size()) {
     auto &[Hash, FS] = *It1;
     EXPECT_EQ(Hash, ExpectedHash);
@@ -157,7 +157,7 @@ TEST(MD5CollisionTest, TestCollision) {
 
   auto [It2, Inserted2] = Profiles.try_emplace(S1, FS1);
   EXPECT_TRUE(Inserted2);
-  EXPECT_EQ(Profiles.size(), 1);
+  EXPECT_EQ(Profiles.size(), 1U);
   if (Profiles.size()) {
     auto &[Hash, FS] = *It2;
     EXPECT_EQ(Hash, ExpectedHash);


        


More information about the llvm-commits mailing list