[clang] [clang][DependencyScanning] Track modules that resolve from sysroot. (PR #130634)
Ben Langmuir via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 14 12:50:51 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);
----------------
benlangmuir wrote:
Do you mean `starts_with`? That one looks like it has the same issue 😬 In fact I see in the `replace_path_prefix` documentation it claims the following behaviour
```
/oldfoo, /old, /new => /oldfoo
```
but the unit test for this function actually has an equivalent case and the behaviour is different `/oldnew/foo, /old, /new => /newnew/foo` specifically because `starts_with` is wrong.
https://github.com/llvm/llvm-project/pull/130634
More information about the cfe-commits
mailing list