aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/algorithm.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/algorithm.cxx')
-rw-r--r--libbuild2/algorithm.cxx38
1 files changed, 22 insertions, 16 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx
index 5011b26..8ef88e4 100644
--- a/libbuild2/algorithm.cxx
+++ b/libbuild2/algorithm.cxx
@@ -332,22 +332,28 @@ namespace build2
if (*mp != nullptr) // Might already be there.
return **mp;
- pair<target&, ulock> r (
- t.ctx.targets.insert_locked (tt,
- move (dir),
- move (out),
- move (n),
- nullopt /* ext */,
- target_decl::implied,
- trace));
-
- assert (r.second);
-
- target& m (r.first);
- *mp = &m;
- m.group = &t;
-
- return m;
+ target* m (nullptr);
+ {
+ pair<target&, ulock> r (
+ t.ctx.targets.insert_locked (tt,
+ move (dir),
+ move (out),
+ move (n),
+ nullopt /* ext */,
+ target_decl::implied,
+ trace));
+
+ if (r.second) // Inserted.
+ {
+ m = &r.first;
+ m->group = &t;
+ }
+ }
+
+ assert (m != nullptr);
+ *mp = m;
+
+ return *m;
};
// Return the matching rule or NULL if no match and try_match is true.