aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-18 15:11:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-18 15:11:53 +0200
commitc28bb7c4038916d359228317d4ef5fe17dabce61 (patch)
tree834d7c1768138b60e42d4d5d73d7a778a6a34932
parent4f8ce9ca52f8bd967ac4e656e24e4f33584abd22 (diff)
Add couple of sanity checks
-rw-r--r--libbuild2/cc/compile-rule.cxx11
-rw-r--r--libbuild2/rule.cxx2
-rw-r--r--libbuild2/target.cxx3
-rw-r--r--libbuild2/target.ixx4
4 files changed, 14 insertions, 6 deletions
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 6e21a7e..da958f4 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -779,7 +779,7 @@ namespace build2
// t.prerequisite_targets since we used standard search() and match()
// above.
//
- const file& src (*md.src.search (t).is_a<file> ());
+ const file& src (*md.src.load (memory_order_relaxed)->is_a<file> ());
// Figure out if __symexport is used. While normally it is specified
// on the project root (which we cached), it can be overridden with
@@ -892,8 +892,13 @@ namespace build2
// Finally the source file.
//
- if (dd.expect (src.path ()) != nullptr)
- l4 ([&]{trace << "source file mismatch forcing update of " << t;});
+ {
+ const path& p (src.path ());
+ assert (!p.empty ()); // Sanity check.
+
+ if (dd.expect (p) != nullptr)
+ l4 ([&]{trace << "source file mismatch forcing update of " << t;});
+ }
// If any of the above checks resulted in a mismatch (different
// compiler, options, or source file) or if the depdb is newer than
diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx
index d69e817..776f022 100644
--- a/libbuild2/rule.cxx
+++ b/libbuild2/rule.cxx
@@ -71,7 +71,7 @@ namespace build2
if (p->empty ())
{
// Since we cannot come up with an extension, ask the target's
- // derivation function to treat this as prerequisite (just like in
+ // derivation function to treat this as a prerequisite (just like in
// search_existing_file()).
//
if (pt->derive_extension (true) == nullptr)
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index 23e6c9c..2ca3de8 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -700,8 +700,7 @@ namespace build2
p += ee;
}
- path (move (p));
- return path_;
+ return path (move (p));
}
// Search functions.
diff --git a/libbuild2/target.ixx b/libbuild2/target.ixx
index f304250..49f87cf 100644
--- a/libbuild2/target.ixx
+++ b/libbuild2/target.ixx
@@ -504,6 +504,10 @@ namespace build2
inline const path& path_target::
path () const
{
+ // You may be wondering why don't we spin the transition out? The reason
+ // is it shouldn't matter since were we called just a moment earlier, we
+ // would have seen it.
+ //
return path_state_.load (memory_order_acquire) == 2 ? path_ : empty_path;
}