[clang] 24228ae - [clang][NFC] Improve locality of recently refactored enums (#70943)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 1 08:47:10 PDT 2023
Author: Vlad Serebrennikov
Date: 2023-11-01T19:47:06+04:00
New Revision: 24228aef56291bae6d10f44d1a40b5cf25bc59d2
URL: https://github.com/llvm/llvm-project/commit/24228aef56291bae6d10f44d1a40b5cf25bc59d2
DIFF: https://github.com/llvm/llvm-project/commit/24228aef56291bae6d10f44d1a40b5cf25bc59d2.diff
LOG: [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:
aaba3761db84032541712899964714f3184e8b3d
50dec541f328a251c2830421f354e4439e635def
b120fe8d3288c4dca1b5427ca34839ce8833f71c
ae7b20b583fab1325d8b51fe5f2eaf612de8b95e
4ad2ada5216ee2bb3c334a3233a9ab51f2521b82
49fd28d9601dde429436655ec74234e895c60b89
Added:
Modified:
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclObjC.h
clang/include/clang/AST/DeclOpenMP.h
clang/include/clang/AST/Type.h
Removed:
################################################################################
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
diff erent 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
diff erent 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.
More information about the cfe-commits
mailing list