Disallow multiple edges.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60127 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov
2008-11-26 22:59:45 +00:00
parent e21815f41b
commit 7e6d70a425
3 changed files with 26 additions and 5 deletions

View File

@ -79,6 +79,20 @@ namespace {
}
void Node::AddEdge(Edge* Edg) {
// If there already was an edge between two nodes, modify it instead
// of adding a new edge.
const std::string& ToolName = Edg->ToolName();
for (container_type::iterator B = OutEdges.begin(), E = OutEdges.end();
B != E; ++B) {
if ((*B)->ToolName() == ToolName) {
llvm::IntrusiveRefCntPtr<Edge>(Edg).swap(*B);
return;
}
}
OutEdges.push_back(llvm::IntrusiveRefCntPtr<Edge>(Edg));
}
CompilationGraph::CompilationGraph() {
NodesMap["root"] = Node(this);
}