Skip to content

Commit 625c9f5

Browse files
authored
Merge pull request #7745 from apple/merging-b120fe8d3288-manually
Merge commit 'b120fe8d3288' from llvm.org/main into next
2 parents 0d62e52 + d49fe3f commit 625c9f5

File tree

11 files changed

+46
-67
lines changed

11 files changed

+46
-67
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,28 +4059,6 @@ class EnumDecl : public TagDecl {
40594059
static bool classofKind(Kind K) { return K == Enum; }
40604060
};
40614061

4062-
/// Enum that represents the different ways arguments are passed to and
4063-
/// returned from function calls. This takes into account the target-specific
4064-
/// and version-specific rules along with the rules determined by the
4065-
/// language.
4066-
enum class ArgPassingKind {
4067-
/// The argument of this type can be passed directly in registers.
4068-
CanPassInRegs,
4069-
4070-
/// The argument of this type cannot be passed directly in registers.
4071-
/// Records containing this type as a subobject are not forced to be passed
4072-
/// indirectly. This value is used only in C++. This value is required by
4073-
/// C++ because, in uncommon situations, it is possible for a class to have
4074-
/// only trivial copy/move constructors even when one of its subobjects has
4075-
/// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
4076-
/// constructor in the derived class is deleted).
4077-
CannotPassInRegs,
4078-
4079-
/// The argument of this type cannot be passed directly in registers.
4080-
/// Records containing this type as a subobject are forced to be passed
4081-
/// indirectly.
4082-
CanNeverPassInRegs
4083-
};
40844062

40854063
/// Represents a struct/union/class. For example:
40864064
/// struct X; // Forward declaration, no "body".
@@ -4092,28 +4070,6 @@ class RecordDecl : public TagDecl {
40924070
public:
40934071
friend class DeclContext;
40944072
friend class ASTDeclReader;
4095-
/// Enum that represents the different ways arguments are passed to and
4096-
/// returned from function calls. This takes into account the target-specific
4097-
/// and version-specific rules along with the rules determined by the
4098-
/// language.
4099-
enum ArgPassingKind : unsigned {
4100-
/// The argument of this type can be passed directly in registers.
4101-
APK_CanPassInRegs,
4102-
4103-
/// The argument of this type cannot be passed directly in registers.
4104-
/// Records containing this type as a subobject are not forced to be passed
4105-
/// indirectly. This value is used only in C++. This value is required by
4106-
/// C++ because, in uncommon situations, it is possible for a class to have
4107-
/// only trivial copy/move constructors even when one of its subobjects has
4108-
/// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
4109-
/// constructor in the derived class is deleted).
4110-
APK_CannotPassInRegs,
4111-
4112-
/// The argument of this type cannot be passed directly in registers.
4113-
/// Records containing this type as a subobject are forced to be passed
4114-
/// indirectly.
4115-
APK_CanNeverPassInRegs
4116-
};
41174073

41184074
protected:
41194075
RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
@@ -4238,15 +4194,15 @@ class RecordDecl : public TagDecl {
42384194
/// it must have at least one trivial, non-deleted copy or move constructor.
42394195
/// FIXME: This should be set as part of completeDefinition.
42404196
bool canPassInRegisters() const {
4241-
return getArgPassingRestrictions() == APK_CanPassInRegs;
4197+
return getArgPassingRestrictions() == ArgPassingKind::CanPassInRegs;
42424198
}
42434199

42444200
ArgPassingKind getArgPassingRestrictions() const {
42454201
return static_cast<ArgPassingKind>(RecordDeclBits.ArgPassingRestrictions);
42464202
}
42474203

42484204
void setArgPassingRestrictions(ArgPassingKind Kind) {
4249-
RecordDeclBits.ArgPassingRestrictions = Kind;
4205+
RecordDeclBits.ArgPassingRestrictions = llvm::to_underlying(Kind);
42504206
}
42514207

42524208
bool isParamDestroyedInCallee() const {

clang/include/clang/AST/DeclBase.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,29 @@ enum class OMPDeclareReductionInitKind;
14031403
enum class ObjCImplementationControl;
14041404
enum class LinkageSpecLanguageIDs;
14051405

1406+
/// Enum that represents the different ways arguments are passed to and
1407+
/// returned from function calls. This takes into account the target-specific
1408+
/// and version-specific rules along with the rules determined by the
1409+
/// language.
1410+
enum class ArgPassingKind {
1411+
/// The argument of this type can be passed directly in registers.
1412+
CanPassInRegs,
1413+
1414+
/// The argument of this type cannot be passed directly in registers.
1415+
/// Records containing this type as a subobject are not forced to be passed
1416+
/// indirectly. This value is used only in C++. This value is required by
1417+
/// C++ because, in uncommon situations, it is possible for a class to have
1418+
/// only trivial copy/move constructors even when one of its subobjects has
1419+
/// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
1420+
/// constructor in the derived class is deleted).
1421+
CannotPassInRegs,
1422+
1423+
/// The argument of this type cannot be passed directly in registers.
1424+
/// Records containing this type as a subobject are forced to be passed
1425+
/// indirectly.
1426+
CanNeverPassInRegs
1427+
};
1428+
14061429
/// DeclContext - This is used only as base class of specific decl types that
14071430
/// can act as declaration contexts. These decls are (only the top classes
14081431
/// that directly derive from DeclContext are mentioned, not their subclasses):

clang/lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4933,7 +4933,7 @@ RecordDecl::RecordDecl(Kind DK, TagKind TK, const ASTContext &C,
49334933
setHasNonTrivialToPrimitiveDestructCUnion(false);
49344934
setHasNonTrivialToPrimitiveCopyCUnion(false);
49354935
setParamDestroyedInCallee(false);
4936-
setArgPassingRestrictions(APK_CanPassInRegs);
4936+
setArgPassingRestrictions(ArgPassingKind::CanPassInRegs);
49374937
setIsRandomized(false);
49384938
setODRHash(0);
49394939
}

clang/lib/AST/DeclCXX.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier const * const *Bases,
446446
setHasVolatileMember(true);
447447

448448
if (BaseClassDecl->getArgPassingRestrictions() ==
449-
RecordDecl::APK_CanNeverPassInRegs)
450-
setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
449+
ArgPassingKind::CanNeverPassInRegs)
450+
setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
451451

452452
// Keep track of the presence of mutable fields.
453453
if (BaseClassDecl->hasMutableFields())
@@ -1032,7 +1032,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
10321032

10331033
// Structs with __weak fields should never be passed directly.
10341034
if (LT == Qualifiers::OCL_Weak)
1035-
setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
1035+
setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
10361036

10371037
Data.HasIrrelevantDestructor = false;
10381038

@@ -1064,7 +1064,7 @@ void CXXRecordDecl::addedMember(Decl *D) {
10641064
Data.HasTrivialSpecialMembers &=
10651065
~(SMF_CopyConstructor | SMF_MoveConstructor |
10661066
SMF_CopyAssignment | SMF_MoveAssignment);
1067-
setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
1067+
setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
10681068

10691069
// Copy/move constructors/assignment operators of a union are deleted by
10701070
// default if it has an address-discriminated ptrauth field.
@@ -1253,8 +1253,8 @@ void CXXRecordDecl::addedMember(Decl *D) {
12531253
if (FieldRec->hasVolatileMember())
12541254
setHasVolatileMember(true);
12551255
if (FieldRec->getArgPassingRestrictions() ==
1256-
RecordDecl::APK_CanNeverPassInRegs)
1257-
setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
1256+
ArgPassingKind::CanNeverPassInRegs)
1257+
setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
12581258

12591259
// C++0x [class]p7:
12601260
// A standard-layout class is a class that:

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2727,7 +2727,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
27272727

27282728
auto *Decl = ParamType->getAsRecordDecl();
27292729
if (CodeGenOpts.PassByValueIsNoAlias && Decl &&
2730-
Decl->getArgPassingRestrictions() == RecordDecl::APK_CanPassInRegs)
2730+
Decl->getArgPassingRestrictions() == ArgPassingKind::CanPassInRegs)
27312731
// When calling the function, the pointer passed in will be the only
27322732
// reference to the underlying object. Mark it accordingly.
27332733
Attrs.addAttribute(llvm::Attribute::NoAlias);

clang/lib/Sema/SemaDecl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19222,13 +19222,13 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
1922219222

1922319223
if (const auto *RT = FT->getAs<RecordType>()) {
1922419224
if (RT->getDecl()->getArgPassingRestrictions() ==
19225-
RecordDecl::APK_CanNeverPassInRegs)
19226-
Record->setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
19225+
ArgPassingKind::CanNeverPassInRegs)
19226+
Record->setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
1922719227
} else if (FT.getQualifiers().getObjCLifetime() == Qualifiers::OCL_Weak) {
19228-
Record->setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
19228+
Record->setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
1922919229
} else if (PointerAuthQualifier Q = FT.getPointerAuth()) {
1923019230
if (Q.isAddressDiscriminated())
19231-
Record->setArgPassingRestrictions(RecordDecl::APK_CanNeverPassInRegs);
19231+
Record->setArgPassingRestrictions(ArgPassingKind::CanNeverPassInRegs);
1923219232
}
1923319233
}
1923419234

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7280,11 +7280,11 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) {
72807280
bool CanPass = canPassInRegisters(*this, Record, CCK);
72817281

72827282
// Do not change ArgPassingRestrictions if it has already been set to
7283-
// APK_CanNeverPassInRegs.
7284-
if (Record->getArgPassingRestrictions() != RecordDecl::APK_CanNeverPassInRegs)
7283+
// ArgPassingKind::CanNeverPassInRegs.
7284+
if (Record->getArgPassingRestrictions() != ArgPassingKind::CanNeverPassInRegs)
72857285
Record->setArgPassingRestrictions(CanPass
7286-
? RecordDecl::APK_CanPassInRegs
7287-
: RecordDecl::APK_CannotPassInRegs);
7286+
? ArgPassingKind::CanPassInRegs
7287+
: ArgPassingKind::CannotPassInRegs);
72887288

72897289
// If canPassInRegisters returns true despite the record having a non-trivial
72907290
// destructor, the record is destructed in the callee. This happens only when

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) {
845845
RD->setHasNonTrivialToPrimitiveDestructCUnion(Record.readInt());
846846
RD->setHasNonTrivialToPrimitiveCopyCUnion(Record.readInt());
847847
RD->setParamDestroyedInCallee(Record.readInt());
848-
RD->setArgPassingRestrictions((RecordDecl::ArgPassingKind)Record.readInt());
848+
RD->setArgPassingRestrictions((ArgPassingKind)Record.readInt());
849849
return Redecl;
850850
}
851851

@@ -4517,7 +4517,7 @@ void ASTDeclReader::UpdateDecl(Decl *D,
45174517
!Reader.PendingFakeDefinitionData.count(OldDD));
45184518
RD->setParamDestroyedInCallee(Record.readInt());
45194519
RD->setArgPassingRestrictions(
4520-
(RecordDecl::ArgPassingKind)Record.readInt());
4520+
static_cast<ArgPassingKind>(Record.readInt()));
45214521
ReadCXXRecordDefinition(RD, /*Update*/true);
45224522

45234523
// Visible update is handled separately.

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5293,7 +5293,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
52935293
auto *RD = cast<CXXRecordDecl>(D);
52945294
UpdatedDeclContexts.insert(RD->getPrimaryContext());
52955295
Record.push_back(RD->isParamDestroyedInCallee());
5296-
Record.push_back(RD->getArgPassingRestrictions());
5296+
Record.push_back(llvm::to_underlying(RD->getArgPassingRestrictions()));
52975297
Record.AddCXXDefinitionData(RD);
52985298
Record.AddOffset(WriteDeclContextLexicalBlock(
52995299
*Context, const_cast<CXXRecordDecl *>(RD)));

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
522522
Record.push_back(D->hasNonTrivialToPrimitiveDestructCUnion());
523523
Record.push_back(D->hasNonTrivialToPrimitiveCopyCUnion());
524524
Record.push_back(D->isParamDestroyedInCallee());
525-
Record.push_back(D->getArgPassingRestrictions());
525+
Record.push_back(llvm::to_underlying(D->getArgPassingRestrictions()));
526526
// Only compute this for C/Objective-C, in C++ this is computed as part
527527
// of CXXRecordDecl.
528528
if (!isa<CXXRecordDecl>(D))

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
19291929
m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
19301930
if (record_decl)
19311931
record_decl->setArgPassingRestrictions(
1932-
clang::RecordDecl::APK_CannotPassInRegs);
1932+
clang::ArgPassingKind::CannotPassInRegs);
19331933
}
19341934
return type_sp;
19351935
}

0 commit comments

Comments
 (0)