Two fixes for the copy ctor/operator=:

1. Make sure to clear() 'this' before adding elements to it
  2. Make sure that the leaders of the RHS EC are the leaders of the LHS EC.

llvm-svn: 20692
This commit is contained in:
Chris Lattner 2005-03-19 21:02:12 +00:00
parent 325f234d79
commit 300dc0bc90
1 changed files with 7 additions and 4 deletions

View File

@ -118,11 +118,14 @@ public:
}
const EquivalenceClasses &operator=(const EquivalenceClasses &RHS) {
TheMapping.clear();
for (iterator I = RHS.begin(), E = RHS.end(); I != E; ++I)
if (I->isLeader())
insert(I->getData());
else
unionSets(I->getData(), *RHS.findLeader(I));
if (I->isLeader()) {
member_iterator MI = RHS.member_begin(I);
member_iterator LeaderIt = member_begin(insert(*MI));
for (++MI; MI != member_end(); ++MI)
unionSets(LeaderIt, member_begin(insert(*MI)));
}
return *this;
}