Index: lib/Tooling/JSONCompilationDatabase.cpp =================================================================== --- lib/Tooling/JSONCompilationDatabase.cpp +++ lib/Tooling/JSONCompilationDatabase.cpp @@ -190,8 +190,11 @@ 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> 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;