本文整理汇总了C++中NominalTypeDecl::getAllConformances方法的典型用法代码示例。如果您正苦于以下问题:C++ NominalTypeDecl::getAllConformances方法的具体用法?C++ NominalTypeDecl::getAllConformances怎么用?C++ NominalTypeDecl::getAllConformances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NominalTypeDecl
的用法示例。
在下文中一共展示了NominalTypeDecl::getAllConformances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lookupDeclsFromProtocolsBeingConformedTo
static void lookupDeclsFromProtocolsBeingConformedTo(
Type BaseTy, VisibleDeclConsumer &Consumer, LookupState LS,
const DeclContext *FromContext, DeclVisibilityKind Reason,
LazyResolver *TypeResolver, VisitedSet &Visited) {
NominalTypeDecl *CurrNominal = BaseTy->getAnyNominal();
if (!CurrNominal)
return;
for (auto Conformance : CurrNominal->getAllConformances()) {
auto Proto = Conformance->getProtocol();
if (!Proto->isAccessibleFrom(FromContext))
continue;
DeclVisibilityKind ReasonForThisProtocol;
if (Reason == DeclVisibilityKind::MemberOfCurrentNominal)
ReasonForThisProtocol =
DeclVisibilityKind::MemberOfProtocolImplementedByCurrentNominal;
else
ReasonForThisProtocol = getReasonForSuper(Reason);
auto NormalConformance = Conformance->getRootNormalConformance();
for (auto Member : Proto->getMembers()) {
if (auto *ATD = dyn_cast<AssociatedTypeDecl>(Member)) {
// Skip type decls if they aren't visible, or any type that has a
// witness. This cuts down on duplicates.
if (areTypeDeclsVisibleInLookupMode(LS) &&
!NormalConformance->hasTypeWitness(ATD)) {
Consumer.foundDecl(ATD, ReasonForThisProtocol);
}
continue;
}
if (auto *VD = dyn_cast<ValueDecl>(Member)) {
if (TypeResolver) {
TypeResolver->resolveDeclSignature(VD);
if (!NormalConformance->hasWitness(VD) &&
(Conformance->getDeclContext()->getParentSourceFile() !=
FromContext->getParentSourceFile()))
TypeResolver->resolveWitness(NormalConformance, VD);
}
// Skip value requirements that have corresponding witnesses. This cuts
// down on duplicates.
if (!NormalConformance->hasWitness(VD) ||
!NormalConformance->getWitness(VD, nullptr) ||
NormalConformance->getWitness(VD, nullptr).getDecl()->getFullName()
!= VD->getFullName()) {
Consumer.foundDecl(VD, ReasonForThisProtocol);
}
}
}
// Add members from any extensions.
SmallVector<ValueDecl *, 2> FoundDecls;
doGlobalExtensionLookup(BaseTy, Proto->getDeclaredType(), FoundDecls,
FromContext, LS, ReasonForThisProtocol,
TypeResolver);
for (auto *VD : FoundDecls)
Consumer.foundDecl(VD, ReasonForThisProtocol);
}
}