ilya-biryukov added inline comments.
================
Comment at: clangd/ClangdServer.cpp:36
- ~FulfillPromiseGuard() { Promise.set_value(); }
+ ~FulfillContextPromiseGuard() { Promise.set_value(std::move(Ctx)); }
----------------
sammccall wrote:
> Yikes, I can see how we got here, but we really don't get to move out of
> something we received an lvalue-reference to...
>
> I think a safer idiom here is turning a whole lambda into a destructor:
>
> auto Fulfil = MakeDestructor([&]{
> DonePromise.set_value(std::move(Ctx));
> });
>
> I'm not sure if LLVM has a shared utility for this, I've seen it in other
> codebases. Either way we could just define it here.
>
> (Or we could copy the context to avoid the awkwardness)
Thanks for suggestion. I totally agree, callbacks on scope exit are better.
I couldn't find an utility like that in LLVM, but I think it's a useful one.
I'll add this locally to this file, but maybe we should make this helper public
and put it into clangd?
What are you thoughts on that?
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D40486
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits