Skip to content

Commit 24228ae

Browse files
authored
[clang][NFC] Improve locality of recently refactored enums (#70943)
This patch moves definition of recently refactored enums closer to the types where they were originally defined. Since they are scoped enums at namespace scope now, they can be forward-declared. Refactorings in question are: aaba376 50dec54 b120fe8 ae7b20b 4ad2ada 49fd28d
1 parent c28b7eb commit 24228ae

File tree

5 files changed

+97
-91
lines changed

5 files changed

+97
-91
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,6 +4059,29 @@ 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+
};
4084+
40624085
/// Represents a struct/union/class. For example:
40634086
/// struct X; // Forward declaration, no "body".
40644087
/// union Y { int A, B; }; // Has body with members A and B (FieldDecls).

clang/include/clang/AST/DeclBase.h

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,37 +1399,9 @@ enum class DeductionCandidate : unsigned char {
13991399
Aggregate,
14001400
};
14011401

1402-
/// Enum that represents the different ways arguments are passed to and
1403-
/// returned from function calls. This takes into account the target-specific
1404-
/// and version-specific rules along with the rules determined by the
1405-
/// language.
1406-
enum class ArgPassingKind {
1407-
/// The argument of this type can be passed directly in registers.
1408-
CanPassInRegs,
1409-
1410-
/// The argument of this type cannot be passed directly in registers.
1411-
/// Records containing this type as a subobject are not forced to be passed
1412-
/// indirectly. This value is used only in C++. This value is required by
1413-
/// C++ because, in uncommon situations, it is possible for a class to have
1414-
/// only trivial copy/move constructors even when one of its subobjects has
1415-
/// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
1416-
/// constructor in the derived class is deleted).
1417-
CannotPassInRegs,
1418-
1419-
/// The argument of this type cannot be passed directly in registers.
1420-
/// Records containing this type as a subobject are forced to be passed
1421-
/// indirectly.
1422-
CanNeverPassInRegs
1423-
};
1424-
1425-
enum class OMPDeclareReductionInitKind {
1426-
Call, // Initialized by function call.
1427-
Direct, // omp_priv(<expr>)
1428-
Copy // omp_priv = <expr>
1429-
};
1430-
1431-
enum class ObjCImplementationControl { None, Required, Optional };
1432-
1402+
enum class ArgPassingKind;
1403+
enum class OMPDeclareReductionInitKind;
1404+
enum class ObjCImplementationControl;
14331405
enum class LinkageSpecLanguageIDs;
14341406

14351407
/// DeclContext - This is used only as base class of specific decl types that

clang/include/clang/AST/DeclObjC.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class ObjCProtocolList : public ObjCList<ObjCProtocolDecl> {
115115
const SourceLocation *Locs, ASTContext &Ctx);
116116
};
117117

118+
enum class ObjCImplementationControl { None, Required, Optional };
119+
118120
/// ObjCMethodDecl - Represents an instance or class method declaration.
119121
/// ObjC methods can be declared within 4 contexts: class interfaces,
120122
/// categories, protocols, and class implementations. While C++ member

clang/include/clang/AST/DeclOpenMP.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {
158158
static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
159159
};
160160

161+
enum class OMPDeclareReductionInitKind {
162+
Call, // Initialized by function call.
163+
Direct, // omp_priv(<expr>)
164+
Copy // omp_priv = <expr>
165+
};
166+
161167
/// This represents '#pragma omp declare reduction ...' directive.
162168
/// For example, in the following, declared reduction 'foo' for types 'int' and
163169
/// 'float':

clang/include/clang/AST/Type.h

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,66 +1569,9 @@ enum class AutoTypeKeyword {
15691569
GNUAutoType
15701570
};
15711571

