From 2cab7b3c2618be9328545e66fc340faea6b15f45 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2022 15:20:07 +0200 Subject: Minor tweaks to target_lock passing semantics This should also get rid of the bogus -Wdangling-pointer issued by GCC 12. --- libbuild2/algorithm.cxx | 10 ++++++++-- libbuild2/algorithm.ixx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 16a6728..e11275d 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -1117,8 +1117,10 @@ namespace build2 return ct.try_matched_state (a, false); } + // Note: lock is a reference to avoid the stacking overhead. + // static group_view - resolve_members_impl (action a, const target& g, target_lock l) + resolve_members_impl (action a, const target& g, target_lock&& l) { // Note that we will be unlocked if the target is already applied. // @@ -1247,8 +1249,10 @@ namespace build2 return r; } + // Note: lock is a reference to avoid the stacking overhead. + // void - resolve_group_impl (action a, const target& t, target_lock l) + resolve_group_impl (action a, const target& t, target_lock&& l) { pair r ( match_impl (l, true /* step */, true /* try_match */)); @@ -1262,6 +1266,8 @@ namespace build2 r.second = target_state::failed; } + l.unlock (); + if (r.first && r.second == target_state::failed) throw failed (); } diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx index 7c87a72..3398595 100644 --- a/libbuild2/algorithm.ixx +++ b/libbuild2/algorithm.ixx @@ -646,7 +646,7 @@ namespace build2 } LIBBUILD2_SYMEXPORT void - resolve_group_impl (action, const target&, target_lock); + resolve_group_impl (action, const target&, target_lock&&); inline const target* resolve_group (action a, const target& t) -- cgit v1.1