From 96d873e6efb5da29a683ff48294c2216a52e34c1 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 23 Mar 2015 18:16:36 -0700 Subject: Move warning emission on dupe edges from State to ManifestParser. This will make it easier to optionally make this an error (because ManifestParser has a way of printing errors), and it'll also make it easier to make the tests quiet again. No behavior change. --- src/manifest_parser.cc | 7 ++++++- src/state.cc | 12 ++++-------- src/state.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/manifest_parser.cc b/src/manifest_parser.cc index b747ad4..ede5adb 100644 --- a/src/manifest_parser.cc +++ b/src/manifest_parser.cc @@ -328,7 +328,12 @@ bool ManifestParser::ParseEdge(string* err) { unsigned int slash_bits; if (!CanonicalizePath(&path, &slash_bits, &path_err)) return lexer_.Error(path_err, err); - state_->AddOut(edge, path, slash_bits); + if (!state_->AddOut(edge, path, slash_bits)) { + Warning("multiple rules generate %s. " + "builds involving this target will not be correct; " + "continuing anyway", + path.c_str()); + } } if (edge->outputs_.empty()) { // All outputs of the edge are already created by other edges. Don't add diff --git a/src/state.cc b/src/state.cc index 0426b85..a70f211 100644 --- a/src/state.cc +++ b/src/state.cc @@ -140,17 +140,13 @@ void State::AddIn(Edge* edge, StringPiece path, unsigned int slash_bits) { node->AddOutEdge(edge); } -void State::AddOut(Edge* edge, StringPiece path, unsigned int slash_bits) { +bool State::AddOut(Edge* edge, StringPiece path, unsigned int slash_bits) { Node* node = GetNode(path, slash_bits); - if (node->in_edge()) { - Warning("multiple rules generate %s. " - "builds involving this target will not be correct; " - "continuing anyway", - path.AsString().c_str()); - return; - } + if (node->in_edge()) + return false; edge->outputs_.push_back(node); node->set_in_edge(edge); + return true; } bool State::AddDefault(StringPiece path, string* err) { diff --git a/src/state.h b/src/state.h index db0e3aa..5000138 100644 --- a/src/state.h +++ b/src/state.h @@ -97,7 +97,7 @@ struct State { Node* SpellcheckNode(const string& path); void AddIn(Edge* edge, StringPiece path, unsigned int slash_bits); - void AddOut(Edge* edge, StringPiece path, unsigned int slash_bits); + bool AddOut(Edge* edge, StringPiece path, unsigned int slash_bits); bool AddDefault(StringPiece path, string* error); /// Reset state. Keeps all nodes and edges, but restores them to the -- cgit v0.12