aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2021-09-08 22:24:07 -0700
committerAkira Hatanaka <ahatanaka@apple.com>2021-09-09 08:52:50 -0700
commit17c2948d04431e94376e8d7883b5d89fbe705b5e (patch)
treecce1b7975d45ee38e09eac244881657a2842c2d1 /clang/lib/Frontend/FrontendActions.cpp
parent92c9ff6d5fc9c8af577922d426f6b65a661bf5dd (diff)
downloadllvm-17c2948d04431e94376e8d7883b5d89fbe705b5e.zip
llvm-17c2948d04431e94376e8d7883b5d89fbe705b5e.tar.gz
llvm-17c2948d04431e94376e8d7883b5d89fbe705b5e.tar.bz2
[clang-scan-deps] Add an API for clang dependency scanner to perform
module lookup by name alone This removes the need to create a fake source file that imports a module. rdar://64538073 Differential Revision: https://reviews.llvm.org/D109485
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index c6ebbdc..b5544af 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -993,3 +993,17 @@ void PrintDependencyDirectivesSourceMinimizerAction::ExecuteAction() {
}
llvm::outs() << Output;
}
+
+void GetDependenciesByModuleNameAction::ExecuteAction() {
+ CompilerInstance &CI = getCompilerInstance();
+ 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);
+}