llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Tulio Magno Quites Machado Filho (tuliom)

<details>
<summary>Changes</summary>

This code was initially written in commit
7ff29148ac7883881e62dc9e1714057c68ad4436 with the intention of sorting headers 
according to their path. At the time, the path was saved in field NameAsWritten 
of Module::Header.

Later, commit e6830b6028ec5434ccf8dbebdd992918f67b1751 added field 
PathRelativeToRootModuleDirectory to Module::Header and modified 
ModuleMapParser::parseUmbrellaDirDecl() so that it started to save the header 
path in the new field and started setting NameAsWritten = "". It didn't modify 
compareModuleHeaders() in order to adapt it to the new field.

After this commit, the sorting stopped working because it continued comparing 
only NameAsWritten.

This commit fixes it by treating NameAsWritten and 
PathRelativeToRootModuleDirectory as a tuple when comparing Module::Header.

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


1 Files Affected:

- (modified) clang/lib/Lex/ModuleMap.cpp (+3-1) 


``````````diff
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 1d67e275cb4775a..7bc89b2fed36bf2 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -49,6 +49,7 @@
 #include <optional>
 #include <string>
 #include <system_error>
+#include <tuple>
 #include <utility>
 
 using namespace clang;
@@ -2511,7 +2512,8 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind 
LeadingToken,
 
 static bool compareModuleHeaders(const Module::Header &A,
                                  const Module::Header &B) {
-  return A.NameAsWritten < B.NameAsWritten;
+  return std::tie(A.NameAsWritten, A.PathRelativeToRootModuleDirectory) <
+         std::tie(B.NameAsWritten, B.PathRelativeToRootModuleDirectory);
 }
 
 /// Parse an umbrella directory declaration.

``````````

</details>


https://github.com/llvm/llvm-project/pull/73323
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to