1572-
/// Capture whether this is a normal array (e.g. int X[4])
1573-
/// an array with a static size (e.g. int X[static 4]), or an array
1574-
/// with a star size (e.g. int X[*]).
1575-
/// 'static' is only allowed on function parameters.
1576-
enum class ArraySizeModifier { Normal, Static, Star };
1577-
1578-
/// The elaboration keyword that precedes a qualified type name or
1579-
/// introduces an elaborated-type-specifier.
1580-
enum class ElaboratedTypeKeyword {
1581-
/// The "struct" keyword introduces the elaborated-type-specifier.
1582-
Struct,
1583-
1584-
/// The "__interface" keyword introduces the elaborated-type-specifier.
1585-
Interface,
1586-
1587-
/// The "union" keyword introduces the elaborated-type-specifier.
1588-
Union,
1589-
1590-
/// The "class" keyword introduces the elaborated-type-specifier.
1591-
Class,
1592-
1593-
/// The "enum" keyword introduces the elaborated-type-specifier.
1594-
Enum,
1595-
1596-
/// The "typename" keyword precedes the qualified type name, e.g.,
1597-
/// \c typename T::type.
1598-
Typename,
1599-
1600-
/// No keyword precedes the qualified type name.
1601-
None
1602-
};
1603-
1604-
enum class VectorKind {
1605-
/// not a target-specific vector type
1606-
Generic,
1607-
1608-
/// is AltiVec vector
1609-
AltiVecVector,
1610-
1611-
/// is AltiVec 'vector Pixel'
1612-
AltiVecPixel,
1613-
1614-
/// is AltiVec 'vector bool ...'
1615-
AltiVecBool,
1616-
1617-
/// is ARM Neon vector
1618-
Neon,
1619-
1620-
/// is ARM Neon polynomial vector
1621-
NeonPoly,
1622-
1623-
/// is AArch64 SVE fixed-length data vector
1624-
SveFixedLengthData,
1625-
1626-
/// is AArch64 SVE fixed-length predicate vector
1627-
SveFixedLengthPredicate,
1628-
1629-
/// is RISC-V RVV fixed-length data vector
1630-
RVVFixedLengthData,
1631-
};
1572+
enum class ArraySizeModifier;
1573+
enum class ElaboratedTypeKeyword;
1574+
enum class VectorKind;
16321575

16331576
/// The base class of the type hierarchy.
16341577
///
@@ -3145,6 +3088,12 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
31453088
}
31463089
};
31473090

3091+
/// Capture whether this is a normal array (e.g. int X[4])
3092+
/// an array with a static size (e.g. int X[static 4]), or an array
3093+
/// with a star size (e.g. int X[*]).
3094+
/// 'static' is only allowed on function parameters.
3095+
enum class ArraySizeModifier { Normal, Static, Star };
3096+
31483097
/// Represents an array type, per C99 6.7.5.2 - Array Declarators.
31493098
class ArrayType : public Type, public llvm::FoldingSetNode {
31503099
private:
@@ -3474,6 +3423,34 @@ class DependentSizedExtVectorType : public Type, public llvm::FoldingSetNode {
34743423
QualType ElementType, Expr *SizeExpr);
34753424
};
34763425

3426+
enum class VectorKind {
3427+
/// not a target-specific vector type
3428+
Generic,
3429+
3430+
/// is AltiVec vector
3431+
AltiVecVector,
3432+
3433+
/// is AltiVec 'vector Pixel'
3434+
AltiVecPixel,
3435+
3436+
/// is AltiVec 'vector bool ...'
3437+
AltiVecBool,
3438+
3439+
/// is ARM Neon vector
3440+
Neon,
3441+
3442+
/// is ARM Neon polynomial vector
3443+
NeonPoly,
3444+
3445+
/// is AArch64 SVE fixed-length data vector
3446+
SveFixedLengthData,
3447+
3448+
/// is AArch64 SVE fixed-length predicate vector
3449+
SveFixedLengthPredicate,
3450+
3451+
/// is RISC-V RVV fixed-length data vector
3452+
RVVFixedLengthData,
3453+
};
34773454

34783455
/// Represents a GCC generic vector type. This type is created using
34793456
/// __attribute__((vector_size(n)), where "n" specifies the vector size in
@@ -5667,6 +5644,32 @@ class InjectedClassNameType : public Type {
56675644
}
56685645
};
56695646

5647+
/// The elaboration keyword that precedes a qualified type name or
5648+
/// introduces an elaborated-type-specifier.
5649+
enum class ElaboratedTypeKeyword {
5650+
/// The "struct" keyword introduces the elaborated-type-specifier.
5651+
Struct,
5652+
5653+
/// The "__interface" keyword introduces the elaborated-type-specifier.
5654+
Interface,
5655+
5656+
/// The "union" keyword introduces the elaborated-type-specifier.
5657+
Union,
5658+
5659+
/// The "class" keyword introduces the elaborated-type-specifier.
5660+
Class,
5661+
5662+
/// The "enum" keyword introduces the elaborated-type-specifier.
5663+
Enum,
5664+
5665+
/// The "typename" keyword precedes the qualified type name, e.g.,
5666+
/// \c typename T::type.
5667+
Typename,
5668+
5669+
/// No keyword precedes the qualified type name.
5670+
None
5671+
};
5672+
56705673
/// The kind of a tag type.
56715674
enum TagTypeKind {
56725675
/// The "struct" keyword.

0 commit comments

Comments
 (0)