From 650e04e179c9d355cd6d8f9a108d60c7969d24ca Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Fri, 4 Dec 2020 11:34:30 +0100 Subject: [Tooling] JSONCompilationDatabase::loadFromBuffer retains the buffer, copy it. This function doesn't seem to be used in-tree outside tests. However clangd wants to use it soon, and having the CDB be self-contained seems reasonable. Differential Revision: https://reviews.llvm.org/D92646 --- clang/lib/Tooling/JSONCompilationDatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/Tooling/JSONCompilationDatabase.cpp') diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp index 4aa1685..2d8847a 100644 --- a/clang/lib/Tooling/JSONCompilationDatabase.cpp +++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -217,7 +217,7 @@ JSONCompilationDatabase::loadFromBuffer(StringRef DatabaseString, std::string &ErrorMessage, JSONCommandLineSyntax Syntax) { std::unique_ptr DatabaseBuffer( - llvm::MemoryBuffer::getMemBuffer(DatabaseString)); + llvm::MemoryBuffer::getMemBufferCopy(DatabaseString)); std::unique_ptr Database( new JSONCompilationDatabase(std::move(DatabaseBuffer), Syntax)); if (!Database->parse(ErrorMessage)) -- cgit v1.1