Fix crash bug when replacing a definition with a definition that has no uses.

TEST=vm/intermediate_language_test.cc
Review URL: https://chromiumcodereview.appspot.com//10826299

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10630 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
fschneider@google.com
2012-08-14 11:18:48 +00:00
parent 5f0160badc
commit 2b3ea645f3
2 changed files with 11 additions and 2 deletions
+5 -2
View File
@@ -312,9 +312,12 @@ void Definition::ReplaceUsesWith(Definition* other) {
}
current->definition_ = other;
current->next_use_ = other->use_list();
other->use_list()->previous_use_ = current;
if (other->use_list() != NULL) {
current->next_use_ = other->use_list();
other->use_list()->previous_use_ = current;
}
other->set_use_list(head);
set_use_list(NULL);
}
+6
View File
@@ -39,6 +39,12 @@ TEST_CASE(DefUseTests) {
BindInstr* bind = new BindInstr(BindInstr::kUsed, use2);
bind->RemoveInputUses();
EXPECT(def1->use_list() == NULL);
// Test replacing with a definition without uses.
UseVal* use4 = new UseVal(def2);
def2->ReplaceUsesWith(def1);
EXPECT(def1->use_list() == use4);
EXPECT(def2->use_list() == NULL);
EXPECT(use4->definition() == def1);
}
} // namespace dart