diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-09-02 11:31:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-09-02 11:31:25 +0200 |
commit | 171b0e3a3b6f5bde0489c0e12c679fcefdeca54f (patch) | |
tree | 654518124cc827f2a62b749d89e632709a1131c1 | |
parent | e2e2001260406bcfa0c636e00be3bc34808f8968 (diff) |
Don't consider aliasing in variable override lookup
-rw-r--r-- | libbuild2/scope.cxx | 6 | ||||
-rw-r--r-- | libbuild2/variable.cxx | 5 | ||||
-rw-r--r-- | libbuild2/variable.hxx | 8 |
3 files changed, 13 insertions, 6 deletions
diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx index ad01aa7..39aba8f 100644 --- a/libbuild2/scope.cxx +++ b/libbuild2/scope.cxx @@ -319,8 +319,12 @@ namespace build2 return lookup_type (); // Note: using the original as storage variable. + // Note: have to suppress aliases since used for something else. // - return lookup_type (s->vars.lookup (*o).first, &var, &s->vars); + return lookup_type ( + s->vars.lookup (*o, true /* typed */, false /* aliased */).first, + &var, + &s->vars); }; // Return true if a value is from this scope (either target type/pattern- diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx index d84945f..0cf6528 100644 --- a/libbuild2/variable.cxx +++ b/libbuild2/variable.cxx @@ -1721,7 +1721,7 @@ namespace build2 const variable_map empty_variable_map (nullptr /* context */); auto variable_map:: - lookup (const variable& var, bool typed) const -> + lookup (const variable& var, bool typed, bool aliased) const -> pair<const value_data*, const variable&> { const variable* v (&var); @@ -1739,7 +1739,8 @@ namespace build2 break; } - v = v->aliases; + if (aliased) + v = v->aliases; } while (v != &var && v != nullptr); diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx index fc446bc..df0cb77 100644 --- a/libbuild2/variable.hxx +++ b/libbuild2/variable.hxx @@ -1555,11 +1555,13 @@ namespace build2 return var != nullptr ? operator[] (*var) : lookup_type (); } - // If typed is false, leave the value untyped even if the variable is. - // The second half of the pair is the storage variable. + // If typed is false, leave the value untyped even if the variable is. If + // aliased is false, then don't consider aliases (used by the variable + // override machinery where the aliases chain is repurrposed for something + // else). The second half of the pair is the storage variable. // pair<const value_data*, const variable&> - lookup (const variable&, bool typed = true) const; + lookup (const variable&, bool typed = true, bool aliased = true) const; pair<value_data*, const variable&> lookup_to_modify (const variable&, bool typed = true); |