本文整理汇总了C++中NominalTypeDecl::getLoc方法的典型用法代码示例。如果您正苦于以下问题:C++ NominalTypeDecl::getLoc方法的具体用法?C++ NominalTypeDecl::getLoc怎么用?C++ NominalTypeDecl::getLoc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NominalTypeDecl
的用法示例。
在下文中一共展示了NominalTypeDecl::getLoc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getConformingContext
ProtocolConformance *ConformanceLookupTable::getConformance(
NominalTypeDecl *nominal,
LazyResolver *resolver,
ConformanceEntry *entry) {
// If we already have a conformance, we're done.
if (auto conformance = entry->getConformance())
return conformance;
ProtocolDecl *protocol = entry->getProtocol();
// Determine where the explicit conformance actually lives.
// FIXME: This is a hack to ensure that inherited conformances are
// always "single step", which is bad for resilience but is assumed
// elsewhere in the compiler.
DeclContext *conformingDC = getConformingContext(nominal, resolver, entry);
if (!conformingDC)
return nullptr;
NominalTypeDecl *conformingNominal
= conformingDC->isNominalTypeOrNominalTypeExtensionContext();
// Form the conformance.
Type type = entry->getDeclContext()->getDeclaredTypeInContext();
ProtocolConformance *conformance;
ASTContext &ctx = nominal->getASTContext();
if (entry->getKind() == ConformanceEntryKind::Inherited) {
// For an inherited conformance, the conforming nominal type will
// be different from the nominal type.
assert(conformingNominal != nominal && "Broken inherited conformance");
// Find the superclass type that matches where the conformance was
// declared.
Type superclassTy = type->getSuperclass(resolver);
while (superclassTy->getAnyNominal() != conformingNominal)
superclassTy = superclassTy->getSuperclass(resolver);
// Look up the inherited conformance.
Module *module = entry->getDeclContext()->getParentModule();
auto inheritedConformance = module->lookupConformance(superclassTy,
protocol,
resolver)
.getPointer();
// Form the inherited conformance.
conformance = ctx.getInheritedConformance(type, inheritedConformance);
} else {
// Create or find the normal conformance.
Type conformingType = conformingDC->getDeclaredTypeInContext();
SourceLoc conformanceLoc
= conformingNominal == conformingDC
? conformingNominal->getLoc()
: cast<ExtensionDecl>(conformingDC)->getLoc();
conformance = ctx.getConformance(conformingType, protocol, conformanceLoc,
conformingDC,
ProtocolConformanceState::Incomplete);
}
// Record the conformance.
entry->Conformance = conformance;
return conformance;
}