mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
PIC: Fix a bug in the code that collects subclasses. We want to collect indirect subclasses as well as direct sub classes.
Swift SVN r20745
This commit is contained in:
@@ -37,17 +37,20 @@ void ClassHierarchyAnalysis::collectSubClasses(ClassDecl *C,
|
||||
std::vector<ClassDecl*> &Sub) {
|
||||
// TODO: Cache this search.
|
||||
assert(Sub.empty() && "Incoming list is not empty");
|
||||
SmallVector<ClassDecl*, 4> Path;
|
||||
for (auto &VT : M->getVTableList()) {
|
||||
ClassDecl *CD = VT.getClass();
|
||||
// Ignore classes that are at the top of the class hierarchy:
|
||||
if (!CD->hasSuperclass())
|
||||
continue;
|
||||
|
||||
// Add the superclass to the list of inherited classes.
|
||||
ClassDecl *Super = CD->getSuperclass()->getClassOrBoundGenericClass();
|
||||
if (Super == C) {
|
||||
Sub.push_back(CD);
|
||||
while (CD->hasSuperclass()) {
|
||||
Path.push_back(CD);
|
||||
// Add the superclass to the list of inherited classes.
|
||||
ClassDecl *Super = CD->getSuperclass()->getClassOrBoundGenericClass();
|
||||
if (Super == C) {
|
||||
Sub.insert(Sub.end(), Path.begin(), Path.end());
|
||||
break;
|
||||
}
|
||||
CD = Super;
|
||||
}
|
||||
Path.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user