From 2dd22da965ffc1623421cb8163947d7e679ce187 Mon Sep 17 00:00:00 2001 From: Mikael Holmen Date: Mon, 12 Apr 2021 08:23:47 +0200 Subject: [PATCH] [libtooling][clang-tidy] Fix compiler warnings in testcase [NFC] Without the fix we get: 06:31:09 In file included from ../../clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp:3: 06:31:09 ../utils/unittest/googletest/include/gtest/gtest.h:1392:11: error: comparison of integers of different signs: 'const int' and 'const unsigned int' [-Werror,-Wsign-compare] 06:31:09 if (lhs == rhs) { 06:31:09 ~~~ ^ ~~~ 06:31:09 ../utils/unittest/googletest/include/gtest/gtest.h:1421:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ' requested here 06:31:09 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); 06:31:09 ^ 06:31:09 ../../clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp:60:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare' requested here 06:31:09 EXPECT_EQ(4, Errors[0].Message.FileOffset); 06:31:09 ^ 06:31:09 ../utils/unittest/googletest/include/gtest/gtest.h:1924:63: note: expanded from macro 'EXPECT_EQ' 06:31:09 EqHelper::Compare, \ 06:31:09 ^ 06:31:09 ../utils/unittest/googletest/include/gtest/gtest.h:1392:11: error: comparison of integers of different signs: 'const int' and 'const unsigned long' [-Werror,-Wsign-compare] 06:31:09 if (lhs == rhs) { 06:31:09 ~~~ ^ ~~~ 06:31:09 ../utils/unittest/googletest/include/gtest/gtest.h:1421:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ' requested here 06:31:09 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); 06:31:09 ^ 06:31:09 ../../clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp:64:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare' requested here 06:31:09 EXPECT_EQ(1, Errors[0].Message.Ranges.size()); 06:31:09 ^ 06:31:09 ../utils/unittest/googletest/include/gtest/gtest.h:1924:63: note: expanded from macro 'EXPECT_EQ' 06:31:09 EqHelper::Compare, \ 06:31:09 ^ 06:31:09 2 errors generated. --- .../unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp b/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp index 9760e3f..f1c5bd2 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp @@ -57,13 +57,13 @@ TEST(ClangTidyDiagnosticConsumer, HandlesSourceRangeHighlight) { // int abc; // ____^ // 01234 - EXPECT_EQ(4, Errors[0].Message.FileOffset); + EXPECT_EQ(4ul, Errors[0].Message.FileOffset); // int abc // ~~~~~~~ -> Length 7. (0-length highlights are nonsensical.) - EXPECT_EQ(1, Errors[0].Message.Ranges.size()); - EXPECT_EQ(0, Errors[0].Message.Ranges[0].FileOffset); - EXPECT_EQ(7, Errors[0].Message.Ranges[0].Length); + EXPECT_EQ(1ul, Errors[0].Message.Ranges.size()); + EXPECT_EQ(0ul, Errors[0].Message.Ranges[0].FileOffset); + EXPECT_EQ(7ul, Errors[0].Message.Ranges[0].Length); } } // namespace test -- 2.7.4