[clang] 05d0f1a - Frontend: Respect -fno-temp-file when creating a PCH
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 17 18:34:36 PDT 2021
Author: Zachary Henkel
Date: 2021-06-17T18:34:10-07:00
New Revision: 05d0f1a8ea012a6b7b8ea65893ec4121106444b5
URL: https://github.com/llvm/llvm-project/commit/05d0f1a8ea012a6b7b8ea65893ec4121106444b5
DIFF: https://github.com/llvm/llvm-project/commit/05d0f1a8ea012a6b7b8ea65893ec4121106444b5.diff
LOG: Frontend: Respect -fno-temp-file when creating a PCH
When creating a PCH file the use of a temp file will be dictated by the
presence or absence of the -fno-temp-file flag. Creating a module file
will always use a temp file via the new ForceUseTemporary flag.
This fixes bug 50033.
Added:
Modified:
clang/include/clang/Frontend/CompilerInstance.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/FrontendActions.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h
index 9d6dd8fa1006f..861b15020329b 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -696,15 +696,13 @@ class CompilerInstance : public ModuleLoader {
/// The files created by this are usually removed on signal, and, depending
/// on FrontendOptions, may also use a temporary file (that is, the data is
/// written to a temporary file which will atomically replace the target
- /// output on success). If a client (like libclang) needs to disable
- /// RemoveFileOnSignal, temporary files will be forced on.
+ /// output on success).
///
/// \return - Null on error.
- std::unique_ptr<raw_pwrite_stream>
- createDefaultOutputFile(bool Binary = true, StringRef BaseInput = "",
- StringRef Extension = "",
- bool RemoveFileOnSignal = true,
- bool CreateMissingDirectories = false);
+ std::unique_ptr<raw_pwrite_stream> createDefaultOutputFile(
+ bool Binary = true, StringRef BaseInput = "", StringRef Extension = "",
+ bool RemoveFileOnSignal = true, bool CreateMissingDirectories = false,
+ bool ForceUseTemporary = false);
/// Create a new output file, optionally deriving the output path name, and
/// add it to the list of tracked output files.
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 78c7d84bbef45..063384130f730 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -743,11 +743,9 @@ void CompilerInstance::clearOutputFiles(bool EraseFiles) {
}
}
-std::unique_ptr<raw_pwrite_stream>
-CompilerInstance::createDefaultOutputFile(bool Binary, StringRef InFile,
- StringRef Extension,
- bool RemoveFileOnSignal,
- bool CreateMissingDirectories) {
+std::unique_ptr<raw_pwrite_stream> CompilerInstance::createDefaultOutputFile(
+ bool Binary, StringRef InFile, StringRef Extension, bool RemoveFileOnSignal,
+ bool CreateMissingDirectories, bool ForceUseTemporary) {
StringRef OutputPath = getFrontendOpts().OutputFile;
Optional<SmallString<128>> PathStorage;
if (OutputPath.empty()) {
@@ -760,9 +758,8 @@ CompilerInstance::createDefaultOutputFile(bool Binary, StringRef InFile,
}
}
- // Force a temporary file if RemoveFileOnSignal was disabled.
return createOutputFile(OutputPath, Binary, RemoveFileOnSignal,
- getFrontendOpts().UseTemporary || !RemoveFileOnSignal,
+ getFrontendOpts().UseTemporary || ForceUseTemporary,
CreateMissingDirectories);
}
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 6df57cbb45ae0..c6ebbdc8c04e1 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -239,7 +239,8 @@ GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
// Because this is exposed via libclang we must disable RemoveFileOnSignal.
return CI.createDefaultOutputFile(/*Binary=*/true, InFile, /*Extension=*/"",
/*RemoveFileOnSignal=*/false,
- /*CreateMissingDirectories=*/true);
+ /*CreateMissingDirectories=*/true,
+ /*ForceUseTemporary=*/true);
}
bool GenerateModuleInterfaceAction::BeginSourceFileAction(
More information about the cfe-commits
mailing list