Skip to content

Commit 887bc11

Browse files
committed
ConstExtract: Adopt Decl::getSemanticAvailableAttrs().
1 parent 0288eaa commit 887bc11

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

include/swift/AST/Attr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,6 +3235,7 @@ class SemanticAvailableAttributes {
32353235

32363236
Range::iterator begin() const { return attrRange.begin(); }
32373237
Range::iterator end() const { return attrRange.end(); }
3238+
bool empty() const { return attrRange.empty(); }
32383239
};
32393240

32403241
class alignas(1 << AttrAlignInBits) TypeAttribute

lib/ConstExtract/ConstExtract.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,14 +1242,15 @@ extractBuilderValueIfExists(const swift::NominalTypeDecl *TypeDecl,
12421242
;
12431243
}
12441244

1245-
void writeAttrInformation(llvm::json::OStream &JSON,
1246-
const DeclAttributes &Attrs) {
1247-
auto availableAttr = Attrs.getAttributes<AvailableAttr>();
1248-
if (availableAttr.empty())
1245+
void writeAvailabilityAttributes(llvm::json::OStream &JSON, const Decl &decl) {
1246+
auto semanticAttrs = decl.getSemanticAvailableAttrs();
1247+
if (semanticAttrs.empty())
12491248
return;
12501249

12511250
JSON.attributeArray("availabilityAttributes", [&] {
1252-
for (const AvailableAttr *attr : availableAttr) {
1251+
for (auto semanticAttr : semanticAttrs) {
1252+
auto attr = semanticAttr.getParsedAttr();
1253+
12531254
JSON.object([&] {
12541255
if (!attr->platformString().empty())
12551256
JSON.attribute("platform", attr->platformString());
@@ -1370,7 +1371,7 @@ void writeProperties(llvm::json::OStream &JSON,
13701371
}
13711372
writePropertyWrapperAttributes(JSON, PropertyInfo.PropertyWrappers,
13721373
decl->getASTContext());
1373-
writeAttrInformation(JSON, decl->getAttrs());
1374+
writeAvailabilityAttributes(JSON, *decl);
13741375
});
13751376
}
13761377
});
@@ -1450,7 +1451,7 @@ bool writeAsJSONToFile(const std::vector<ConstValueTypeInfo> &ConstValueInfos,
14501451
writeAssociatedTypeAliases(JSON, *NomTypeDecl);
14511452
writeProperties(JSON, TypeInfo, *NomTypeDecl);
14521453
writeEnumCases(JSON, TypeInfo.EnumElements);
1453-
writeAttrInformation(JSON, NomTypeDecl->getAttrs());
1454+
writeAvailabilityAttributes(JSON, *NomTypeDecl);
14541455
});
14551456
}
14561457
});

0 commit comments

Comments
 (0)