liberty/lib/Devirt/DevirtualizationAnalysis.cpp
// Check ty1 is a subclass of ty2
Check ty1 is a subclass of ty2
Check ty1 is a subclass of ty2
bool DevirtualizationAnalysis::isPotentialSubClass(StructType *ty1, StructType *ty2){
  const unsigned N = ty1->getNumElements();
  for (unsigned i = 0; i < N; ++i){
    Type *elm = ty1->getElementType(i);
    if (areStructurallyEquivalentTransitively(elm, ty2))
      return true;
    if (StructType *structelm = dyn_cast<StructType>(elm))
      if (isPotentialSubClass(structelm, ty2))
        return true;
  }
  return false;
}
bool DevirtualizationAnalysis :: isPotentialSubClass ( StructType * ty1 , StructType * ty2 ) { const unsigned N = ty1 -> getNumElements ( ) ; for ( unsigned i = 0 ; i < N ; ++ i ) { Type * elm = ty1 -> getElementType ( i ) ; if ( areStructurallyEquivalentTransitively ( elm , ty2 ) ) return true ; if ( StructType * structelm = dyn_cast < StructType > ( elm ) ) if ( isPotentialSubClass ( structelm , ty2 ) ) return true ; } return false ; }
Check ty1 is a subclass of ty2
Check ty1 is a subclass of ty2
// Ziyang (Feb 19): // Step 1: check whether ty2 is equivalent (remove tail) to any element of ty1 // Step 2: recuisively check whether any element of ty1 is a subclass of ty2 // elm is a subclass of ty2