[libcxx-commits] [PATCH] D115730: [libc++] Add a helper class to write code with the strong exception guarantee
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Dec 21 06:45:47 PST 2021
ldionne added a comment.
In D115730#3203479 <https://reviews.llvm.org/D115730#3203479>, @Quuxplusone wrote:
> @ldionne: I'd still prefer the version I showed in https://reviews.llvm.org/D115730?id=394248#inline-1106466 where the object doesn't have a `completed` data member at all (so it would better be named `__on_scope_exit` rather than `__transaction`). I'd also be interested in seeing a godbolt or something showing which approach gives better codegen. Naïvely, I would expect my preferred version would be no worse, and maybe a tiny bit better, because it gives the optimizer more freedom to rearrange the stack frame. But the reason I prefer it is for simplicity/readability: I think the `set_completed`/`__complete` thing is easy to mess up.
I have a strong distaste for managing the `bool completed` and having to enclose all the rollback code in `if (!completed)`. IMO that's a lot easier to mess up than just making sure a `__complete()` method is called. Since this simple helper is really tailored for exception handling (it's purely a means to remove `#if _LIBCPP_NO_EXCEPTIONS`), I'd rather keep as-is.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115730/new/
https://reviews.llvm.org/D115730
More information about the libcxx-commits
mailing list