Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

std::tie clearly expresses the intent while slightly shortening the
code.

std::tie clearly expresses the intent while slightly shortening the
code.
@llvmbot
Copy link
Member

llvmbot commented Jun 28, 2025

@llvm/pr-subscribers-clang-tools-extra

Author: Kazu Hirata (kazutakahirata)

Changes

std::tie clearly expresses the intent while slightly shortening the
code.


Full diff: https://github.com/llvm/llvm-project/pull/146220.diff

1 Files Affected:

  • (modified) clang-tools-extra/modularize/Modularize.cpp (+1-1)
diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp
index 2a90c5e3f6782..1da531a4aefa4 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -459,7 +459,7 @@ struct HeaderEntry {
     return !(X == Y);
   }
   friend bool operator<(const HeaderEntry &X, const HeaderEntry &Y) {
-    return X.Loc < Y.Loc || (X.Loc == Y.Loc && X.Name < Y.Name);
+    return std::tie(X.Loc, X.Name) < std::tie(Y.Loc, Y.Name);
   }
   friend bool operator>(const HeaderEntry &X, const HeaderEntry &Y) {
     return Y < X;

@kazutakahirata kazutakahirata merged commit 402baea into llvm:main Jun 28, 2025
9 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250628_operator_less_modularize branch June 28, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants