if (replace_to->last_use_ == NULL) {
DCHECK_EQ(NULL, replace_to->first_use_);
replace_to->first_use_ = first_use_;
- } else {
+ replace_to->last_use_ = last_use_;
+ } else if (first_use_ != NULL) {
DCHECK_NE(NULL, replace_to->first_use_);
replace_to->last_use_->next = first_use_;
first_use_->prev = replace_to->last_use_;
+ replace_to->last_use_ = last_use_;
}
- replace_to->last_use_ = last_use_;
replace_to->use_count_ += use_count_;
use_count_ = 0;
first_use_ = NULL;
TEST(NodeUseIteratorReplaceNoUses) {
GraphTester graph;
Node* n0 = graph.NewNode(&dummy_operator);
- Node* n3 = graph.NewNode(&dummy_operator);
- n0->ReplaceUses(n3);
+ Node* n1 = graph.NewNode(&dummy_operator);
+ Node* n2 = graph.NewNode(&dummy_operator);
+ Node* n3 = graph.NewNode(&dummy_operator, n2);
+ n0->ReplaceUses(n1);
+ CHECK(n0->uses().begin() == n0->uses().end());
+ n0->ReplaceUses(n2);
CHECK(n0->uses().begin() == n0->uses().end());
+ USE(n3);
}