ABI checker: include a field to indicate whether a decl is from extension

This commit is contained in:
Xi Ge
2022-06-03 11:23:15 -07:00
parent ee312bc1e2
commit 26952f74de
6 changed files with 37 additions and 5 deletions

View File

@@ -109,6 +109,7 @@ SDKNodeDecl::SDKNodeDecl(SDKNodeInitInfo Info, SDKNodeKind Kind)
IsOverriding(Info.IsOverriding),
IsOpen(Info.IsOpen),
IsInternal(Info.IsInternal), IsABIPlaceholder(Info.IsABIPlaceholder),
IsFromExtension(Info.IsFromExtension),
ReferenceOwnership(uint8_t(Info.ReferenceOwnership)),
GenericSig(Info.GenericSig),
SugaredGenericSig(Info.SugaredGenericSig),
@@ -1376,6 +1377,13 @@ StringRef SDKContext::getInitKind(Decl *D) {
return StringRef();
}
static bool isDeclaredInExtension(Decl *D) {
if (auto *DC = D->getDeclContext()->getAsDecl()) {
return isa<ExtensionDecl>(DC);
}
return false;
}
SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, Decl *D):
Ctx(Ctx), DKind(D->getKind()), Loc(D->getLoc()),
Location(calculateLocation(Ctx, D)),
@@ -1394,6 +1402,7 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, Decl *D):
IsImplicit(D->isImplicit()),
IsDeprecated(D->getAttrs().getDeprecated(D->getASTContext())),
IsABIPlaceholder(isABIPlaceholderRecursive(D)),
IsFromExtension(isDeclaredInExtension(D)),
DeclAttrs(collectDeclAttributes(D)) {}
SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, OperatorDecl *OD):
@@ -2040,6 +2049,7 @@ void SDKNodeDecl::jsonize(json::Output &out) {
uint8_t Raw = uint8_t(getReferenceOwnership());
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_ownership).data(), Raw);
}
output(out, KeyKind::KK_isFromExtension, IsFromExtension);
}
void SDKNodeDeclAbstractFunc::jsonize(json::Output &out) {