aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2024-08-29 16:06:03 +0800
committerGitHub <noreply@github.com>2024-08-29 16:06:03 +0800
commit2eeeff842f993a694159183a2834b4d305549cad (patch)
tree0c6d8ece51bf2b3506e3c042d9f0a791a5765251 /clang/lib/Frontend/FrontendActions.cpp
parente5b55e606796bac0e28e2f0fdc6fb39a419f6b15 (diff)
downloadllvm-2eeeff842f993a694159183a2834b4d305549cad.zip
llvm-2eeeff842f993a694159183a2834b4d305549cad.tar.gz
llvm-2eeeff842f993a694159183a2834b4d305549cad.tar.bz2
[C++20] [Modules] Embed all source files for C++20 Modules (#102444)
Close https://github.com/llvm/llvm-project/issues/72383 The implementation rationale is, I don't want to pass `-fmodules-embed-all-files` all the time since we can't test it in lit tests (we're using `clang_cc1`). So I tried to set it in FrontendActions for modules.
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 9f5d09e..8c7b749 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -262,11 +262,20 @@ GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
/*ForceUseTemporary=*/true);
}
-bool GenerateModuleInterfaceAction::BeginSourceFileAction(
- CompilerInstance &CI) {
+bool clang::BeginInvocationForModules(CompilerInstance &CI) {
+ // Embed all module files for named modules.
+ // See https://github.com/llvm/llvm-project/issues/72383 for discussion.
+ CI.getFrontendOpts().ModulesEmbedAllFiles = true;
CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleInterface);
+ return true;
+}
- return GenerateModuleAction::BeginSourceFileAction(CI);
+bool GenerateModuleInterfaceAction::BeginInvocation(
+ CompilerInstance &CI) {
+ if (!BeginInvocationForModules(CI))
+ return false;
+
+ return GenerateModuleAction::BeginInvocation(CI);
}
std::unique_ptr<ASTConsumer>