From 590c5f97fb46862cdbd51cf02ec3b4ace13ddab1 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Thu, 7 May 2020 06:56:10 -0400 Subject: [PATCH] Expand comparison check to more operators This doesn't actually catch any more real cases in the current code, but it future-proofs while I'm thinking about such things. --- src/cata_variant.h | 6 +++--- tools/clang-tidy-plugin/UseLocalizedSortingCheck.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cata_variant.h b/src/cata_variant.h index 58d7878b07e9b..c46d5da77848b 100644 --- a/src/cata_variant.h +++ b/src/cata_variant.h @@ -325,9 +325,9 @@ class cata_variant CATA_VARIANT_OPERATOR( == ); CATA_VARIANT_OPERATOR( != ); CATA_VARIANT_OPERATOR( < ); // NOLINT( cata-use-localized-sorting ) - CATA_VARIANT_OPERATOR( <= ); - CATA_VARIANT_OPERATOR( > ); - CATA_VARIANT_OPERATOR( >= ); + CATA_VARIANT_OPERATOR( <= ); // NOLINT( cata-use-localized-sorting ) + CATA_VARIANT_OPERATOR( > ); // NOLINT( cata-use-localized-sorting ) + CATA_VARIANT_OPERATOR( >= ); // NOLINT( cata-use-localized-sorting ) #undef CATA_VARIANT_OPERATOR private: explicit cata_variant( cata_variant_type t, std::string &&v ) diff --git a/tools/clang-tidy-plugin/UseLocalizedSortingCheck.cpp b/tools/clang-tidy-plugin/UseLocalizedSortingCheck.cpp index 1bdaff7b534d8..09ad8dda5642b 100644 --- a/tools/clang-tidy-plugin/UseLocalizedSortingCheck.cpp +++ b/tools/clang-tidy-plugin/UseLocalizedSortingCheck.cpp @@ -91,7 +91,12 @@ void UseLocalizedSortingCheck::registerMatchers( MatchFinder *Finder ) 0, expr( hasType( qualType().bind( "arg0Type" ) ) ).bind( "arg0Expr" ) ), - hasOverloadedOperatorName( "<" ) + anyOf( + hasOverloadedOperatorName( "<" ), + hasOverloadedOperatorName( ">" ), + hasOverloadedOperatorName( "<=" ), + hasOverloadedOperatorName( ">=" ) + ) ).bind( "opCall" ), this );