[clang][modules][deps] Preserve module map load order
authorJan Svoboda <jan_svoboda@apple.com>
Thu, 22 Sep 2022 19:36:25 +0000 (12:36 -0700)
committerJan Svoboda <jan_svoboda@apple.com>
Thu, 22 Sep 2022 19:54:51 +0000 (12:54 -0700)
commit20fa87c7e87fcb2fca403c7a73f8acc7e4dd5fa1
treee4754cde4bb59668539b958d7b528876e889b8c2
parenta212d8da94d08e229aa8d65283e4b116310bba10
[clang][modules][deps] Preserve module map load order

In `ASTWriter`, input files are sorted based on whether they are system or user. The current implementation used single `std::queue` with `push_back` and `push_front`. This resulted in the user files being reversed.

This patch fixes that by keeping the system/user distinction, but otherwise serializing files in the order they were loaded by the `SourceManager`. This is then used in the dependency scanner to report module map dependencies in the correct order.

Depends on D134224.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D134248
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/modules-module-map-order.m [new file with mode: 0644]
clang/test/Index/Core/index-with-module.m
clang/test/Modules/module-file-home-is-cwd.m
clang/test/Modules/module_file_info.m