mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add support for parsing @lifetime attribute to specify lifetime dependencies on declarations
This commit is contained in:
@@ -2011,6 +2011,8 @@ StringRef DeclAttribute::getAttrName() const {
|
||||
} else {
|
||||
return "_allowFeatureSuppression";
|
||||
}
|
||||
case DeclAttrKind::Lifetime:
|
||||
return "lifetime";
|
||||
}
|
||||
llvm_unreachable("bad DeclAttrKind");
|
||||
}
|
||||
@@ -3040,6 +3042,24 @@ AllowFeatureSuppressionAttr *AllowFeatureSuppressionAttr::create(
|
||||
AllowFeatureSuppressionAttr(atLoc, range, implicit, inverted, features);
|
||||
}
|
||||
|
||||
LifetimeAttr::LifetimeAttr(SourceLoc atLoc, SourceRange baseRange,
|
||||
bool implicit,
|
||||
ArrayRef<LifetimeDependenceSpecifier> entries)
|
||||
: DeclAttribute(DeclAttrKind::Lifetime, atLoc, baseRange, implicit),
|
||||
NumEntries(entries.size()) {
|
||||
std::copy(entries.begin(), entries.end(),
|
||||
getTrailingObjects<LifetimeDependenceSpecifier>());
|
||||
}
|
||||
|
||||
LifetimeAttr *
|
||||
LifetimeAttr::create(ASTContext &context, SourceLoc atLoc,
|
||||
SourceRange baseRange, bool implicit,
|
||||
ArrayRef<LifetimeDependenceSpecifier> entries) {
|
||||
unsigned size = totalSizeToAlloc<LifetimeDependenceSpecifier>(entries.size());
|
||||
void *mem = context.Allocate(size, alignof(LifetimeDependenceSpecifier));
|
||||
return new (mem) LifetimeAttr(atLoc, baseRange, implicit, entries);
|
||||
}
|
||||
|
||||
void swift::simple_display(llvm::raw_ostream &out, const DeclAttribute *attr) {
|
||||
if (attr)
|
||||
attr->print(out);
|
||||
|
||||
Reference in New Issue
Block a user