AST: Eliminate remaining direct access to AvailableAttr's fields.

Most of the compiler should use SemanticAvailableAttr instead. In contexts like
ASTDumper where a semantic attribute is unavailable use accessors on
AvailableAttr.

NFC.
This commit is contained in:
Allan Shortlidge
2025-01-21 22:54:00 -08:00
parent 1341516dba
commit ba822d1e23
8 changed files with 98 additions and 84 deletions

View File

@@ -3060,35 +3060,37 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
}
case DeclAttrKind::Available: {
auto *theAttr = cast<AvailableAttr>(DA);
ENCODE_VER_TUPLE(Introduced, theAttr->Introduced)
ENCODE_VER_TUPLE(Deprecated, theAttr->Deprecated)
ENCODE_VER_TUPLE(Obsoleted, theAttr->Obsoleted)
auto theAttr = D->getSemanticAvailableAttr(cast<AvailableAttr>(DA));
assert(theAttr);
assert(theAttr->Rename.empty() || !theAttr->hasCachedRenamedDecl());
assert(theAttr->hasCachedDomain());
auto domain = theAttr->getCachedDomain();
ENCODE_VER_TUPLE(Introduced, theAttr->getIntroduced())
ENCODE_VER_TUPLE(Deprecated, theAttr->getDeprecated())
ENCODE_VER_TUPLE(Obsoleted, theAttr->getObsoleted())
assert(theAttr->getRename().empty() ||
!theAttr->getParsedAttr()->hasCachedRenamedDecl());
auto domain = theAttr->getDomain();
// FIXME: [availability] Serialize domain and kind directly.
llvm::SmallString<32> blob;
blob.append(theAttr->Message);
blob.append(theAttr->Rename);
blob.append(theAttr->getMessage());
blob.append(theAttr->getRename());
auto abbrCode = S.DeclTypeAbbrCodes[AvailableDeclAttrLayout::Code];
AvailableDeclAttrLayout::emitRecord(
S.Out, S.ScratchRecord, abbrCode,
theAttr->isImplicit(),
theAttr->getParsedAttr()->isImplicit(),
theAttr->isUnconditionallyUnavailable(),
theAttr->isUnconditionallyDeprecated(),
theAttr->isNoAsync(),
domain->isPackageDescription(),
domain.isPackageDescription(),
theAttr->isSPI(),
domain->isEmbedded(),
domain.isEmbedded(),
LIST_VER_TUPLE_PIECES(Introduced),
LIST_VER_TUPLE_PIECES(Deprecated),
LIST_VER_TUPLE_PIECES(Obsoleted),
static_cast<unsigned>(domain->getPlatformKind()),
theAttr->Message.size(),
theAttr->Rename.size(),
static_cast<unsigned>(domain.getPlatformKind()),
theAttr->getMessage().size(),
theAttr->getRename().size(),
blob);
return;
}