-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] [C++26] Implement P2573R2: = delete("should have a reason");
#86526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
98af47e
5ffac60
8dc5f8b
a018c88
b5a50be
e48b80d
9e45341
9fc02a5
7664e7d
41bb3dd
b1c930c
29cdff9
7807c71
f1d7478
40a2330
d6537a2
c1ff133
3445e48
99c8dd1
9df9e9f
b442173
800b643
c12f90e
8602457
8465430
ddd2a2a
bba5a44
b11b6fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1993,21 +1993,35 @@ class FunctionDecl : public DeclaratorDecl, | |
|
||
}; | ||
|
||
/// Stashed information about a defaulted function definition whose body has | ||
/// not yet been lazily generated. | ||
class DefaultedFunctionInfo final | ||
: llvm::TrailingObjects<DefaultedFunctionInfo, DeclAccessPair> { | ||
/// Stashed information about a defaulted/deleted function body. | ||
class DefaultedOrDeletedFunctionInfo final | ||
: llvm::TrailingObjects<DefaultedOrDeletedFunctionInfo, DeclAccessPair, | ||
StringLiteral *> { | ||
friend TrailingObjects; | ||
unsigned NumLookups; | ||
bool HasDeletedMessage; | ||
|
||
size_t numTrailingObjects(OverloadToken<DeclAccessPair>) const { | ||
return NumLookups; | ||
} | ||
|
||
public: | ||
static DefaultedFunctionInfo *Create(ASTContext &Context, | ||
ArrayRef<DeclAccessPair> Lookups); | ||
static DefaultedOrDeletedFunctionInfo * | ||
Create(ASTContext &Context, ArrayRef<DeclAccessPair> Lookups, | ||
StringLiteral *DeletedMessage = nullptr); | ||
|
||
/// Get the unqualified lookup results that should be used in this | ||
/// defaulted function definition. | ||
ArrayRef<DeclAccessPair> getUnqualifiedLookups() const { | ||
return {getTrailingObjects<DeclAccessPair>(), NumLookups}; | ||
} | ||
|
||
StringLiteral *getDeletedMessage() const { | ||
return HasDeletedMessage ? *getTrailingObjects<StringLiteral *>() | ||
: nullptr; | ||
} | ||
|
||
void setDeletedMessage(StringLiteral *Message); | ||
}; | ||
|
||
private: | ||
|
@@ -2017,12 +2031,12 @@ class FunctionDecl : public DeclaratorDecl, | |
ParmVarDecl **ParamInfo = nullptr; | ||
|
||
/// The active member of this union is determined by | ||
/// FunctionDeclBits.HasDefaultedFunctionInfo. | ||
/// FunctionDeclBits.HasDefaultedOrDeletedInfo. | ||
union { | ||
/// The body of the function. | ||
LazyDeclStmtPtr Body; | ||
/// Information about a future defaulted function definition. | ||
DefaultedFunctionInfo *DefaultedInfo; | ||
DefaultedOrDeletedFunctionInfo *DefaultedOrDeletedInfo; | ||
}; | ||
|
||
unsigned ODRHash; | ||
|
@@ -2280,18 +2294,18 @@ class FunctionDecl : public DeclaratorDecl, | |
|
||
/// Returns whether this specific declaration of the function has a body. | ||
bool doesThisDeclarationHaveABody() const { | ||
return (!FunctionDeclBits.HasDefaultedFunctionInfo && Body) || | ||
return (!FunctionDeclBits.HasDefaultedOrDeletedInfo && Body) || | ||
isLateTemplateParsed(); | ||
} | ||
|
||
void setBody(Stmt *B); | ||
void setLazyBody(uint64_t Offset) { | ||
FunctionDeclBits.HasDefaultedFunctionInfo = false; | ||
FunctionDeclBits.HasDefaultedOrDeletedInfo = false; | ||
Body = LazyDeclStmtPtr(Offset); | ||
} | ||
|
||
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info); | ||
DefaultedFunctionInfo *getDefaultedFunctionInfo() const; | ||
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info); | ||
DefaultedOrDeletedFunctionInfo *getDefalutedOrDeletedInfo() const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Sirraide There's no reason we can't change this name to fix this typo right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That can be fixed as NFC commit. I missed it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah, my bad, yeah, that should just be a NFC fix. |
||
|
||
/// Whether this function is variadic. | ||
bool isVariadic() const; | ||
|
@@ -2494,7 +2508,7 @@ class FunctionDecl : public DeclaratorDecl, | |
return FunctionDeclBits.IsDeleted && !isDefaulted(); | ||
} | ||
|
||
void setDeletedAsWritten(bool D = true) { FunctionDeclBits.IsDeleted = D; } | ||
void setDeletedAsWritten(bool D = true, StringLiteral *Message = nullptr); | ||
|
||
/// Determines whether this function is "main", which is the | ||
/// entry point into an executable program. | ||
|
@@ -2650,6 +2664,13 @@ class FunctionDecl : public DeclaratorDecl, | |
AC.push_back(TRC); | ||
} | ||
|
||
/// Get the message that indicates why this function was deleted. | ||
StringLiteral *getDeletedMessage() const { | ||
return FunctionDeclBits.HasDefaultedOrDeletedInfo | ||
? DefaultedOrDeletedInfo->getDeletedMessage() | ||
: nullptr; | ||
} | ||
|
||
void setPreviousDeclaration(FunctionDecl * PrevDecl); | ||
|
||
FunctionDecl *getCanonicalDecl() override; | ||
|
Uh oh!
There was an error while loading. Please reload this page.