aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2020-11-20 18:04:32 -0800
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2021-01-26 15:56:19 -0800
commitad7aaa475e5e632242b07380ec47d2f35d077209 (patch)
tree7633c37dced0ea3e786f9fa47ee048e0a04dee63 /clang/lib/Frontend/FrontendActions.cpp
parent4d28f0a6a4036388694bb83aebc0db9334b82f6e (diff)
downloadllvm-ad7aaa475e5e632242b07380ec47d2f35d077209.zip
llvm-ad7aaa475e5e632242b07380ec47d2f35d077209.tar.gz
llvm-ad7aaa475e5e632242b07380ec47d2f35d077209.tar.bz2
Frontend: Fix layering between create{,Default}OutputFile, NFC
Fix layering between `CompilerInstance::createDefaultOutputFile` and the two versions of `createOutputFile`. - Add missing configuration flags to `createDefaultOutputFile` so that GeneratePCHAction and GenerateModuleFromModuleMapAction can use it. They previously promised that temporary files were turned on; now `createDefaultOutputFile` handles that logic. - Lift the logic handling `InFile` and `Extension` to `createDefaultOutputFile`, since it's only the callers of that function that are using it. - Rename the deeper of the two `createOutputFile`s to `createOutputFileImpl` and make it private to `CompilerInstance` (to prove that no one else is using it). - Sink the logic for adding to `CompilerInstance::OutputFiles` down to `createOutputFileImpl`, allowing two "optional" (but always used) `std::string*` out parameters to be removed. - Instead of passing a `std::error_code` out parameter into `createOutputFileImpl`, have it return `Expected<>`. - As a drive-by, inline `CompilerInstance::addOutputFile` into its only caller, `createOutputFileImpl`. Clean layering makes it easier for a future commit to extract `createOutputFileImpl` out of `CompilerInstance`. Differential Revision: https://reviews.llvm.org/D93248
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index d32f27a..060cec2 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -136,13 +136,9 @@ bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI,
std::unique_ptr<llvm::raw_pwrite_stream>
GeneratePCHAction::CreateOutputFile(CompilerInstance &CI, StringRef InFile,
std::string &OutputFile) {
- // We use createOutputFile here because this is exposed via libclang, and we
- // must disable the RemoveFileOnSignal behavior.
- // We use a temporary to avoid race conditions.
- std::unique_ptr<raw_pwrite_stream> OS =
- CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
- /*RemoveFileOnSignal=*/false, InFile,
- /*Extension=*/"", CI.getFrontendOpts().UseTemporary);
+ // Because this is exposed via libclang we must disable RemoveFileOnSignal.
+ std::unique_ptr<raw_pwrite_stream> OS = CI.createDefaultOutputFile(
+ /*Binary=*/true, InFile, /*Extension=*/"", /*RemoveFileOnSignal=*/false);
if (!OS)
return nullptr;
@@ -219,13 +215,10 @@ GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
ModuleMapFile);
}
- // We use createOutputFile here because this is exposed via libclang, and we
- // must disable the RemoveFileOnSignal behavior.
- // We use a temporary to avoid race conditions.
- return CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
- /*RemoveFileOnSignal=*/false, InFile,
- /*Extension=*/"", /*UseTemporary=*/true,
- /*CreateMissingDirectories=*/true);
+ // Because this is exposed via libclang we must disable RemoveFileOnSignal.
+ return CI.createDefaultOutputFile(/*Binary=*/true, InFile, /*Extension=*/"",
+ /*RemoveFileOnSignal=*/false,
+ /*CreateMissingDirectories=*/true);
}
bool GenerateModuleInterfaceAction::BeginSourceFileAction(