Merge pull request #82354 from meg-gupta/lifetimeenum

Add lifetime dependencies on function types representing ~Escapable enum elements with ~Escapable payloads
This commit is contained in:
Meghana Gupta
2025-06-23 22:07:38 -07:00
committed by GitHub
12 changed files with 272 additions and 36 deletions

View File

@@ -8779,7 +8779,8 @@ public:
/// EnumCaseDecl.
class EnumElementDecl : public DeclContext, public ValueDecl {
friend class EnumRawValuesRequest;
friend class LifetimeDependenceInfoRequest;
/// This is the type specified with the enum element, for
/// example 'Int' in 'case Y(Int)'. This is null if there is no type
/// associated with this element, as in 'case Z' or in all elements of enum
@@ -8791,6 +8792,11 @@ class EnumElementDecl : public DeclContext, public ValueDecl {
/// The raw value literal for the enum element, or null.
LiteralExpr *RawValueExpr;
protected:
struct {
unsigned NoLifetimeDependenceInfo : 1;
} LazySemanticInfo = {};
public:
EnumElementDecl(SourceLoc IdentifierLoc, DeclName Name,
ParameterList *Params,

View File

@@ -324,8 +324,7 @@ public:
/// Builds LifetimeDependenceInfo from a swift decl, either from the explicit
/// lifetime dependence specifiers or by inference based on types and
/// ownership modifiers.
static std::optional<ArrayRef<LifetimeDependenceInfo>>
get(AbstractFunctionDecl *decl);
static std::optional<ArrayRef<LifetimeDependenceInfo>> get(ValueDecl *decl);
/// Builds LifetimeDependenceInfo from SIL
static std::optional<llvm::ArrayRef<LifetimeDependenceInfo>>

View File

@@ -5114,8 +5114,7 @@ public:
class LifetimeDependenceInfoRequest
: public SimpleRequest<
LifetimeDependenceInfoRequest,
std::optional<llvm::ArrayRef<LifetimeDependenceInfo>>(
AbstractFunctionDecl *),
std::optional<llvm::ArrayRef<LifetimeDependenceInfo>>(ValueDecl *),
RequestFlags::SeparatelyCached | RequestFlags::SplitCached> {
public:
using SimpleRequest::SimpleRequest;
@@ -5124,7 +5123,7 @@ private:
friend SimpleRequest;
std::optional<llvm::ArrayRef<LifetimeDependenceInfo>>
evaluate(Evaluator &evaluator, AbstractFunctionDecl *AFD) const;
evaluate(Evaluator &evaluator, ValueDecl *AFD) const;
public:
// Separate caching.