-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang][NFC] Improve locality of recently refactored enums #70943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) ChangesThis 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: I'm going to land this as soon as pre-commit CI goes green, possibly not waiting for slow windows bot. Full diff: https://github.com/llvm/llvm-project/pull/70943.diff 5 Files Affected:
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 1c2158f51aa184d..d9b00b1628ab25c 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -4059,6 +4059,29 @@ class EnumDecl : public TagDecl {
static bool classofKind(Kind K) { return K == Enum; }
};
+/// Enum that represents the different ways arguments are passed to and
+/// returned from function calls. This takes into account the target-specific
+/// and version-specific rules along with the rules determined by the
+/// language.
+enum class ArgPassingKind {
+ /// The argument of this type can be passed directly in registers.
+ CanPassInRegs,
+
+ /// The argument of this type cannot be passed directly in registers.
+ /// Records containing this type as a subobject are not forced to be passed
+ /// indirectly. This value is used only in C++. This value is required by
+ /// C++ because, in uncommon situations, it is possible for a class to have
+ /// only trivial copy/move constructors even when one of its subobjects has
+ /// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
+ /// constructor in the derived class is deleted).
+ CannotPassInRegs,
+
+ /// The argument of this type cannot be passed directly in registers.
+ /// Records containing this type as a subobject are forced to be passed
+ /// indirectly.
+ CanNeverPassInRegs
+};
+
/// Represents a struct/union/class. For example:
/// struct X; // Forward declaration, no "body".
/// union Y { int A, B; }; // Has body with members A and B (FieldDecls).
diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index 32b6aed6397668c..6704c0cd41ecd3d 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1399,37 +1399,9 @@ enum class DeductionCandidate : unsigned char {
Aggregate,
};
-/// Enum that represents the different ways arguments are passed to and
-/// returned from function calls. This takes into account the target-specific
-/// and version-specific rules along with the rules determined by the
-/// language.
-enum class ArgPassingKind {
- /// The argument of this type can be passed directly in registers.
- CanPassInRegs,
-
- /// The argument of this type cannot be passed directly in registers.
- /// Records containing this type as a subobject are not forced to be passed
- /// indirectly. This value is used only in C++. This value is required by
- /// C++ because, in uncommon situations, it is possible for a class to have
- /// only trivial copy/move constructors even when one of its subobjects has
- /// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
- /// constructor in the derived class is deleted).
- CannotPassInRegs,
-
- /// The argument of this type cannot be passed directly in registers.
- /// Records containing this type as a subobject are forced to be passed
- /// indirectly.
- CanNeverPassInRegs
-};
-
-enum class OMPDeclareReductionInitKind {
- Call, // Initialized by function call.
- Direct, // omp_priv(<expr>)
- Copy // omp_priv = <expr>
-};
-
-enum class ObjCImplementationControl { None, Required, Optional };
-
+enum class ArgPassingKind;
+enum class OMPDeclareReductionInitKind;
+enum class ObjCImplementationControl;
enum class LinkageSpecLanguageIDs;
/// DeclContext - This is used only as base class of specific decl types that
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index 2b205bee51de18e..e0b31c58c39a2c5 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -115,6 +115,8 @@ class ObjCProtocolList : public ObjCList<ObjCProtocolDecl> {
const SourceLocation *Locs, ASTContext &Ctx);
};
+enum class ObjCImplementationControl { None, Required, Optional };
+
/// ObjCMethodDecl - Represents an instance or class method declaration.
/// ObjC methods can be declared within 4 contexts: class interfaces,
/// categories, protocols, and class implementations. While C++ member
diff --git a/clang/include/clang/AST/DeclOpenMP.h b/clang/include/clang/AST/DeclOpenMP.h
index 2bbd159f59a3536..73725e6e85666a0 100644
--- a/clang/include/clang/AST/DeclOpenMP.h
+++ b/clang/include/clang/AST/DeclOpenMP.h
@@ -158,6 +158,12 @@ class OMPThreadPrivateDecl final : public OMPDeclarativeDirective<Decl> {
static bool classofKind(Kind K) { return K == OMPThreadPrivate; }
};
+enum class OMPDeclareReductionInitKind {
+ Call, // Initialized by function call.
+ Direct, // omp_priv(<expr>)
+ Copy // omp_priv = <expr>
+};
+
/// This represents '#pragma omp declare reduction ...' directive.
/// For example, in the following, declared reduction 'foo' for types 'int' and
/// 'float':
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index a15ed46cae0ee54..23022d7e1a72928 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1569,66 +1569,9 @@ enum class AutoTypeKeyword {
GNUAutoType
};
-/// Capture whether this is a normal array (e.g. int X[4])
-/// an array with a static size (e.g. int X[static 4]), or an array
-/// with a star size (e.g. int X[*]).
-/// 'static' is only allowed on function parameters.
-enum class ArraySizeModifier { Normal, Static, Star };
-
-/// The elaboration keyword that precedes a qualified type name or
-/// introduces an elaborated-type-specifier.
-enum class ElaboratedTypeKeyword {
- /// The "struct" keyword introduces the elaborated-type-specifier.
- Struct,
-
- /// The "__interface" keyword introduces the elaborated-type-specifier.
- Interface,
-
- /// The "union" keyword introduces the elaborated-type-specifier.
- Union,
-
- /// The "class" keyword introduces the elaborated-type-specifier.
- Class,
-
- /// The "enum" keyword introduces the elaborated-type-specifier.
- Enum,
-
- /// The "typename" keyword precedes the qualified type name, e.g.,
- /// \c typename T::type.
- Typename,
-
- /// No keyword precedes the qualified type name.
- None
-};
-
-enum class VectorKind {
- /// not a target-specific vector type
- Generic,
-
- /// is AltiVec vector
- AltiVecVector,
-
- /// is AltiVec 'vector Pixel'
- AltiVecPixel,
-
- /// is AltiVec 'vector bool ...'
- AltiVecBool,
-
- /// is ARM Neon vector
- Neon,
-
- /// is ARM Neon polynomial vector
- NeonPoly,
-
- /// is AArch64 SVE fixed-length data vector
- SveFixedLengthData,
-
- /// is AArch64 SVE fixed-length predicate vector
- SveFixedLengthPredicate,
-
- /// is RISC-V RVV fixed-length data vector
- RVVFixedLengthData,
-};
+enum class ArraySizeModifier;
+enum class ElaboratedTypeKeyword;
+enum class VectorKind;
/// The base class of the type hierarchy.
///
@@ -3145,6 +3088,12 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
}
};
+/// Capture whether this is a normal array (e.g. int X[4])
+/// an array with a static size (e.g. int X[static 4]), or an array
+/// with a star size (e.g. int X[*]).
+/// 'static' is only allowed on function parameters.
+enum class ArraySizeModifier { Normal, Static, Star };
+
/// Represents an array type, per C99 6.7.5.2 - Array Declarators.
class ArrayType : public Type, public llvm::FoldingSetNode {
private:
@@ -3474,6 +3423,34 @@ class DependentSizedExtVectorType : public Type, public llvm::FoldingSetNode {
QualType ElementType, Expr *SizeExpr);
};
+enum class VectorKind {
+ /// not a target-specific vector type
+ Generic,
+
+ /// is AltiVec vector
+ AltiVecVector,
+
+ /// is AltiVec 'vector Pixel'
+ AltiVecPixel,
+
+ /// is AltiVec 'vector bool ...'
+ AltiVecBool,
+
+ /// is ARM Neon vector
+ Neon,
+
+ /// is ARM Neon polynomial vector
+ NeonPoly,
+
+ /// is AArch64 SVE fixed-length data vector
+ SveFixedLengthData,
+
+ /// is AArch64 SVE fixed-length predicate vector
+ SveFixedLengthPredicate,
+
+ /// is RISC-V RVV fixed-length data vector
+ RVVFixedLengthData,
+};
/// Represents a GCC generic vector type. This type is created using
/// __attribute__((vector_size(n)), where "n" specifies the vector size in
@@ -5667,6 +5644,32 @@ class InjectedClassNameType : public Type {
}
};
+/// The elaboration keyword that precedes a qualified type name or
+/// introduces an elaborated-type-specifier.
+enum class ElaboratedTypeKeyword {
+ /// The "struct" keyword introduces the elaborated-type-specifier.
+ Struct,
+
+ /// The "__interface" keyword introduces the elaborated-type-specifier.
+ Interface,
+
+ /// The "union" keyword introduces the elaborated-type-specifier.
+ Union,
+
+ /// The "class" keyword introduces the elaborated-type-specifier.
+ Class,
+
+ /// The "enum" keyword introduces the elaborated-type-specifier.
+ Enum,
+
+ /// The "typename" keyword precedes the qualified type name, e.g.,
+ /// \c typename T::type.
+ Typename,
+
+ /// No keyword precedes the qualified type name.
+ None
+};
+
/// The kind of a tag type.
enum TagTypeKind {
/// The "struct" keyword.
|
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
I'm going to land this as soon as pre-commit CI goes green, possibly not waiting for slow windows bot.