[PATCH] D72632: [unittests] Fix "comparison of integers of different signs" warnings

Miloš Stojanović via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 10:26:18 PST 2020


mstojanovic created this revision.
mstojanovic added reviewers: lhames, labath, petarj.
Herald added a project: LLVM.

A warning is sent because `std::distance()` returns a signed type so `CmpHelperEQ()` gets instantiated into a function that compares differently signed arguments.


https://reviews.llvm.org/D72632

Files:
  llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
  llvm/unittests/Object/MinidumpTest.cpp


Index: llvm/unittests/Object/MinidumpTest.cpp
===================================================================
--- llvm/unittests/Object/MinidumpTest.cpp
+++ llvm/unittests/Object/MinidumpTest.cpp
@@ -589,7 +589,7 @@
     const MinidumpFile &File = **ExpectedFile;
     auto ExpectedInfo = File.getMemoryInfoList();
     ASSERT_THAT_EXPECTED(ExpectedInfo, Succeeded());
-    ASSERT_EQ(1u, std::distance(ExpectedInfo->begin(), ExpectedInfo->end()));
+    ASSERT_EQ(1, std::distance(ExpectedInfo->begin(), ExpectedInfo->end()));
     const MemoryInfo &Info = *ExpectedInfo.get().begin();
     EXPECT_EQ(0x0706050403020100u, Info.BaseAddress);
     EXPECT_EQ(0x0504030201000908u, Info.AllocationBase);
Index: llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
===================================================================
--- llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
+++ llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
@@ -56,17 +56,17 @@
                                 false, false);
 
   // Check that iteration of blocks within a section behaves as expected.
-  EXPECT_EQ(std::distance(Sec1.blocks().begin(), Sec1.blocks().end()), 2U);
+  EXPECT_EQ(std::distance(Sec1.blocks().begin(), Sec1.blocks().end()), 2);
   EXPECT_TRUE(llvm::count(Sec1.blocks(), &B1));
   EXPECT_TRUE(llvm::count(Sec1.blocks(), &B2));
 
   // Check that iteration of symbols within a section behaves as expected.
-  EXPECT_EQ(std::distance(Sec1.symbols().begin(), Sec1.symbols().end()), 2U);
+  EXPECT_EQ(std::distance(Sec1.symbols().begin(), Sec1.symbols().end()), 2);
   EXPECT_TRUE(llvm::count(Sec1.symbols(), &S1));
   EXPECT_TRUE(llvm::count(Sec1.symbols(), &S2));
 
   // Check that iteration of blocks across sections behaves as expected.
-  EXPECT_EQ(std::distance(G.blocks().begin(), G.blocks().end()), 4U);
+  EXPECT_EQ(std::distance(G.blocks().begin(), G.blocks().end()), 4);
   EXPECT_TRUE(llvm::count(G.blocks(), &B1));
   EXPECT_TRUE(llvm::count(G.blocks(), &B2));
   EXPECT_TRUE(llvm::count(G.blocks(), &B3));
@@ -75,8 +75,7 @@
   // Check that iteration of defined symbols across sections behaves as
   // expected.
   EXPECT_EQ(
-      std::distance(G.defined_symbols().begin(), G.defined_symbols().end()),
-      4U);
+      std::distance(G.defined_symbols().begin(), G.defined_symbols().end()), 4);
   EXPECT_TRUE(llvm::count(G.defined_symbols(), &S1));
   EXPECT_TRUE(llvm::count(G.defined_symbols(), &S2));
   EXPECT_TRUE(llvm::count(G.defined_symbols(), &S3));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72632.237723.patch
Type: text/x-patch
Size: 2503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200113/fdf2e5db/attachment.bin>


More information about the llvm-commits mailing list