forked from OSchip/llvm-project
[Tooling] Don't mmap the JSONCompilationDatabase, it's not correct for long-lived processes.
Reviewers: ilya-biryukov Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61631 llvm-svn: 360122
This commit is contained in:
parent
b9ec3e9370
commit
fdbb61856e
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue