Index: clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h =================================================================== --- clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h +++ clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h @@ -126,9 +126,9 @@ public: ModuleDepCollectorPP(ModuleDepCollector &MDC) : MDC(MDC) {} - void FileChanged(SourceLocation Loc, FileChangeReason Reason, - SrcMgr::CharacteristicKind FileType, - FileID PrevFID) override; + void LexedFileChanged(FileID FID, LexedFileChangeReason Reason, + SrcMgr::CharacteristicKind FileType, FileID PrevFID, + SourceLocation Loc) override; void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, CharSourceRange FilenameRange, Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp =================================================================== --- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp +++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp @@ -301,11 +301,12 @@ assert(Inserted && "duplicate module mapping"); } -void ModuleDepCollectorPP::FileChanged(SourceLocation Loc, - FileChangeReason Reason, - SrcMgr::CharacteristicKind FileType, - FileID PrevFID) { - if (Reason != PPCallbacks::EnterFile) +void ModuleDepCollectorPP::LexedFileChanged(FileID FID, + LexedFileChangeReason Reason, + SrcMgr::CharacteristicKind FileType, + FileID PrevFID, + SourceLocation Loc) { + if (Reason != LexedFileChangeReason::EnterFile) return; // This has to be delayed as the context hash can change at the start of @@ -320,8 +321,7 @@ // Dependency generation really does want to go all the way to the // file entry for a source location to find out what is depended on. // We do not want #line markers to affect dependency generation! - if (std::optional Filename = - SM.getNonBuiltinFilenameForID(SM.getFileID(SM.getExpansionLoc(Loc)))) + if (std::optional Filename = SM.getNonBuiltinFilenameForID(FID)) MDC.addFileDep(llvm::sys::path::remove_leading_dotslash(*Filename)); }