aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-19 08:03:46 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-19 08:03:46 +0200
commit49b6de46afac29898d47c1f38f1ad0b57ea041af (patch)
tree60b9b8e55bb7f79e4cf84a95bc8689b37790e0b7 /build2
parentba9137db8e456eb00b921a855e5383b78fa7a8ec (diff)
Fix typification bug in variable_cache
Diffstat (limited to 'build2')
-rw-r--r--build2/scope.cxx6
-rw-r--r--build2/variable5
-rw-r--r--build2/variable.txx10
3 files changed, 15 insertions, 6 deletions
diff --git a/build2/scope.cxx b/build2/scope.cxx
index 4449747..59b2ee2 100644
--- a/build2/scope.cxx
+++ b/build2/scope.cxx
@@ -50,7 +50,8 @@ namespace build2
s->target_vars.cache.insert (
make_tuple (&v, tt, *tn),
stem,
- static_cast<const variable_map::value_data&> (v).version));
+ static_cast<const variable_map::value_data&> (v).version,
+ var));
value& cv (entry.first);
@@ -404,7 +405,8 @@ namespace build2
inner_proj->override_cache.insert (
make_pair (&var, inner_vars),
stem,
- 0)); // Overrides are immutable.
+ 0, // Overrides are immutable.
+ var));
value& cv (entry.first);
bool cl (entry.second.owns_lock ());
diff --git a/build2/variable b/build2/variable
index ea1912a..be3b478 100644
--- a/build2/variable
+++ b/build2/variable
@@ -1208,10 +1208,11 @@ namespace build2
{
public:
// If the returned unique lock is locked, then the value has been
- // invalidated.
+ // invalidated. If the variable type does not match the value type,
+ // then typify the cached value.
//
pair<value&, ulock>
- insert (K, const lookup& stem, size_t version);
+ insert (K, const lookup& stem, size_t version, const variable&);
private:
struct entry_type
diff --git a/build2/variable.txx b/build2/variable.txx
index 038f107..c7d3e5a 100644
--- a/build2/variable.txx
+++ b/build2/variable.txx
@@ -557,7 +557,7 @@ namespace build2
//
template <typename K>
pair<value&, ulock> variable_cache<K>::
- insert (K k, const lookup& stem, size_t ver)
+ insert (K k, const lookup& stem, size_t ver, const variable& var)
{
using value_data = variable_map::value_data;
@@ -580,7 +580,8 @@ namespace build2
if (i != m_.end () &&
i->second.version == ver &&
i->second.stem_vars == svars &&
- i->second.stem_version == sver)
+ i->second.stem_version == sver &&
+ (var.type == nullptr || i->second.value.type == var.type))
return pair<value&, ulock> (i->second.value, move (ul));
// Relock for exclusive access. Note that it is entirely possible
@@ -625,9 +626,14 @@ namespace build2
e.value.version++; // Value changed.
}
else
+ {
// Cache hit.
//
+ if (var.type != nullptr && e.value.type != var.type)
+ typify (e.value, *var.type, &var);
+
ul.unlock ();
+ }
return pair<value&, ulock> (e.value, move (ul));
}