1111#include " clang/Serialization/InMemoryModuleCache.h"
1212#include " clang/Serialization/ModuleFile.h"
1313#include " llvm/Support/FileSystem.h"
14+ #include " llvm/Support/IOSandbox.h"
1415#include " llvm/Support/LockFileManager.h"
1516#include " llvm/Support/Path.h"
1617
@@ -27,6 +28,9 @@ void clang::maybePruneImpl(StringRef Path, time_t PruneInterval,
2728 if (PruneInterval <= 0 || PruneAfter <= 0 )
2829 return ;
2930
31+ // This is a compiler-internal input/output, let's bypass the sandbox.
32+ auto BypassSandbox = llvm::sys::sandbox::scopedDisable ();
33+
3034 llvm::SmallString<128 > TimestampFile (Path);
3135 llvm::sys::path::append (TimestampFile, " modules.timestamp" );
3236
@@ -103,6 +107,9 @@ class CrossProcessModuleCache : public ModuleCache {
103107
104108public:
105109 void prepareForGetLock (StringRef ModuleFilename) override {
110+ // This is a compiler-internal input/output, let's bypass the sandbox.
111+ auto BypassSandbox = llvm::sys::sandbox::scopedDisable ();
112+
106113 // FIXME: Do this in LockFileManager and only if the directory doesn't
107114 // exist.
108115 StringRef Dir = llvm::sys::path::parent_path (ModuleFilename);
@@ -115,6 +122,9 @@ class CrossProcessModuleCache : public ModuleCache {
115122 }
116123
117124 std::time_t getModuleTimestamp (StringRef ModuleFilename) override {
125+ // This is a compiler-internal input/output, let's bypass the sandbox.
126+ auto BypassSandbox = llvm::sys::sandbox::scopedDisable ();
127+
118128 std::string TimestampFilename =
119129 serialization::ModuleFile::getTimestampFilename (ModuleFilename);
120130 llvm::sys::fs::file_status Status;
@@ -124,6 +134,9 @@ class CrossProcessModuleCache : public ModuleCache {
124134 }
125135
126136 void updateModuleTimestamp (StringRef ModuleFilename) override {
137+ // This is a compiler-internal input/output, let's bypass the sandbox.
138+ auto BypassSandbox = llvm::sys::sandbox::scopedDisable ();
139+
127140 // Overwrite the timestamp file contents so that file's mtime changes.
128141 std::error_code EC;
129142 llvm::raw_fd_ostream OS (
@@ -138,6 +151,9 @@ class CrossProcessModuleCache : public ModuleCache {
138151
139152 void maybePrune (StringRef Path, time_t PruneInterval,
140153 time_t PruneAfter) override {
154+ // This is a compiler-internal input/output, let's bypass the sandbox.
155+ auto BypassSandbox = llvm::sys::sandbox::scopedDisable ();
156+
141157 maybePruneImpl (Path, PruneInterval, PruneAfter);
142158 }
143159
0 commit comments