-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathllvm-no-temp-files.patch
135 lines (124 loc) · 4.63 KB
/
llvm-no-temp-files.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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<llvm::raw_fd_ostream> 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) &&