Author: Kazu Hirata
Date: 2025-05-10T20:01:28-07:00
New Revision: 066bc49f764cb24c8847d83a059684e3b6d7f4da

URL: 
https://github.com/llvm/llvm-project/commit/066bc49f764cb24c8847d83a059684e3b6d7f4da
DIFF: 
https://github.com/llvm/llvm-project/commit/066bc49f764cb24c8847d83a059684e3b6d7f4da.diff

LOG: [modularize] Use std::tie to implement operator< (NFC) (#139410)

Added: 
    

Modified: 
    clang-tools-extra/modularize/Modularize.cpp
    clang-tools-extra/modularize/PreprocessorTracker.cpp

Removed: 
    


################################################################################
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

Reply via email to