Perform a dynamic method call if a class has objc ancestry in speculative devirt as fallback.

If a class has an @objc ancestry this class can be dynamically overridden and
therefore we don't know the default case even if we see the full class
hierarchy.

rdar://23228386
This commit is contained in:
Arnold Schwaighofer
2016-02-01 11:25:18 -08:00
parent ef9bd1ca90
commit f6866b4ae7
2 changed files with 60 additions and 0 deletions

View File

@@ -217,6 +217,13 @@ static bool isDefaultCaseKnown(ClassHierarchyAnalysis *CHA,
if (CD->isFinal())
return true;
// If the class has an @objc ancestry it can be dynamically subclassed and we
// can't therefore statically know the default case.
auto Ancestry = CD->checkObjCAncestry();
if (Ancestry != ObjCClassKind::NonObjC &&
Ancestry != ObjCClassKind::ObjCMembers)
return false;
// Without an associated context we cannot perform any
// access-based optimizations.
if (!DC)