[cfe-commits] r124612 - in /cfe/trunk: include/clang/Frontend/CompilerInstance.h lib/Frontend/CompilerInstance.cpp
Daniel Dunbar
daniel at zuster.org
Mon Jan 31 14:00:42 PST 2011
Author: ddunbar
Date: Mon Jan 31 16:00:42 2011
New Revision: 124612
URL: http://llvm.org/viewvc/llvm-project?rev=124612&view=rev
Log:
Frontend: Add an explicit RemoveFileOnSignal flag argument, to control the
automatic behavior (which is undesirable in a multithreaded context).
Modified:
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=124612&r1=124611&r2=124612&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Mon Jan 31 16:00:42 2011
@@ -583,7 +583,8 @@
///
/// \return - Null on error.
llvm::raw_fd_ostream *
- createOutputFile(llvm::StringRef OutputPath, bool Binary = true,
+ createOutputFile(llvm::StringRef OutputPath,
+ bool Binary = true, bool RemoveFileOnSignal = true,
llvm::StringRef BaseInput = "",
llvm::StringRef Extension = "");
@@ -600,13 +601,17 @@
/// for deriving the output path.
/// \param Extension - The extension to use for derived output names.
/// \param Binary - The mode to open the file in.
+ /// \param RemoveFileOnSignal - Whether the file should be registered with
+ /// llvm::sys::RemoveFileOnSignal. Note that this is not safe for
+ /// multithreaded use, as the underlying signal mechanism is not reentrant
/// \param ResultPathName [out] - If given, the result path name will be
/// stored here on success.
/// \param TempPathName [out] - If given, the temporary file path name
/// will be stored here on success.
static llvm::raw_fd_ostream *
createOutputFile(llvm::StringRef OutputPath, std::string &Error,
- bool Binary = true, llvm::StringRef BaseInput = "",
+ bool Binary = true, bool RemoveFileOnSignal = true,
+ llvm::StringRef BaseInput = "",
llvm::StringRef Extension = "",
std::string *ResultPathName = 0,
std::string *TempPathName = 0);
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=124612&r1=124611&r2=124612&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Jan 31 16:00:42 2011
@@ -381,16 +381,17 @@
llvm::StringRef InFile,
llvm::StringRef Extension) {
return createOutputFile(getFrontendOpts().OutputFile, Binary,
- InFile, Extension);
+ /*RemoveFileOnSignal=*/true, InFile, Extension);
}
llvm::raw_fd_ostream *
CompilerInstance::createOutputFile(llvm::StringRef OutputPath,
- bool Binary,
+ bool Binary, bool RemoveFileOnSignal,
llvm::StringRef InFile,
llvm::StringRef Extension) {
std::string Error, OutputPathName, TempPathName;
llvm::raw_fd_ostream *OS = createOutputFile(OutputPath, Error, Binary,
+ RemoveFileOnSignal,
InFile, Extension,
&OutputPathName,
&TempPathName);
@@ -412,6 +413,7 @@
CompilerInstance::createOutputFile(llvm::StringRef OutputPath,
std::string &Error,
bool Binary,
+ bool RemoveFileOnSignal,
llvm::StringRef InFile,
llvm::StringRef Extension,
std::string *ResultPathName,
@@ -455,7 +457,8 @@
return 0;
// Make sure the out stream file gets removed if we crash.
- llvm::sys::RemoveFileOnSignal(llvm::sys::Path(OSFile));
+ if (RemoveFileOnSignal)
+ llvm::sys::RemoveFileOnSignal(llvm::sys::Path(OSFile));
if (ResultPathName)
*ResultPathName = OutFile;
More information about the cfe-commits
mailing list