diff options
author | Sam McCall <sam.mccall@gmail.com> | 2021-07-27 13:52:32 +0200 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2021-07-27 14:01:35 +0200 |
commit | ec1fb9533305e9bd69294ede7e5e7d9befbb2225 (patch) | |
tree | 709944fbf08003e2e3e617568add8d21f5e23568 | |
parent | 76f3ffb2b285998f02639db8fd42fb0de8a540d0 (diff) | |
download | llvm-ec1fb9533305e9bd69294ede7e5e7d9befbb2225.zip llvm-ec1fb9533305e9bd69294ede7e5e7d9befbb2225.tar.gz llvm-ec1fb9533305e9bd69294ede7e5e7d9befbb2225.tar.bz2 |
[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
-rw-r--r-- | clang-tools-extra/clangd/GlobalCompilationDatabase.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp index d830190b..cfc4613 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}, |