[clang-tools-extra] ec1fb95 - [clangd] Use function pointer instead of function_ref to avoid GCC 5 bug
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 27 05:01:42 PDT 2021
Author: Sam McCall
Date: 2021-07-27T14:01:35+02:00
New Revision: ec1fb9533305e9bd69294ede7e5e7d9befbb2225
URL: https://github.com/llvm/llvm-project/commit/ec1fb9533305e9bd69294ede7e5e7d9befbb2225
DIFF: https://github.com/llvm/llvm-project/commit/ec1fb9533305e9bd69294ede7e5e7d9befbb2225.diff
LOG: [clangd] Use function pointer instead of function_ref to avoid GCC 5 bug
With GCC <6 constructing a function_ref from a free function reference
leads to it referencing a temporary function pointer. If the lifetime of
that temporary is insufficient it can crash.
Fixes https://github.com/clangd/clangd/issues/800
Added:
Modified:
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index d830190bfdfdb..cfc46131496d1 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -279,11 +279,10 @@ bool DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(
struct CDBFile {
CachedFile *File;
// Wrapper for {Fixed,JSON}CompilationDatabase::loadFromBuffer.
- llvm::function_ref<std::unique_ptr<tooling::CompilationDatabase>(
+ std::unique_ptr<tooling::CompilationDatabase> (*Parser)(
PathRef,
/*Data*/ llvm::StringRef,
- /*ErrorMsg*/ std::string &)>
- Parser;
+ /*ErrorMsg*/ std::string &);
};
for (const auto &Entry : {CDBFile{&CompileCommandsJson, parseJSON},
CDBFile{&BuildCompileCommandsJson, parseJSON},
More information about the cfe-commits
mailing list