[clang] [clang][NFC] Improve locality of recently refactored enums (PR #70943)

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll closed 
https://github.com/llvm/llvm-project/pull/70943
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Improve locality of recently refactored enums (PR #70943)

2023-11-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

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

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:

- (modified) clang/include/clang/AST/Decl.h (+23) 
- (modified) clang/include/clang/AST/DeclBase.h (+3-31) 
- (modified) clang/include/clang/AST/DeclObjC.h (+2) 
- (modified) clang/include/clang/AST/DeclOpenMP.h (+6) 
- (modified) clang/include/clang/AST/Type.h (+63-60) 


``diff
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()
-  Copy// omp_priv = 
-};
-
-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 {
const SourceLocation *Locs, ASTContext );
 };
 
+enum class ObjCImplementationControl { None, Required, Optional };
+
 /// ObjCMethodDecl - Represents an instance or class method declaration.
 /// ObjC 

[clang] [clang][NFC] Improve locality of recently refactored enums (PR #70943)

2023-11-01 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/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

I'm going to land this as soon as pre-commit CI goes green, possibly not 
waiting for slow windows bot.

>From dc0737c7ee6df7c4228ecf263696bf13c951e941 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 1 Nov 2023 17:49:42 +0300
Subject: [PATCH] [clang][NFC] Improve locality of recently refactored enums

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.
---
 clang/include/clang/AST/Decl.h   |  23 +
 clang/include/clang/AST/DeclBase.h   |  34 +---
 clang/include/clang/AST/DeclObjC.h   |   2 +
 clang/include/clang/AST/DeclOpenMP.h |   6 ++
 clang/include/clang/AST/Type.h   | 123 ++-
 5 files changed, 97 insertions(+), 91 deletions(-)

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()
-  Copy// omp_priv = 
-};
-
-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
---