Index: lib/Support/FileOutputBuffer.cpp =================================================================== --- lib/Support/FileOutputBuffer.cpp (revision 321491) +++ lib/Support/FileOutputBuffer.cpp (working copy) @@ -163,7 +163,7 @@ case fs::file_type::regular_file: case fs::file_type::file_not_found: case fs::file_type::status_error: - return createOnDiskBuffer(Path, Size, Mode); + return createInMemoryBuffer(Path, Size, Mode); default: return createInMemoryBuffer(Path, Size, Mode); } Index: tools/clang/lib/Frontend/ASTUnit.cpp =================================================================== --- tools/clang/lib/Frontend/ASTUnit.cpp (revision 244347) +++ tools/clang/lib/Frontend/ASTUnit.cpp (working copy) @@ -2217,11 +2217,8 @@ // Write to a temporary file and later rename it to the actual file, to avoid // possible race conditions. - SmallString<128> TempPath; - TempPath = File; - TempPath += "-%%%%%%%%"; int fd; - if (llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath)) + if (llvm::sys::fs::openFileForWrite(File, fd, llvm::sys::fs::F_None)) return true; // FIXME: Can we somehow regenerate the stat cache here, or do we need to @@ -2235,11 +2232,6 @@ return true; } - if (llvm::sys::fs::rename(TempPath, File)) { - llvm::sys::fs::remove(TempPath); - return true; - } - return false; } Index: tools/clang/lib/Frontend/CompilerInstance.cpp =================================================================== --- tools/clang/lib/Frontend/CompilerInstance.cpp (revision 244347) +++ tools/clang/lib/Frontend/CompilerInstance.cpp (working copy) @@ -725,6 +725,8 @@ assert((!CreateMissingDirectories || UseTemporary) && "CreateMissingDirectories is only allowed when using temporary files"); + UseTemporary = false; + std::string OutFile, TempFile; if (!OutputPath.empty()) { OutFile = OutputPath; Index: tools/clang/lib/Rewrite/Rewriter.cpp =================================================================== --- tools/clang/lib/Rewrite/Rewriter.cpp (revision 244347) +++ tools/clang/lib/Rewrite/Rewriter.cpp (working copy) @@ -403,41 +403,20 @@ public: AtomicallyMovedFile(DiagnosticsEngine &Diagnostics, StringRef Filename, bool &AllWritten) - : Diagnostics(Diagnostics), Filename(Filename), AllWritten(AllWritten) { - TempFilename = Filename; - TempFilename += "-%%%%%%%%"; + : Diagnostics(Diagnostics), AllWritten(AllWritten) { int FD; - if (llvm::sys::fs::createUniqueFile(TempFilename, FD, TempFilename)) { + if (llvm::sys::fs::openFileForWrite(Filename, FD, llvm::sys::fs::F_None)) { AllWritten = false; - Diagnostics.Report(clang::diag::err_unable_to_make_temp) - << TempFilename; } else { FileStream.reset(new llvm::raw_fd_ostream(FD, /*shouldClose=*/true)); } } - ~AtomicallyMovedFile() { - if (!ok()) return; - - // Close (will also flush) theFileStream. - FileStream->close(); - if (std::error_code ec = llvm::sys::fs::rename(TempFilename, Filename)) { - AllWritten = false; - Diagnostics.Report(clang::diag::err_unable_to_rename_temp) - << TempFilename << Filename << ec.message(); - // If the remove fails, there's not a lot we can do - this is already an - // error. - llvm::sys::fs::remove(TempFilename); - } - } - bool ok() { return (bool)FileStream; } raw_ostream &getStream() { return *FileStream; } private: DiagnosticsEngine &Diagnostics; - StringRef Filename; - SmallString<128> TempFilename; std::unique_ptr FileStream; bool &AllWritten; }; Index: lib/Support/Unix/Program.inc =================================================================== --- lib/Support/Unix/Program.inc (revision 306665) +++ lib/Support/Unix/Program.inc (working copy) @@ -180,7 +180,7 @@ // If this OS has posix_spawn and there is no memory limit being implied, use // posix_spawn. It is more efficient than fork/exec. -#ifdef HAVE_POSIX_SPAWN +#if 0 if (MemoryLimit == 0) { posix_spawn_file_actions_t FileActionsStore; posix_spawn_file_actions_t *FileActions = nullptr; @@ -247,7 +247,7 @@ #endif // Create a child process. - int child = fork(); + int child = 0; switch (child) { // An error occurred: Return to the caller. case -1: Index: lib/Support/Unix/Signals.inc =================================================================== --- lib/Support/Unix/Signals.inc (revision 246397) +++ lib/Support/Unix/Signals.inc (working copy) @@ -90,6 +90,7 @@ static void RegisterHandler(int Signal) { + return; assert(NumRegisteredSignals < array_lengthof(RegisteredSignalInfo) &&