[PATCH] D143613: [clang][deps] Migrate ModuleDepCollector to LexedFileChanged NFCI
Ben Langmuir via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 8 15:39:42 PST 2023
benlangmuir created this revision.
benlangmuir added reviewers: akyrtzi, jansvoboda11.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
LexedFileChanged has the semantics we want of ignoring #line/etc. It's also consistent with other dep collectors like DependencyFileGenerator.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143613
Files:
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
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<StringRef> Filename =
- SM.getNonBuiltinFilenameForID(SM.getFileID(SM.getExpansionLoc(Loc))))
+ if (std::optional<StringRef> Filename = SM.getNonBuiltinFilenameForID(FID))
MDC.addFileDep(llvm::sys::path::remove_leading_dotslash(*Filename));
}
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143613.495973.patch
Type: text/x-patch
Size: 2583 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230208/995f4959/attachment.bin>
More information about the cfe-commits
mailing list