summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/JSONCompilationDatabase.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-05-07 09:05:15 +0000
committerSam McCall <sam.mccall@gmail.com>2019-05-07 09:05:15 +0000
commitfdbb61856e84d69194d848e6d492193326eb60f4 (patch)
tree7bc663756896d49904ae44dde8ed94cee22ac859 /clang/lib/Tooling/JSONCompilationDatabase.cpp
parentb9ec3e93706dc1782d5b8c70624f96980cb791cc (diff)
downloadbcm5719-llvm-fdbb61856e84d69194d848e6d492193326eb60f4.tar.gz
bcm5719-llvm-fdbb61856e84d69194d848e6d492193326eb60f4.zip
[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
Diffstat (limited to 'clang/lib/Tooling/JSONCompilationDatabase.cpp')
-rw-r--r--clang/lib/Tooling/JSONCompilationDatabase.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp
index 3414f7db58a..0ee9d174b44 100644
--- a/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud