[clang] [Dependency Scanning] Teach `DependencyScanningTool::getModuleDependencies` to Process a List of Module Names (PR #129915)
Cyndy Ishida via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 5 12:39:30 PST 2025
================
@@ -1213,11 +1213,17 @@ void GetDependenciesByModuleNameAction::ExecuteAction() {
Preprocessor &PP = CI.getPreprocessor();
SourceManager &SM = PP.getSourceManager();
FileID MainFileID = SM.getMainFileID();
- SourceLocation FileStart = SM.getLocForStartOfFile(MainFileID);
- SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path;
- IdentifierInfo *ModuleID = PP.getIdentifierInfo(ModuleName);
- Path.push_back(std::make_pair(ModuleID, FileStart));
- auto ModResult = CI.loadModule(FileStart, Path, Module::Hidden, false);
- PPCallbacks *CB = PP.getPPCallbacks();
- CB->moduleImport(SourceLocation(), Path, ModResult);
+ SourceLocation SLoc = SM.getLocForStartOfFile(MainFileID);
+ for (auto ModuleName : ModuleNames) {
+ SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path;
+ IdentifierInfo *ModuleID = PP.getIdentifierInfo(ModuleName);
+ Path.push_back(std::make_pair(ModuleID, SLoc));
+ auto ModResult = CI.loadModule(SLoc, Path, Module::Hidden, false);
+ PPCallbacks *CB = PP.getPPCallbacks();
+ CB->moduleImport(SourceLocation(), Path, ModResult);
+ // FIXME: how do you know that this offset is correct?
+ SLoc = SLoc.getLocWithOffset(1);
----------------
cyndyishida wrote:
I used it as an incrementer as we need to allocate one source location for each module to import.
IIRC I found this pattern used in different parts of the codebase.
https://github.com/llvm/llvm-project/pull/129915
More information about the cfe-commits
mailing list