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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20692 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-03-19 21:02:12 +00:00
parent 6782397046
commit 1f377fefb7

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;
}