[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-23 Thread Adrian McCarthy via Phabricator via lldb-commits
amccarth added a comment. Nit: As a single word, "cleanup" is a noun (or an adjective). As two words, "clean up" is a verb. Given that, I'd expect to see classes and objects with names like `Cleanup` or `cleanup` and functions to contain `CleanUp`. When I see an identifier like

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-23 Thread Phabricator via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL325964: [Utility] Simplify and generalize the CleanUp helper, NFC (authored by vedantk, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit:

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-23 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment. Thanks! I'll clean up the issues you pointed out before committing. https://reviews.llvm.org/D43662 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-23 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision. labath added a comment. This revision is now accepted and ready to land. This looks great, thanks. I've been wanting to do something about the CleanUp class for a long time. I have just a couple of nits, but no need to go through review again.

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-23 Thread Vedant Kumar via Phabricator via lldb-commits
vsk updated this revision to Diff 135671. vsk added a comment. Herald added a subscriber: mgorny. Thanks for the feedback. I've added support for forwarding arguments to the cleanup function though the constructor. It uses std::bind instead of a lambda because I couldn't figure out a simpler

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-23 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment. I agree with Pavel, I prefer having a slightly more complex constructor if we can make the call sites simpler for the simple common cases, especially since we don't lose any generality by doing so. It's also not an uncommon pattern in C++, e.g. `std::async` does

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment. While we wait for the verdict on the template stuff, it occurred to me that you don't need the PerformCleanup bool member as std::function has an "empty" state. So the destructor can just do `if(Cleanup) Cleanup()` and the disable function can reset the cleanup object.

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment. In https://reviews.llvm.org/D43662#1016950, @labath wrote: > In https://reviews.llvm.org/D43662#1016939, @vsk wrote: > > > > What do you think about a syntax like: > > > > > > lldb_utility::CleanUp cleanup_our(::close, our_socket); // The CleanUp > > > constructor creates

Re: [Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Zachary Turner via lldb-commits
I wouldn’t use std::bind though, just make a lambda. On Thu, Feb 22, 2018 at 6:06 PM Pavel Labath via Phabricator < revi...@reviews.llvm.org> wrote: > labath added a comment. > > In https://reviews.llvm.org/D43662#1016939, @vsk wrote: > > > > What do you think about a syntax like: > > > > > >

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment. In https://reviews.llvm.org/D43662#1016939, @vsk wrote: > > What do you think about a syntax like: > > > > lldb_utility::CleanUp cleanup_our(::close, our_socket); // The CleanUp > > constructor creates the std::function internally > > @labath I find the current version

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added a comment. > Couldn't we just add a creator helper so that you can say: > > auto cleanup = makeCleanupRAII([&] { > > process_sp->Destroy(/*force_kill=*/false); > debugger.StopEventHandlerThread(); > }); @zturner In this version of the patch, CleanUp accepts a std::function,

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment. Btw, I think we should also move the CleanUp class out of the lldb_utility and into lldb_private namespace. we have been slowly getting rid of these... https://reviews.llvm.org/D43662 ___ lldb-commits mailing list

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment. What do you think about a syntax like: lldb_utility::CleanUp cleanup_our(::close, our_socket); // The CleanUp constructor creates the std::function internally This would be a generalization of your syntax, so you could still use a lambda when needed, but you could

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment. Couldn't we just add a creator helper so that you can say: auto cleanup = makeCleanupRAII([&] { process_sp->Destroy(/*force_kill=*/false); debugger.StopEventHandlerThread(); }); https://reviews.llvm.org/D43662

[Lldb-commits] [PATCH] D43662: [Utility] Simplify and generalize the CleanUp helper, NFC

2018-02-22 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision. vsk added reviewers: zturner, labath, davide, JDevlieghere. Removing the template arguments and most of the mutating methods from CleanUp makes it easier to understand and reuse. In its present state, CleanUp would be too cumbersome to adapt to cases where multiple