Today I checked out lldb to check that r284364 wouldn't cause any
trouble, but there were a few warnings that fired when I tried to build
it, breaking my -Werror build.
The EXPECT and ASSERT macros in gtest don't do the usual arithmetic
conversions, so there are a number of warnings where we compare
differently sized ints. This fixes the places that warn to be more
specific. Okay to commit?
commit d64b335a2ffcf48f98c0267f890630ace2b454ea
Author: Justin Bogner
Date: Sun Oct 16 22:47:17 2016 -0700
unittests: Specify types in a bunch of unittest EXPECT's
The EXPECT and ASSERT macros in gtest don't do the usual arithmetic
conversions. Specify types in several of them to fix -Werror.
diff --git a/unittests/Core/ArchSpecTest.cpp b/unittests/Core/ArchSpecTest.cpp
index 03a0637..32b3636 100644
--- a/unittests/Core/ArchSpecTest.cpp
+++ b/unittests/Core/ArchSpecTest.cpp
@@ -21,26 +21,26 @@ TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleSimple) {
// Success conditions. Valid cpu/subtype combinations using both - and .
ArchSpec AS;
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10", AS));
- EXPECT_EQ(12, AS.GetMachOCPUType());
- EXPECT_EQ(10, AS.GetMachOCPUSubType());
+ EXPECT_EQ(12u, AS.GetMachOCPUType());
+ EXPECT_EQ(10u, AS.GetMachOCPUSubType());
AS = ArchSpec();
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15", AS));
- EXPECT_EQ(12, AS.GetMachOCPUType());
- EXPECT_EQ(15, AS.GetMachOCPUSubType());
+ EXPECT_EQ(12u, AS.GetMachOCPUType());
+ EXPECT_EQ(15u, AS.GetMachOCPUSubType());
AS = ArchSpec();
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12.15", AS));
- EXPECT_EQ(12, AS.GetMachOCPUType());
- EXPECT_EQ(15, AS.GetMachOCPUSubType());
+ EXPECT_EQ(12u, AS.GetMachOCPUType());
+ EXPECT_EQ(15u, AS.GetMachOCPUSubType());
// Failure conditions.
// Valid string, unknown cpu/subtype.
AS = ArchSpec();
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("13.11", AS));
- EXPECT_EQ(0, AS.GetMachOCPUType());
- EXPECT_EQ(0, AS.GetMachOCPUSubType());
+ EXPECT_EQ(0u, AS.GetMachOCPUType());
+ EXPECT_EQ(0u, AS.GetMachOCPUSubType());
// Missing / invalid cpu or subtype
AS = ArchSpec();
@@ -60,22 +60,22 @@ TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleSimple) {
TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleExtra) {
ArchSpec AS;
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15-vendor-os", AS));
- EXPECT_EQ(12, AS.GetMachOCPUType());
- EXPECT_EQ(15, AS.GetMachOCPUSubType());
+ EXPECT_EQ(12u, AS.GetMachOCPUType());
+ EXPECT_EQ(15u, AS.GetMachOCPUSubType());
EXPECT_EQ("vendor", AS.GetTriple().getVendorName());
EXPECT_EQ("os", AS.GetTriple().getOSName());
AS = ArchSpec();
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10-vendor-os-name", AS));
- EXPECT_EQ(12, AS.GetMachOCPUType());
- EXPECT_EQ(10, AS.GetMachOCPUSubType());
+ EXPECT_EQ(12u, AS.GetMachOCPUType());
+ EXPECT_EQ(10u, AS.GetMachOCPUSubType());
EXPECT_EQ("vendor", AS.GetTriple().getVendorName());
EXPECT_EQ("os", AS.GetTriple().getOSName());
AS = ArchSpec();
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-15-vendor.os-name", AS));
- EXPECT_EQ(12, AS.GetMachOCPUType());
- EXPECT_EQ(15, AS.GetMachOCPUSubType());
+ EXPECT_EQ(12u, AS.GetMachOCPUType());
+ EXPECT_EQ(15u, AS.GetMachOCPUSubType());
EXPECT_EQ("vendor.os", AS.GetTriple().getVendorName());
EXPECT_EQ("name", AS.GetTriple().getOSName());
@@ -83,8 +83,8 @@ TEST(ArchSpecTest, TestParseMachCPUDashSubtypeTripleExtra) {
// since they are unrecognized.
AS = ArchSpec();
EXPECT_TRUE(ParseMachCPUDashSubtypeTriple("12-10-vendor", AS));
- EXPECT_EQ(12, AS.GetMachOCPUType());
- EXPECT_EQ(10, AS.GetMachOCPUSubType());
+ EXPECT_EQ(12u, AS.GetMachOCPUType());
+ EXPECT_EQ(10u, AS.GetMachOCPUSubType());
EXPECT_EQ("apple", AS.GetTriple().getVendorName());
EXPECT_EQ("", AS.GetTriple().getOSName());
@@ -100,16 +100,16 @@ TEST(ArchSpecTest, TestSetTriple) {
// Various flavors of valid triples.
EXPECT_TRUE(AS.SetTriple("12-10-apple-darwin"));
- EXPECT_EQ(llvm::MachO::CPU_TYPE_ARM, AS.GetMachOCPUType());
- EXPECT_EQ(10, AS.GetMachOCPUSubType());
+ EXPECT_EQ(uint32_t(llvm::MachO::CPU_TYPE_ARM), AS.GetMachOCPUType());
+ EXPECT_EQ(10u, AS.GetMachOCPUSubType());
EXPECT_TRUE(llvm::StringRef(AS.GetTriple().str())
.consume_front("armv7f-apple-darwin"));
EXPECT_EQ(ArchSpec::eCore_arm_armv7f, AS.GetCore());
AS = ArchSpec();
EXPECT_TRUE(AS.SetTriple("18.100-apple-darwin"));
- EXPECT_EQ(llvm::MachO::CPU_TYPE_POWERPC, AS.GetMachOCPUType());
- EXPECT_EQ(100, AS.GetMachOCPUSubType());
+ EXPECT_EQ(uint32_t(llvm::MachO::CPU_TYPE_POWERPC), AS.GetMachOCPUType());
+ EXPECT_EQ(100u, AS.GetMachOCPUSubType());
EXPECT_TRUE(llvm::StringRef(AS.GetTriple().str())
.consume_front("powerpc-apple-darwin"));
EXPECT_EQ(ArchSpec::eCore_ppc_ppc970, AS.GetCore());
@@ -133,4 +133,4 @@ TEST(ArchSpecTest, TestSetTriple) {
AS = ArchSpec();
EXP