aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 6168057..dc361b2 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -364,6 +364,7 @@ static std::error_code collectModuleHeaderIncludes(
llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
llvm::vfs::FileSystem &FS = FileMgr.getVirtualFileSystem();
+ SmallVector<std::pair<std::string, const FileEntry *>, 8> Headers;
for (llvm::vfs::recursive_directory_iterator Dir(FS, DirNative, EC), End;
Dir != End && !EC; Dir.increment(EC)) {
// Check whether this entry has an extension typically associated with
@@ -394,13 +395,25 @@ static std::error_code collectModuleHeaderIncludes(
++It)
llvm::sys::path::append(RelativeHeader, *It);
- // Include this header as part of the umbrella directory.
- Module->addTopHeader(*Header);
- addHeaderInclude(RelativeHeader, Includes, LangOpts, Module->IsExternC);
+ std::string RelName = RelativeHeader.c_str();
+ Headers.push_back(std::make_pair(RelName, *Header));
}
if (EC)
return EC;
+
+ // Sort header paths and make the header inclusion order deterministic
+ // across different OSs and filesystems.
+ llvm::sort(Headers.begin(), Headers.end(), [](
+ const std::pair<std::string, const FileEntry *> &LHS,
+ const std::pair<std::string, const FileEntry *> &RHS) {
+ return LHS.first < RHS.first;
+ });
+ for (auto &H : Headers) {
+ // Include this header as part of the umbrella directory.
+ Module->addTopHeader(H.second);
+ addHeaderInclude(H.first, Includes, LangOpts, Module->IsExternC);
+ }
}
// Recurse into submodules.