[clang] [clang][DependencyScanning] Track modules that resolve from sysroot. (PR #130634)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 14 14:14:20 PDT 2025


================
@@ -739,6 +748,12 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
   MDC.ScanInstance.getASTReader()->visitInputFileInfos(
       *MF, /*IncludeSystem=*/true,
       [&](const serialization::InputFileInfo &IFI, bool IsSystem) {
+        if (MD.IsInSysroot) {
+          auto FullFilePath = ASTReader::ResolveImportedPath(
+              PathBuf, IFI.UnresolvedImportedFilename, MF->BaseDirectory);
+          MD.IsInSysroot = FullFilePath->starts_with(CurrSysroot);
----------------
cyndyishida wrote:

There's also a swift version that attempts to do the same. https://github.com/swiftlang/swift/blob/b4a2908fb5d7ae5b19d1f4a7f0ec9636f7c729c9/lib/Basic/StringExtras.cpp#L1459
It isolates & moves forward by separator, so I can try to apply this here (and double check it resolves the examples you point out).

https://github.com/llvm/llvm-project/pull/130634


More information about the cfe-commits mailing list