https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/139410
None >From 29d26619cb5ca1e2cdcc55cd1c43239835b831b5 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Sat, 10 May 2025 09:21:24 -0700 Subject: [PATCH] [clang-tools-extra] Use std::tie to implement operator< (NFC) --- clang-tools-extra/modularize/Modularize.cpp | 7 ++----- .../modularize/PreprocessorTracker.cpp | 15 ++------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp index 8609692945344..7f8a19280b111 100644 --- a/clang-tools-extra/modularize/Modularize.cpp +++ b/clang-tools-extra/modularize/Modularize.cpp @@ -406,11 +406,8 @@ struct Location { } friend bool operator<(const Location &X, const Location &Y) { - if (X.File != Y.File) - return X.File < Y.File; - if (X.Line != Y.Line) - return X.Line < Y.Line; - return X.Column < Y.Column; + return std::tie(X.File, X.Line, X.Column) < + std::tie(Y.File, Y.Line, Y.Column); } friend bool operator>(const Location &X, const Location &Y) { return Y < X; } friend bool operator<=(const Location &X, const Location &Y) { diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp b/clang-tools-extra/modularize/PreprocessorTracker.cpp index 0c030f1112204..336f570217933 100644 --- a/clang-tools-extra/modularize/PreprocessorTracker.cpp +++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp @@ -494,19 +494,8 @@ class PPItemKey { return Column == Other.Column; } bool operator<(const PPItemKey &Other) const { - if (Name < Other.Name) - return true; - else if (Name > Other.Name) - return false; - if (File < Other.File) - return true; - else if (File > Other.File) - return false; - if (Line < Other.Line) - return true; - else if (Line > Other.Line) - return false; - return Column < Other.Column; + return std::tie(Name, File, Line, Column) < + std::tie(Other.Name, Other.File, Other.Line, Other.Column); } StringHandle Name; HeaderHandle File; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits