Skip to content

Commit a764358

Browse files
committed
[clang][NFC] Convert DeclUpdateKind to scoped enum
1 parent 576be7b commit a764358

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
@@ -4689,15 +4689,15 @@ static void forAllLaterRedecls(DeclT *D, Fn F) {
46894689
void ASTDeclReader::UpdateDecl(Decl *D) {
46904690
while (Record.getIdx() < Record.size()) {
46914691
switch ((DeclUpdateKind)Record.readInt()) {
4692-
case UPD_CXX_ADDED_IMPLICIT_MEMBER: {
4692+
case DeclUpdateKind::CXXAddedImplicitMember: {
46934693
auto *RD = cast<CXXRecordDecl>(D);
46944694
Decl *MD = Record.readDecl();
46954695
assert(MD && "couldn't read decl from update record");
46964696
Reader.PendingAddedClassMembers.push_back({RD, MD});
46974697
break;
46984698
}
46994699

4700-
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
4700+
case DeclUpdateKind::CXXAddedAnonymousNamespace: {
47014701
auto *Anon = readDeclAs<NamespaceDecl>();
47024702

47034703
// Each module has its own anonymous namespace, which is disjoint from
@@ -4712,15 +4712,15 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47124712
break;
47134713
}
47144714

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

4723-
case UPD_CXX_POINT_OF_INSTANTIATION: {
4723+
case DeclUpdateKind::CXXPointOfInstantiation: {
47244724
SourceLocation POI = Record.readSourceLocation();
47254725
if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D)) {
47264726
VTSD->setPointOfInstantiation(POI);
@@ -4740,7 +4740,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47404740
break;
47414741
}
47424742

4743-
case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT: {
4743+
case DeclUpdateKind::CXXInstantiatedDefaultArgument: {
47444744
auto *Param = cast<ParmVarDecl>(D);
47454745

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

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

@@ -4772,7 +4772,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47724772
break;
47734773
}
47744774

4775-
case UPD_CXX_ADDED_FUNCTION_DEFINITION: {
4775+
case DeclUpdateKind::CXXAddedFunctionDefinition: {
47764776
auto *FD = cast<FunctionDecl>(D);
47774777
if (Reader.PendingBodies[FD]) {
47784778
// FIXME: Maybe check for ODR violations.
@@ -4794,7 +4794,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
47944794
break;
47954795
}
47964796

4797-
case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
4797+
case DeclUpdateKind::CXXInstantiatedClassDefinition: {
47984798
auto *RD = cast<CXXRecordDecl>(D);
47994799
auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
48004800
bool HadRealDefinition =
@@ -4855,7 +4855,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
48554855
break;
48564856
}
48574857

4858-
case UPD_CXX_RESOLVED_DTOR_DELETE: {
4858+
case DeclUpdateKind::CXXResolvedDtorDelete: {
48594859
// Set the 'operator delete' directly to avoid emitting another update
48604860
// record.
48614861
auto *Del = readDeclAs<FunctionDecl>();
@@ -4869,7 +4869,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
48694869
break;
48704870
}
48714871

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

@@ -4891,35 +4891,35 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
48914891
break;
48924892
}
48934893

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

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

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

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

4917-
case UPD_DECL_MARKED_OPENMP_THREADPRIVATE:
4917+
case DeclUpdateKind::DeclMarkedOpenMPThreadPrivate:
49184918
D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(Reader.getContext(),
49194919
readSourceRange()));
49204920
break;
49214921

4922-
case UPD_DECL_MARKED_OPENMP_ALLOCATE: {
4922+
case DeclUpdateKind::DeclMarkedOpenMPAllocate: {
49234923
auto AllocatorKind =
49244924
static_cast<OMPAllocateDeclAttr::AllocatorTypeTy>(Record.readInt());
49254925
Expr *Allocator = Record.readExpr();
@@ -4930,7 +4930,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
49304930
break;
49314931
}
49324932

4933-
case UPD_DECL_EXPORTED: {
4933+
case DeclUpdateKind::DeclExported: {
49344934
unsigned SubmoduleID = readSubmoduleID();
49354935
auto *Exported = cast<NamedDecl>(D);
49364936
Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr;
@@ -4939,7 +4939,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
49394939
break;
49404940
}
49414941

4942-
case UPD_DECL_MARKED_OPENMP_DECLARETARGET: {
4942+
case DeclUpdateKind::DeclMarkedOpenMPDeclareTarget: {
49434943
auto MapType = Record.readEnum<OMPDeclareTargetDeclAttr::MapTypeTy>();
49444944
auto DevType = Record.readEnum<OMPDeclareTargetDeclAttr::DevTypeTy>();
49454945
Expr *IndirectE = Record.readExpr();
@@ -4951,7 +4951,7 @@ void ASTDeclReader::UpdateDecl(Decl *D) {
49514951
break;
49524952
}
49534953

4954-
case UPD_ADDED_ATTR_TO_RECORD:
4954+
case DeclUpdateKind::AddedAttrToRecord:
49554955
AttrVec Attrs;
49564956
Record.readAttributes(Attrs);
49574957
assert(Attrs.size() == 1);

0 commit comments

Comments
 (0)