diff options
Diffstat (limited to 'lib/Tooling/JSONCompilationDatabase.cpp')
-rw-r--r-- | lib/Tooling/JSONCompilationDatabase.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Tooling/JSONCompilationDatabase.cpp b/lib/Tooling/JSONCompilationDatabase.cpp index 3414f7db58..0ee9d174b4 100644 --- a/lib/Tooling/JSONCompilationDatabase.cpp +++ b/lib/Tooling/JSONCompilationDatabase.cpp @@ -190,8 +190,11 @@ std::unique_ptr<JSONCompilationDatabase> JSONCompilationDatabase::loadFromFile(StringRef FilePath, std::string &ErrorMessage, JSONCommandLineSyntax Syntax) { + // Don't mmap: if we're a long-lived process, the build system may overwrite. llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> DatabaseBuffer = - llvm::MemoryBuffer::getFile(FilePath); + llvm::MemoryBuffer::getFile(FilePath, /*FileSize=*/-1, + /*RequiresNullTerminator=*/true, + /*IsVolatile=*/true); if (std::error_code Result = DatabaseBuffer.getError()) { ErrorMessage = "Error while opening JSON database: " + Result.message(); return nullptr; |