[clang-tools-extra] r323863 - [clangd] Second attempt to fix MSVC compilation breakage.
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 31 03:26:44 PST 2018
Author: ibiryukov
Date: Wed Jan 31 03:26:43 2018
New Revision: 323863
URL: http://llvm.org/viewvc/llvm-project?rev=323863&view=rev
Log:
[clangd] Second attempt to fix MSVC compilation breakage.
Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=323863&r1=323862&r2=323863&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jan 31 03:26:43 2018
@@ -34,25 +34,31 @@ namespace {
// Issues an async read of AST and waits for results.
template <class Ret, class Func>
Ret blockingRunWithAST(TUScheduler &S, PathRef File, Func &&F) {
- // Using Optional to workaround MSVC bug. It requires future<> arguments to
- // have default ctor.
- std::packaged_task<llvm::Optional<Ret>(llvm::Expected<InputsAndAST>)> Task(
- std::forward<Func>(F));
+ // Using shared_ptr to workaround MSVC bug. It requires future<> arguments to
+ // have default and copy ctor.
+ auto SharedPtrFunc = [&](llvm::Expected<InputsAndAST> Arg) {
+ return std::make_shared<Ret>(F(std::move(Arg)));
+ };
+ std::packaged_task<std::shared_ptr<Ret>(llvm::Expected<InputsAndAST>)> Task(
+ SharedPtrFunc);
auto Future = Task.get_future();
S.runWithAST(File, std::move(Task));
- return *Future.get();
+ return std::move(*Future.get());
}
// Issues an async read of preamble and waits for results.
template <class Ret, class Func>
Ret blockingRunWithPreamble(TUScheduler &S, PathRef File, Func &&F) {
- // Using Optional to workaround MSVC bug. It requires future<> arguments to
- // have default ctor.
- std::packaged_task<llvm::Optional<Ret>(llvm::Expected<InputsAndPreamble>)>
- Task(std::forward<Func>(F));
+ // Using shared_ptr to workaround MSVC bug. It requires future<> arguments to
+ // have default and copy ctor.
+ auto SharedPtrFunc = [&](llvm::Expected<InputsAndPreamble> Arg) {
+ return std::make_shared<Ret>(F(std::move(Arg)));
+ };
+ std::packaged_task<std::shared_ptr<Ret>(llvm::Expected<InputsAndPreamble>)>
+ Task(SharedPtrFunc);
auto Future = Task.get_future();
S.runWithPreamble(File, std::move(Task));
- return *Future.get();
+ return std::move(*Future.get());
}
void ignoreError(llvm::Error Err) {
More information about the cfe-commits
mailing list