summaryrefslogtreecommitdiffstats
path: root/src/state.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-15 23:34:03 (GMT)
committerNico Weber <nicolasweber@gmx.de>2015-03-15 23:34:03 (GMT)
commit56e9d08c028d2c16f787041dc1f41271464a8bdc (patch)
tree7c666efb09121fba46787e3bd3b47bf28ddeb5f2 /src/state.cc
parent51f06facf46e7a1a5338a4ca2ec9b8441c44c405 (diff)
downloadNinja-56e9d08c028d2c16f787041dc1f41271464a8bdc.zip
Ninja-56e9d08c028d2c16f787041dc1f41271464a8bdc.tar.gz
Ninja-56e9d08c028d2c16f787041dc1f41271464a8bdc.tar.bz2
Build self-consistent graphs for dupe edges with multiple outputs.
Fixes #867, both the crashes and "[stuck]" issues. The problem was that a duplicate edge would modify the in_edge of the outputs of the new build rule, but the edge corresponding to the old build rule would still think that the in_edge points to itself. `old_edge->outputs_[0]->in_edge()` would not return `old_edge`, which confused the scan logic. As fix, let `State::AddOut()` reject changing in_edge if it's already set. This changes behavior in a minor way: Previously, if there were multiple edges for a single output, the last edge would be kept. Now, the first edge is kept. This only had mostly-well-defined semantics if all duplicate edges are the same (which is the only case I've seen in practice), and for that case the behavior doesn't change. For testing, add a VerifyGraph() function and call that every time any test graph is parsed. That's a bit more code than just copying the test cases from the bug into build_test.cc, but it also yields better test coverage overall.
Diffstat (limited to 'src/state.cc')
-rw-r--r--src/state.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/state.cc b/src/state.cc
index 89f90c0..18c0c8c 100644
--- a/src/state.cc
+++ b/src/state.cc
@@ -141,13 +141,14 @@ void State::AddIn(Edge* edge, StringPiece path, unsigned int slash_bits) {
void State::AddOut(Edge* edge, StringPiece path, unsigned int slash_bits) {
Node* node = GetNode(path, slash_bits);
- edge->outputs_.push_back(node);
if (node->in_edge()) {
Warning("multiple rules generate %s. "
"builds involving this target will not be correct; "
"continuing anyway",
path.AsString().c_str());
+ return;
}
+ edge->outputs_.push_back(node);
node->set_in_edge(edge);
}