本文整理汇总了C++中NominalTypeDecl::getLocalConformances方法的典型用法代码示例。如果您正苦于以下问题:C++ NominalTypeDecl::getLocalConformances方法的具体用法?C++ NominalTypeDecl::getLocalConformances怎么用?C++ NominalTypeDecl::getLocalConformances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NominalTypeDecl
的用法示例。
在下文中一共展示了NominalTypeDecl::getLocalConformances方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectSynthesizedExtensionInfoForProtocol
std::unique_ptr<ExtensionInfoMap>
collectSynthesizedExtensionInfo(MergeGroupVector &AllGroups) {
if (isa<ProtocolDecl>(Target)) {
return collectSynthesizedExtensionInfoForProtocol(AllGroups);
}
std::unique_ptr<ExtensionInfoMap> InfoMap(new ExtensionInfoMap());
ExtensionMergeInfoMap MergeInfoMap;
std::vector<NominalTypeDecl*> Unhandled;
auto handleExtension = [&](ExtensionDecl *E, bool Synthesized,
ExtensionDecl *EnablingE,
NormalProtocolConformance *Conf) {
if (Options.shouldPrint(E)) {
auto Pair = isApplicable(E, Synthesized, EnablingE, Conf);
if (Pair.first) {
InfoMap->insert({E, Pair.first});
MergeInfoMap.insert({E, Pair.second});
}
}
};
for (auto *Conf : Target->getLocalConformances()) {
Unhandled.push_back(Conf->getProtocol());
}
if (auto *CD = dyn_cast<ClassDecl>(Target)) {
if (auto Super = CD->getSuperclassDecl())
Unhandled.push_back(Super);
}
while (!Unhandled.empty()) {
NominalTypeDecl* Back = Unhandled.back();
Unhandled.pop_back();
for (ExtensionDecl *E : Back->getExtensions()) {
handleExtension(E, true, nullptr, nullptr);
}
for (auto *Conf : Back->getLocalConformances()) {
Unhandled.push_back(Conf->getProtocol());
}
if (auto *CD = dyn_cast<ClassDecl>(Back)) {
if (auto Super = CD->getSuperclass())
Unhandled.push_back(Super->getAnyNominal());
}
}
// Merge with actual extensions.
for (auto *EnablingE : Target->getExtensions()) {
handleExtension(EnablingE, false, nullptr, nullptr);
for (auto *Conf : EnablingE->getLocalConformances()) {
for (auto E : Conf->getProtocol()->getExtensions())
handleExtension(E, true, EnablingE, Conf->getRootNormalConformance());
}
}
populateMergeGroup(*InfoMap, MergeInfoMap, AllGroups,
/*AllowMergeWithDefBody*/true);
std::sort(AllGroups.begin(), AllGroups.end());
for (auto &Group : AllGroups) {
Group.removeUnfavored(Target);
Group.sortMembers();
}
AllGroups.erase(std::remove_if(AllGroups.begin(), AllGroups.end(),
[](ExtensionMergeGroup &Group) { return Group.Members.empty(); }),
AllGroups.end());
return InfoMap;
}