aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2024-03-29 11:20:55 -0700
committerGitHub <noreply@github.com>2024-03-29 11:20:55 -0700
commit407a2f231a81862e20d80059870c48d818b61ec2 (patch)
tree154fa4bc1c57f7884a8b55c66f3d1f39968e8763 /clang/lib/Frontend/FrontendActions.cpp
parent99379522d00d0720bcda5067d4de2bfb0c279f15 (diff)
downloadllvm-407a2f231a81862e20d80059870c48d818b61ec2.zip
llvm-407a2f231a81862e20d80059870c48d818b61ec2.tar.gz
llvm-407a2f231a81862e20d80059870c48d818b61ec2.tar.bz2
[clang] Move state out of `PreprocessorOptions` (1/n) (#86358)
An instance of `PreprocessorOptions` is part of `CompilerInvocation` which is supposed to be a value type. The `DependencyDirectivesForFile` member is problematic, since it holds an owning reference of the scanning VFS. This makes it not a true value type, and it can keep potentially large chunk of memory (the local cache in the scanning VFS) alive for longer than clients might expect. Let's move it into the `Preprocessor` instead.
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 3fd1cdd..0bc26b6 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -69,7 +69,10 @@ void InitOnlyAction::ExecuteAction() {
// Basically PreprocessOnlyAction::ExecuteAction.
void ReadPCHAndPreprocessAction::ExecuteAction() {
- Preprocessor &PP = getCompilerInstance().getPreprocessor();
+ CompilerInstance &CI = getCompilerInstance();
+ AdjustCI(CI);
+
+ Preprocessor &PP = CI.getPreprocessor();
// Ignore unknown pragmas.
PP.IgnorePragmas();
@@ -1188,6 +1191,8 @@ void PrintDependencyDirectivesSourceMinimizerAction::ExecuteAction() {
void GetDependenciesByModuleNameAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
+ AdjustCI(CI);
+
Preprocessor &PP = CI.getPreprocessor();
SourceManager &SM = PP.getSourceManager();
FileID MainFileID = SM.getMainFileID();