[PATCH] D61631: [Tooling] Don't mmap the JSONCompilationDatabase, it's not correct for long-lived processes.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 7 02:04:04 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360122: [Tooling] Don't mmap the JSONCompilationDatabase, it's not correct for long… (authored by sammccall, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D61631?vs=198408&id=198414#toc
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61631/new/
https://reviews.llvm.org/D61631
Files:
lib/Tooling/JSONCompilationDatabase.cpp
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<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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61631.198414.patch
Type: text/x-patch
Size: 965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190507/69130077/attachment-0001.bin>
More information about the cfe-commits
mailing list