forked from OSchip/llvm-project
Adjust r316292 - remove the anonymous union for sharing a bitfield in FunctionDecl.
The anonymous union did NOT save us storage, but instead behaved as if we added an additional integer data member to FunctionDecl. For additional context, the anonymous union renders the bit fields as non-adjacent and prevents them from sharing the same 'memory location' (i.e. bit-storage) by requiring the anonymous union object to be appropriately aligned. This was confirmed through discussion with Richard Smith in Albuquerque (ISO C++ Meeting) https://reviews.llvm.org/rL316292 llvm-svn: 317984
This commit is contained in:
parent
be49c048c1
commit
1f3a2af902
|
@ -1678,17 +1678,17 @@ private:
|
|||
/// skipped.
|
||||
unsigned HasSkippedBody : 1;
|
||||
|
||||
/// Indicates if the function declaration will have a body, once we're done
|
||||
/// parsing it.
|
||||
unsigned WillHaveBody : 1;
|
||||
|
||||
protected:
|
||||
// Since a Deduction Guide [C++17] will never have a body, we can share the
|
||||
// storage, and use a different name.
|
||||
union {
|
||||
/// Indicates if the function declaration will have a body, once we're done
|
||||
/// parsing it.
|
||||
unsigned WillHaveBody : 1;
|
||||
/// Indicates that the Deduction Guide is the implicitly generated 'copy
|
||||
/// deduction candidate' (is used during overload resolution).
|
||||
unsigned IsCopyDeductionCandidate : 1;
|
||||
};
|
||||
/// [C++17] Only used by CXXDeductionGuideDecl. Declared here to avoid
|
||||
/// increasing the size of CXXDeductionGuideDecl by the size of an unsigned
|
||||
/// int as opposed to adding a single bit to FunctionDecl.
|
||||
/// Indicates that the Deduction Guide is the implicitly generated 'copy
|
||||
/// deduction candidate' (is used during overload resolution).
|
||||
unsigned IsCopyDeductionCandidate : 1;
|
||||
private:
|
||||
/// \brief End part of this FunctionDecl's source range.
|
||||
///
|
||||
|
@ -1767,15 +1767,14 @@ protected:
|
|||
DeclContext(DK), redeclarable_base(C), ParamInfo(nullptr), Body(),
|
||||
SClass(S), IsInline(isInlineSpecified),
|
||||
IsInlineSpecified(isInlineSpecified), IsExplicitSpecified(false),
|
||||
IsVirtualAsWritten(false), IsPure(false),
|
||||
HasInheritedPrototype(false), HasWrittenPrototype(true),
|
||||
IsDeleted(false), IsTrivial(false), IsDefaulted(false),
|
||||
IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
|
||||
IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
|
||||
InstantiationIsPending(false),
|
||||
IsVirtualAsWritten(false), IsPure(false), HasInheritedPrototype(false),
|
||||
HasWrittenPrototype(true), IsDeleted(false), IsTrivial(false),
|
||||
IsDefaulted(false), IsExplicitlyDefaulted(false),
|
||||
HasImplicitReturnZero(false), IsLateTemplateParsed(false),
|
||||
IsConstexpr(isConstexprSpecified), InstantiationIsPending(false),
|
||||
UsesSEHTry(false), HasSkippedBody(false), WillHaveBody(false),
|
||||
EndRangeLoc(NameInfo.getEndLoc()), TemplateOrSpecialization(),
|
||||
DNLoc(NameInfo.getInfo()) {}
|
||||
IsCopyDeductionCandidate(false), EndRangeLoc(NameInfo.getEndLoc()),
|
||||
TemplateOrSpecialization(), DNLoc(NameInfo.getInfo()) {}
|
||||
|
||||
typedef Redeclarable<FunctionDecl> redeclarable_base;
|
||||
FunctionDecl *getNextRedeclarationImpl() override {
|
||||
|
|
|
@ -1881,10 +1881,6 @@ private:
|
|||
if (EndLocation.isValid())
|
||||
setRangeEnd(EndLocation);
|
||||
IsExplicitSpecified = IsExplicit;
|
||||
|
||||
// IsCopyDeductionCandidate is a union variant member, so ensure it is the
|
||||
// active member by storing to it.
|
||||
IsCopyDeductionCandidate = false;
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -1863,8 +1863,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
|
|||
|
||||
void ASTDeclReader::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) {
|
||||
VisitFunctionDecl(D);
|
||||
if (Record.readInt())
|
||||
D->setIsCopyDeductionCandidate();
|
||||
D->IsCopyDeductionCandidate = Record.readInt();
|
||||
}
|
||||
|
||||
void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
||||
|
|
|
@ -612,7 +612,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
|
|||
|
||||
void ASTDeclWriter::VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D) {
|
||||
VisitFunctionDecl(D);
|
||||
Record.push_back(D->isCopyDeductionCandidate());
|
||||
Record.push_back(D->IsCopyDeductionCandidate);
|
||||
Code = serialization::DECL_CXX_DEDUCTION_GUIDE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue