Skip to content

Commit c485722

Browse files
author
git apple-llvm automerger
committed
Merge commit 'a764358a9d86' from llvm.org/main into next
2 parents 3164a37 + a764358 commit c485722

File tree

5 files changed

+115
-97
lines changed

5 files changed

+115
-97
lines changed

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ class StoredDeclsList;
7575
class SwitchCase;
7676
class Token;
7777

78+
namespace serialization {
79+
enum class DeclUpdateKind;
80+
} // namespace serialization
81+
7882
namespace SrcMgr {
7983
class FileInfo;
8084
} // namespace SrcMgr
@@ -374,8 +378,7 @@ class ASTWriter : public ASTDeserializationListener,
374378

375379
/// An update to a Decl.
376380
class DeclUpdate {
377-
/// A DeclUpdateKind.
378-
unsigned Kind;
381+
serialization::DeclUpdateKind Kind;
379382
union {
380383
const Decl *Dcl;
381384
void *Type;
@@ -386,18 +389,21 @@ class ASTWriter : public ASTDeserializationListener,
386389
};
387390

388391
public:
389-
DeclUpdate(unsigned Kind) : Kind(Kind), Dcl(nullptr) {}
390-
DeclUpdate(unsigned Kind, const Decl *Dcl) : Kind(Kind), Dcl(Dcl) {}
391-
DeclUpdate(unsigned Kind, QualType Type)
392+
DeclUpdate(serialization::DeclUpdateKind Kind) : Kind(Kind), Dcl(nullptr) {}
393+
DeclUpdate(serialization::DeclUpdateKind Kind, const Decl *Dcl)
394+
: Kind(Kind), Dcl(Dcl) {}
395+
DeclUpdate(serialization::DeclUpdateKind Kind, QualType Type)
392396
: Kind(Kind), Type(Type.getAsOpaquePtr()) {}
393-
DeclUpdate(unsigned Kind, SourceLocation Loc)
397+
DeclUpdate(serialization::DeclUpdateKind Kind, SourceLocation Loc)
394398
: Kind(Kind), Loc(Loc.getRawEncoding()) {}
395-
DeclUpdate(unsigned Kind, unsigned Val) : Kind(Kind), Val(Val) {}
396-
DeclUpdate(unsigned Kind, Module *M) : Kind(Kind), Mod(M) {}
397-
DeclUpdate(unsigned Kind, const Attr *Attribute)
398-
: Kind(Kind), Attribute(Attribute) {}
399-
400-
unsigned getKind() const { return Kind; }
399+
DeclUpdate(serialization::DeclUpdateKind Kind, unsigned Val)
400+
: Kind(Kind), Val(Val) {}
401+
DeclUpdate(serialization::DeclUpdateKind Kind, Module *M)
402+
: Kind(Kind), Mod(M) {}
403+
DeclUpdate(serialization::DeclUpdateKind Kind, const Attr *Attribute)
404+
: Kind(Kind), Attribute(Attribute) {}
405+
406+
serialization::DeclUpdateKind getKind() const { return Kind; }
401407
const Decl *getDecl() const { return Dcl; }
402408
QualType getType() const { return QualType::getFromOpaquePtr(Type); }
403409

clang/lib/Serialization/ASTCommon.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@ namespace clang {
2222

2323
namespace serialization {
2424

25-
enum DeclUpdateKind {
26-
UPD_CXX_ADDED_IMPLICIT_MEMBER,
27-
UPD_CXX_ADDED_ANONYMOUS_NAMESPACE,
28-
UPD_CXX_ADDED_FUNCTION_DEFINITION,
29-
UPD_CXX_ADDED_VAR_DEFINITION,
30-
UPD_CXX_POINT_OF_INSTANTIATION,
31-
UPD_CXX_INSTANTIATED_CLASS_DEFINITION,
32-
UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT,
33-
UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER,
34-
UPD_CXX_RESOLVED_DTOR_DELETE,
35-
UPD_CXX_RESOLVED_EXCEPTION_SPEC,
36-
UPD_CXX_DEDUCED_RETURN_TYPE,
37-
UPD_DECL_MARKED_USED,
38-
UPD_MANGLING_NUMBER,
39-
UPD_STATIC_LOCAL_NUMBER,
40-
UPD_DECL_MARKED_OPENMP_THREADPRIVATE,
41-
UPD_DECL_MARKED_OPENMP_ALLOCATE,
42-
UPD_DECL_MARKED_OPENMP_DECLARETARGET,
43-
UPD_DECL_EXPORTED,
44-
UPD_ADDED_ATTR_TO_RECORD
25+
enum class DeclUpdateKind {
26+
CXXAddedImplicitMember,
27+
CXXAddedAnonymousNamespace,
28+
CXXAddedFunctionDefinition,
29+
CXXAddedVarDefinition,
30+
CXXPointOfInstantiation,
31+
CXXInstantiatedClassDefinition,
32+
CXXInstantiatedDefaultArgument,
33+
CXXInstantiatedDefaultMemberInitializer,
34+
CXXResolvedDtorDelete,
35+
CXXResolvedExceptionSpec,
36+
CXXDeducedReturnType,
37+
DeclMarkedUsed,
38+
ManglingNumber,
39+
StaticLocalNumber,
40+
DeclMarkedOpenMPThreadPrivate,
41+
DeclMarkedOpenMPAllocate,
42+
DeclMarkedOpenMPDeclareTarget,
43+
DeclExported,
44+
AddedAttrToRecord
4545
};
4646

4747
TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT);

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4691,15 +4691,15 @@ static void forAllLaterRedecls(DeclT *D, Fn F) {
46914691
void ASTDeclReader::UpdateDecl(Decl *D) {
46924692
while (Record.getIdx() < Record.size()) {
46934693
switch ((DeclUpdateKind)Record.readInt()) {
4694-
case UPD_CXX_ADDED_IMPLICIT_MEMBER: {
4694+
case DeclUpdateKind::CXXAddedImplicitMember: {
46954695
auto *RD = cast<CXXRecordDecl>(D);
46964696
Decl *MD = Record.readDecl();
46974697
assert(MD && "couldn't read decl from update record");
46984698
Reader.PendingAddedClassMembers.push_back({RD, MD});
46994699
break;
47004700
}
47014701

4702-
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
4702+
case DeclUpdateKind::CXXAddedAnonymousNamespace: {
47034703
auto *Anon = readDeclAs<NamespaceDecl>();
47044704

47054705
// Each module has its own anonymous namespace, which is disjoint from
@@ -4714,15 +4714,15 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47144714
break;
47154715
}
47164716

4717-
case UPD_CXX_ADDED_VAR_DEFINITION: {
4717+
case DeclUpdateKind::CXXAddedVarDefinition: {
47184718
auto *VD = cast<VarDecl>(D);
47194719
VD->NonParmVarDeclBits.IsInline = Record.readInt();
47204720
VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
47214721
ReadVarDeclInit(VD);
47224722
break;
47234723
}
47244724

4725-
case UPD_CXX_POINT_OF_INSTANTIATION: {
4725+
case DeclUpdateKind::CXXPointOfInstantiation: {
47264726
SourceLocation POI = Record.readSourceLocation();
47274727
if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
47284728
VTSD->setPointOfInstantiation(POI);
@@ -4742,7 +4742,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47424742
break;
47434743
}
47444744

4745-
case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT: {
4745+
case DeclUpdateKind::CXXInstantiatedDefaultArgument: {
47464746
auto *Param = cast<ParmVarDecl>(D);
47474747

47484748
// We have to read the default argument regardless of whether we use it
@@ -4757,7 +4757,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47574757
break;
47584758
}
47594759

4760-
case UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER: {
4760+
case DeclUpdateKind::CXXInstantiatedDefaultMemberInitializer: {
47614761
auto *FD = cast<FieldDecl>(D);
47624762
auto *DefaultInit = Record.readExpr();
47634763

@@ -4774,7 +4774,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47744774
break;
47754775
}
47764776

4777-
case UPD_CXX_ADDED_FUNCTION_DEFINITION: {
4777+
case DeclUpdateKind::CXXAddedFunctionDefinition: {
47784778
auto *FD = cast<FunctionDecl>(D);
47794779
if (Reader.PendingBodies[FD]) {
47804780
// FIXME: Maybe check for ODR violations.
@@ -4796,7 +4796,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47964796
break;
47974797
}
47984798

4799-
case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
4799+
case DeclUpdateKind::CXXInstantiatedClassDefinition: {
48004800
auto *RD = cast<CXXRecordDecl>(D);
48014801
auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
48024802
bool HadRealDefinition =
@@ -4857,7 +4857,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
48574857
break;
48584858
}
48594859

4860-
case UPD_CXX_RESOLVED_DTOR_DELETE: {
4860+
case DeclUpdateKind::CXXResolvedDtorDelete: {
48614861
// Set the 'operator delete' directly to avoid emitting another update
48624862
// record.
48634863
auto *Del = readDeclAs<FunctionDecl>();
@@ -4871,7 +4871,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
48714871
break;
48724872
}
48734873

4874-
case UPD_CXX_RESOLVED_EXCEPTION_SPEC: {
4874+
case DeclUpdateKind::CXXResolvedExceptionSpec: {
48754875
SmallVector<QualType, 8> ExceptionStorage;
48764876
auto ESI = Record.readExceptionSpecInfo(ExceptionStorage);
48774877

@@ -4893,35 +4893,35 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
48934893
break;
48944894
}
48954895

4896-
case UPD_CXX_DEDUCED_RETURN_TYPE: {
4896+
case DeclUpdateKind::CXXDeducedReturnType: {
48974897
auto *FD = cast<FunctionDecl>(D);
48984898
QualType DeducedResultType = Record.readType();
48994899
Reader.PendingDeducedTypeUpdates.insert(
49004900
{FD->getCanonicalDecl(), DeducedResultType});
49014901
break;
49024902
}
49034903

4904-
case UPD_DECL_MARKED_USED:
4904+
case DeclUpdateKind::DeclMarkedUsed:
49054905
// Maintain AST consistency: any later redeclarations are used too.
49064906
D->markUsed(Reader.getContext());
49074907
break;
49084908

4909-
case UPD_MANGLING_NUMBER:
4909+
case DeclUpdateKind::ManglingNumber:
49104910
Reader.getContext().setManglingNumber(cast<NamedDecl>(D),
49114911
Record.readInt());
49124912
break;
49134913

4914-
case UPD_STATIC_LOCAL_NUMBER:
4914+
case DeclUpdateKind::StaticLocalNumber:
49154915
Reader.getContext().setStaticLocalNumber(cast<VarDecl>(D),
49164916
Record.readInt());
49174917
break;
49184918

4919-
case UPD_DECL_MARKED_OPENMP_THREADPRIVATE:
4919+
case DeclUpdateKind::DeclMarkedOpenMPThreadPrivate:
49204920
D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(Reader.getContext(),
49214921
readSourceRange()));
49224922
break;
49234923

4924-
case UPD_DECL_MARKED_OPENMP_ALLOCATE: {
4924+
case DeclUpdateKind::DeclMarkedOpenMPAllocate: {
49254925
auto AllocatorKind =
49264926
static_cast<OMPAllocateDeclAttr::AllocatorTypeTy>(Record.readInt());
49274927
Expr *Allocator = Record.readExpr();
@@ -4932,7 +4932,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
49324932
break;
49334933
}
49344934

4935-
case UPD_DECL_EXPORTED: {
4935+
case DeclUpdateKind::DeclExported: {
49364936
unsigned SubmoduleID = readSubmoduleID();
49374937
auto *Exported = cast<NamedDecl>(D);
49384938
Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr;
@@ -4941,7 +4941,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
49414941
break;
49424942
}
49434943

4944-
case UPD_DECL_MARKED_OPENMP_DECLARETARGET: {
4944+
case DeclUpdateKind::DeclMarkedOpenMPDeclareTarget: {
49454945
auto MapType = Record.readEnum<OMPDeclareTargetDeclAttr::MapTypeTy>();
49464946
auto DevType = Record.readEnum<OMPDeclareTargetDeclAttr::DevTypeTy>();
49474947
Expr *IndirectE = Record.readExpr();
@@ -4953,7 +4953,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
49534953
break;
49544954
}
49554955

4956-
case UPD_ADDED_ATTR_TO_RECORD:
4956+
case DeclUpdateKind::AddedAttrToRecord:
49574957
AttrVec Attrs;
49584958
Record.readAttributes(Attrs);
49594959
assert(Attrs.size() == 1);

0 commit comments

Comments
 (0)