[clang] [clang][NFC] Annotate `Type` bit-fields with `clang::preferred_type` (PR #70349)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 26 10:03:39 PDT 2023


https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/70349

>From 7329f68092d5f8f5a5978e5a6cbad6ada87d4fe8 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Thu, 26 Oct 2023 16:09:25 +0300
Subject: [PATCH 1/3] [clang][NFC] Annotate `Type` bit-fields with
 `clang::preferred_type`

---
 clang/include/clang/AST/DeclBase.h        |  2 +-
 clang/include/clang/AST/DependenceFlags.h |  2 +-
 clang/include/clang/AST/Type.h            | 46 ++++++++++++++++++++++-
 clang/include/clang/Basic/Linkage.h       |  2 +-
 4 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h
index 978e4255e877ec2..0307691fdd480bf 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
 class FunctionDecl;
 class FunctionType;
 class IdentifierInfo;
-enum Linkage : unsigned char;
+enum Linkage : unsigned;
 class LinkageSpecDecl;
 class Module;
 class NamedDecl;
diff --git a/clang/include/clang/AST/DependenceFlags.h b/clang/include/clang/AST/DependenceFlags.h
index 3b3c1afb096addd..e91b6ff35b34966 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
 using ExprDependence = ExprDependenceScope::ExprDependence;
 
 struct TypeDependenceScope {
-  enum TypeDependence : uint8_t {
+  enum TypeDependence : unsigned {
     /// Whether this type contains an unexpanded parameter pack
     /// (for C++11 variadic templates)
     UnexpandedPack = 1,
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1e8e1303e65f6ba..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     template <class T> friend class TypePropertyCache;
 
     /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
+    [[clang::preferred_type(TypeClass)]]
     unsigned TC : 8;
 
     /// Store information on the type dependency.
+    [[clang::preferred_type(TypeDependence)]]
     unsigned Dependence : llvm::BitWidth<TypeDependence>;
 
     /// True if the cache (i.e. the bitfields here starting with
     /// 'Cache') is valid.
+    [[clang::preferred_type(bool)]]
     mutable unsigned CacheValid : 1;
 
     /// Linkage of this type.
+    [[clang::preferred_type(Linkage)]]
     mutable unsigned CachedLinkage : 3;
 
     /// Whether this type involves and local or unnamed types.
+    [[clang::preferred_type(bool)]]
     mutable unsigned CachedLocalOrUnnamed : 1;
 
     /// Whether this type comes from an AST file.
+    [[clang::preferred_type(bool)]]
     mutable unsigned FromAST : 1;
 
     bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
     friend class ArrayType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// CVR qualifiers from declarations like
     /// 'int X[static restrict 4]'. For function parameters only.
+    [[clang::preferred_type(Qualifiers)]]
     unsigned IndexTypeQuals : 3;
 
     /// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned : NumArrayTypeBits;
 
     /// Whether we have a stored size expression.
+    [[clang::preferred_type(bool)]]
     unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
     friend class BuiltinType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     friend class FunctionProtoType;
     friend class FunctionType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// Extra information which affects how the function is called, like
     /// regparm and the calling convention.
+    [[clang::preferred_type(CallingConv)]]
     unsigned ExtInfo : 13;
 
     /// The ref-qualifier associated with a \c FunctionProtoType.
     ///
     /// This is a value of type \c RefQualifierKind.
+    [[clang::preferred_type(RefQualifierKind)]]
     unsigned RefQualifier : 2;
 
     /// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     ///
     /// C++ 8.3.5p4: The return type, the parameter type list and the
     /// cv-qualifier-seq, [...], are part of the function type.
+    [[clang::preferred_type(Qualifiers)]]
     unsigned FastTypeQuals : Qualifiers::FastWidth;
     /// Whether this function has extended Qualifiers.
+    [[clang::preferred_type(bool)]]
     unsigned HasExtQuals : 1;
 
     /// The number of parameters this function has, not counting '...'.
@@ -1719,24 +1734,30 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned NumParams : 16;
 
     /// The type of exception specification this function has.
+    [[clang::preferred_type(ExceptionSpecificationType)]]
     unsigned ExceptionSpecType : 4;
 
     /// Whether this function has extended parameter information.
+    [[clang::preferred_type(bool)]]
     unsigned HasExtParameterInfos : 1;
 
     /// Whether this function has extra bitfields for the prototype.
+    [[clang::preferred_type(bool)]]
     unsigned HasExtraBitfields : 1;
 
     /// Whether the function is variadic.
+    [[clang::preferred_type(bool)]]
     unsigned Variadic : 1;
 
     /// Whether this function has a trailing return type.
+    [[clang::preferred_type(bool)]]
     unsigned HasTrailingReturn : 1;
   };
 
   class ObjCObjectTypeBitfields {
     friend class ObjCObjectType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// The number of type arguments stored directly on this object type.
@@ -1746,12 +1767,14 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned NumProtocols : 6;
 
     /// Whether this is a "kindof" type.
+    [[clang::preferred_type(bool)]]
     unsigned IsKindOf : 1;
   };
 
   class ReferenceTypeBitfields {
     friend class ReferenceType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// True if the type was originally spelled with an lvalue sigil.
@@ -1765,16 +1788,19 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     ///   ref &&a;             // lvalue, inner ref
     ///   rvref &a;            // lvalue, inner ref, spelled lvalue
     ///   rvref &&a;           // rvalue, inner ref
+    [[clang::preferred_type(bool)]]
     unsigned SpelledAsLValue : 1;
 
     /// True if the inner type is a reference type.  This only happens
     /// in non-canonical forms.
+    [[clang::preferred_type(bool)]]
     unsigned InnerRef : 1;
   };
 
   class TypeWithKeywordBitfields {
     friend class TypeWithKeyword;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// An ElaboratedTypeKeyword.  8 bits for efficient access.
@@ -1786,10 +1812,11 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class ElaboratedTypeBitfields {
     friend class ElaboratedType;
 
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeWithKeywordBitfields)]]
     unsigned : NumTypeWithKeywordBits;
 
     /// Whether the ElaboratedType has a trailing OwnedTagDecl.
+    [[clang::preferred_type(bool)]]
     unsigned HasOwnedTagDecl : 1;
   };
 
@@ -1797,6 +1824,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     friend class VectorType;
     friend class DependentVectorType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// The kind of vector, either a generic vector type or some
@@ -1809,6 +1837,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class AttributedTypeBitfields {
     friend class AttributedType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// An AttributedType::Kind
@@ -1818,10 +1847,12 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class AutoTypeBitfields {
     friend class AutoType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// Was this placeholder type spelled as 'auto', 'decltype(auto)',
     /// or '__auto_type'?  AutoTypeKeyword value.
+    [[clang::preferred_type(AutoTypeKeyword)]]
     unsigned Keyword : 2;
 
     /// The number of template arguments in the type-constraints, which is
@@ -1838,33 +1869,40 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     friend class TypeOfType;
     friend class TypeOfExprType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
+    [[clang::preferred_type(bool)]]
     unsigned IsUnqual : 1; // If true: typeof_unqual, else: typeof
   };
 
   class UsingBitfields {
     friend class UsingType;
 
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// True if the underlying type is different from the declared one.
+    [[clang::preferred_type(bool)]]
     unsigned hasTypeDifferentFromDecl : 1;
   };
 
   class TypedefBitfields {
     friend class TypedefType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// True if the underlying type is different from the declared one.
+    [[clang::preferred_type(bool)]]
     unsigned hasTypeDifferentFromDecl : 1;
   };
 
   class SubstTemplateTypeParmTypeBitfields {
     friend class SubstTemplateTypeParmType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
+    [[clang::preferred_type(bool)]]
     unsigned HasNonCanonicalUnderlyingType : 1;
 
     // The index of the template parameter this substitution represents.
@@ -1881,6 +1919,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class SubstTemplateTypeParmPackTypeBitfields {
     friend class SubstTemplateTypeParmPackType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     // The index of the template parameter this substitution represents.
@@ -1896,9 +1935,11 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class TemplateSpecializationTypeBitfields {
     friend class TemplateSpecializationType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// Whether this template specialization type is a substituted type alias.
+    [[clang::preferred_type(bool)]]
     unsigned TypeAlias : 1;
 
     /// The number of template arguments named in this class template
@@ -1929,6 +1970,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class PackExpansionTypeBitfields {
     friend class PackExpansionType;
 
+    [[clang::preferred_type(TypeBitfields)]]
     unsigned : NumTypeBits;
 
     /// The number of expansions that this pack expansion will
diff --git a/clang/include/clang/Basic/Linkage.h b/clang/include/clang/Basic/Linkage.h
index 0b7b61954a075ae..bfe750462cc70b7 100644
--- a/clang/include/clang/Basic/Linkage.h
+++ b/clang/include/clang/Basic/Linkage.h
@@ -20,7 +20,7 @@ namespace clang {
 
 /// Describes the different kinds of linkage
 /// (C++ [basic.link], C99 6.2.2) that an entity may have.
-enum Linkage : unsigned char {
+enum Linkage : unsigned {
   /// No linkage, which means that the entity is unique and
   /// can only be referred to from within its scope.
   NoLinkage = 0,

>From 21689b56d1fc1db0b2263e8049ff656d3757ad36 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Thu, 26 Oct 2023 16:10:15 +0300
Subject: [PATCH 2/3] Run clang-format

---
 clang/include/clang/AST/Type.h | 134 ++++++++++++---------------------
 1 file changed, 48 insertions(+), 86 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index f24b1dccc240785..55558a22ecc1b1c 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,29 +1611,24 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     template <class T> friend class TypePropertyCache;
 
     /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
-    [[clang::preferred_type(TypeClass)]]
-    unsigned TC : 8;
+    [[clang::preferred_type(TypeClass)]] unsigned TC : 8;
 
     /// Store information on the type dependency.
-    [[clang::preferred_type(TypeDependence)]]
-    unsigned Dependence : llvm::BitWidth<TypeDependence>;
+    [[clang::preferred_type(TypeDependence)]] unsigned Dependence
+        : llvm::BitWidth<TypeDependence>;
 
     /// True if the cache (i.e. the bitfields here starting with
     /// 'Cache') is valid.
-    [[clang::preferred_type(bool)]]
-    mutable unsigned CacheValid : 1;
+    [[clang::preferred_type(bool)]] mutable unsigned CacheValid : 1;
 
     /// Linkage of this type.
-    [[clang::preferred_type(Linkage)]]
-    mutable unsigned CachedLinkage : 3;
+    [[clang::preferred_type(Linkage)]] mutable unsigned CachedLinkage : 3;
 
     /// Whether this type involves and local or unnamed types.
-    [[clang::preferred_type(bool)]]
-    mutable unsigned CachedLocalOrUnnamed : 1;
+    [[clang::preferred_type(bool)]] mutable unsigned CachedLocalOrUnnamed : 1;
 
     /// Whether this type comes from an AST file.
-    [[clang::preferred_type(bool)]]
-    mutable unsigned FromAST : 1;
+    [[clang::preferred_type(bool)]] mutable unsigned FromAST : 1;
 
     bool isCacheValid() const {
       return CacheValid;
@@ -1658,13 +1653,11 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
     friend class ArrayType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// CVR qualifiers from declarations like
     /// 'int X[static restrict 4]'. For function parameters only.
-    [[clang::preferred_type(Qualifiers)]]
-    unsigned IndexTypeQuals : 3;
+    [[clang::preferred_type(Qualifiers)]] unsigned IndexTypeQuals : 3;
 
     /// Storage class qualifiers from declarations like
     /// 'int X[static restrict 4]'. For function parameters only.
@@ -1679,15 +1672,13 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned : NumArrayTypeBits;
 
     /// Whether we have a stored size expression.
-    [[clang::preferred_type(bool)]]
-    unsigned HasStoredSizeExpr : 1;
+    [[clang::preferred_type(bool)]] unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
     friend class BuiltinType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// The kind (BuiltinType::Kind) of builtin type this is.
     static constexpr unsigned NumOfBuiltinTypeBits = 9;
@@ -1701,19 +1692,16 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     friend class FunctionProtoType;
     friend class FunctionType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// Extra information which affects how the function is called, like
     /// regparm and the calling convention.
-    [[clang::preferred_type(CallingConv)]]
-    unsigned ExtInfo : 13;
+    [[clang::preferred_type(CallingConv)]] unsigned ExtInfo : 13;
 
     /// The ref-qualifier associated with a \c FunctionProtoType.
     ///
     /// This is a value of type \c RefQualifierKind.
-    [[clang::preferred_type(RefQualifierKind)]]
-    unsigned RefQualifier : 2;
+    [[clang::preferred_type(RefQualifierKind)]] unsigned RefQualifier : 2;
 
     /// Used only by FunctionProtoType, put here to pack with the
     /// other bitfields.
@@ -1721,11 +1709,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     ///
     /// C++ 8.3.5p4: The return type, the parameter type list and the
     /// cv-qualifier-seq, [...], are part of the function type.
-    [[clang::preferred_type(Qualifiers)]]
-    unsigned FastTypeQuals : Qualifiers::FastWidth;
+    [[clang::preferred_type(Qualifiers)]] unsigned FastTypeQuals
+        : Qualifiers::FastWidth;
     /// Whether this function has extended Qualifiers.
-    [[clang::preferred_type(bool)]]
-    unsigned HasExtQuals : 1;
+    [[clang::preferred_type(bool)]] unsigned HasExtQuals : 1;
 
     /// The number of parameters this function has, not counting '...'.
     /// According to [implimits] 8 bits should be enough here but this is
@@ -1734,31 +1721,26 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned NumParams : 16;
 
     /// The type of exception specification this function has.
-    [[clang::preferred_type(ExceptionSpecificationType)]]
-    unsigned ExceptionSpecType : 4;
+    [[clang::preferred_type(
+        ExceptionSpecificationType)]] unsigned ExceptionSpecType : 4;
 
     /// Whether this function has extended parameter information.
-    [[clang::preferred_type(bool)]]
-    unsigned HasExtParameterInfos : 1;
+    [[clang::preferred_type(bool)]] unsigned HasExtParameterInfos : 1;
 
     /// Whether this function has extra bitfields for the prototype.
-    [[clang::preferred_type(bool)]]
-    unsigned HasExtraBitfields : 1;
+    [[clang::preferred_type(bool)]] unsigned HasExtraBitfields : 1;
 
     /// Whether the function is variadic.
-    [[clang::preferred_type(bool)]]
-    unsigned Variadic : 1;
+    [[clang::preferred_type(bool)]] unsigned Variadic : 1;
 
     /// Whether this function has a trailing return type.
-    [[clang::preferred_type(bool)]]
-    unsigned HasTrailingReturn : 1;
+    [[clang::preferred_type(bool)]] unsigned HasTrailingReturn : 1;
   };
 
   class ObjCObjectTypeBitfields {
     friend class ObjCObjectType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// The number of type arguments stored directly on this object type.
     unsigned NumTypeArgs : 7;
@@ -1767,15 +1749,13 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned NumProtocols : 6;
 
     /// Whether this is a "kindof" type.
-    [[clang::preferred_type(bool)]]
-    unsigned IsKindOf : 1;
+    [[clang::preferred_type(bool)]] unsigned IsKindOf : 1;
   };
 
   class ReferenceTypeBitfields {
     friend class ReferenceType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// True if the type was originally spelled with an lvalue sigil.
     /// This is never true of rvalue references but can also be false
@@ -1788,20 +1768,17 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     ///   ref &&a;             // lvalue, inner ref
     ///   rvref &a;            // lvalue, inner ref, spelled lvalue
     ///   rvref &&a;           // rvalue, inner ref
-    [[clang::preferred_type(bool)]]
-    unsigned SpelledAsLValue : 1;
+    [[clang::preferred_type(bool)]] unsigned SpelledAsLValue : 1;
 
     /// True if the inner type is a reference type.  This only happens
     /// in non-canonical forms.
-    [[clang::preferred_type(bool)]]
-    unsigned InnerRef : 1;
+    [[clang::preferred_type(bool)]] unsigned InnerRef : 1;
   };
 
   class TypeWithKeywordBitfields {
     friend class TypeWithKeyword;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// An ElaboratedTypeKeyword.  8 bits for efficient access.
     unsigned Keyword : 8;
@@ -1812,20 +1789,18 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class ElaboratedTypeBitfields {
     friend class ElaboratedType;
 
-    [[clang::preferred_type(TypeWithKeywordBitfields)]]
-    unsigned : NumTypeWithKeywordBits;
+    [[clang::preferred_type(TypeWithKeywordBitfields)]] unsigned
+        : NumTypeWithKeywordBits;
 
     /// Whether the ElaboratedType has a trailing OwnedTagDecl.
-    [[clang::preferred_type(bool)]]
-    unsigned HasOwnedTagDecl : 1;
+    [[clang::preferred_type(bool)]] unsigned HasOwnedTagDecl : 1;
   };
 
   class VectorTypeBitfields {
     friend class VectorType;
     friend class DependentVectorType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// The kind of vector, either a generic vector type or some
     /// target-specific vector type such as for AltiVec or Neon.
@@ -1837,8 +1812,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class AttributedTypeBitfields {
     friend class AttributedType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// An AttributedType::Kind
     unsigned AttrKind : 32 - NumTypeBits;
@@ -1847,13 +1821,11 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class AutoTypeBitfields {
     friend class AutoType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// Was this placeholder type spelled as 'auto', 'decltype(auto)',
     /// or '__auto_type'?  AutoTypeKeyword value.
-    [[clang::preferred_type(AutoTypeKeyword)]]
-    unsigned Keyword : 2;
+    [[clang::preferred_type(AutoTypeKeyword)]] unsigned Keyword : 2;
 
     /// The number of template arguments in the type-constraints, which is
     /// expected to be able to hold at least 1024 according to [implimits].
@@ -1869,10 +1841,9 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     friend class TypeOfType;
     friend class TypeOfExprType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
-    [[clang::preferred_type(bool)]]
-    unsigned IsUnqual : 1; // If true: typeof_unqual, else: typeof
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(
+        bool)]] unsigned IsUnqual : 1; // If true: typeof_unqual, else: typeof
   };
 
   class UsingBitfields {
@@ -1881,29 +1852,24 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// True if the underlying type is different from the declared one.
-    [[clang::preferred_type(bool)]]
-    unsigned hasTypeDifferentFromDecl : 1;
+    [[clang::preferred_type(bool)]] unsigned hasTypeDifferentFromDecl : 1;
   };
 
   class TypedefBitfields {
     friend class TypedefType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// True if the underlying type is different from the declared one.
-    [[clang::preferred_type(bool)]]
-    unsigned hasTypeDifferentFromDecl : 1;
+    [[clang::preferred_type(bool)]] unsigned hasTypeDifferentFromDecl : 1;
   };
 
   class SubstTemplateTypeParmTypeBitfields {
     friend class SubstTemplateTypeParmType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
-    [[clang::preferred_type(bool)]]
-    unsigned HasNonCanonicalUnderlyingType : 1;
+    [[clang::preferred_type(bool)]] unsigned HasNonCanonicalUnderlyingType : 1;
 
     // The index of the template parameter this substitution represents.
     unsigned Index : 15;
@@ -1919,8 +1885,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class SubstTemplateTypeParmPackTypeBitfields {
     friend class SubstTemplateTypeParmPackType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     // The index of the template parameter this substitution represents.
     unsigned Index : 16;
@@ -1935,12 +1900,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class TemplateSpecializationTypeBitfields {
     friend class TemplateSpecializationType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// Whether this template specialization type is a substituted type alias.
-    [[clang::preferred_type(bool)]]
-    unsigned TypeAlias : 1;
+    [[clang::preferred_type(bool)]] unsigned TypeAlias : 1;
 
     /// The number of template arguments named in this class template
     /// specialization, which is expected to be able to hold at least 1024
@@ -1970,8 +1933,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class PackExpansionTypeBitfields {
     friend class PackExpansionType;
 
-    [[clang::preferred_type(TypeBitfields)]]
-    unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// The number of expansions that this pack expansion will
     /// generate when substituted (+1), which is expected to be able to

>From 3eb936f9351d1252c465372023423344b63488fa Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Thu, 26 Oct 2023 21:03:22 +0400
Subject: [PATCH 3/3] Revert "Run clang-format"

This reverts commit 21689b56d1fc1db0b2263e8049ff656d3757ad36.
---
 clang/include/clang/AST/Type.h | 134 +++++++++++++++++++++------------
 1 file changed, 86 insertions(+), 48 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 55558a22ecc1b1c..f24b1dccc240785 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1611,24 +1611,29 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     template <class T> friend class TypePropertyCache;
 
     /// TypeClass bitfield - Enum that specifies what subclass this belongs to.
-    [[clang::preferred_type(TypeClass)]] unsigned TC : 8;
+    [[clang::preferred_type(TypeClass)]]
+    unsigned TC : 8;
 
     /// Store information on the type dependency.
-    [[clang::preferred_type(TypeDependence)]] unsigned Dependence
-        : llvm::BitWidth<TypeDependence>;
+    [[clang::preferred_type(TypeDependence)]]
+    unsigned Dependence : llvm::BitWidth<TypeDependence>;
 
     /// True if the cache (i.e. the bitfields here starting with
     /// 'Cache') is valid.
-    [[clang::preferred_type(bool)]] mutable unsigned CacheValid : 1;
+    [[clang::preferred_type(bool)]]
+    mutable unsigned CacheValid : 1;
 
     /// Linkage of this type.
-    [[clang::preferred_type(Linkage)]] mutable unsigned CachedLinkage : 3;
+    [[clang::preferred_type(Linkage)]]
+    mutable unsigned CachedLinkage : 3;
 
     /// Whether this type involves and local or unnamed types.
-    [[clang::preferred_type(bool)]] mutable unsigned CachedLocalOrUnnamed : 1;
+    [[clang::preferred_type(bool)]]
+    mutable unsigned CachedLocalOrUnnamed : 1;
 
     /// Whether this type comes from an AST file.
-    [[clang::preferred_type(bool)]] mutable unsigned FromAST : 1;
+    [[clang::preferred_type(bool)]]
+    mutable unsigned FromAST : 1;
 
     bool isCacheValid() const {
       return CacheValid;
@@ -1653,11 +1658,13 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class ArrayTypeBitfields {
     friend class ArrayType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// CVR qualifiers from declarations like
     /// 'int X[static restrict 4]'. For function parameters only.
-    [[clang::preferred_type(Qualifiers)]] unsigned IndexTypeQuals : 3;
+    [[clang::preferred_type(Qualifiers)]]
+    unsigned IndexTypeQuals : 3;
 
     /// Storage class qualifiers from declarations like
     /// 'int X[static restrict 4]'. For function parameters only.
@@ -1672,13 +1679,15 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned : NumArrayTypeBits;
 
     /// Whether we have a stored size expression.
-    [[clang::preferred_type(bool)]] unsigned HasStoredSizeExpr : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned HasStoredSizeExpr : 1;
   };
 
   class BuiltinTypeBitfields {
     friend class BuiltinType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// The kind (BuiltinType::Kind) of builtin type this is.
     static constexpr unsigned NumOfBuiltinTypeBits = 9;
@@ -1692,16 +1701,19 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     friend class FunctionProtoType;
     friend class FunctionType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// Extra information which affects how the function is called, like
     /// regparm and the calling convention.
-    [[clang::preferred_type(CallingConv)]] unsigned ExtInfo : 13;
+    [[clang::preferred_type(CallingConv)]]
+    unsigned ExtInfo : 13;
 
     /// The ref-qualifier associated with a \c FunctionProtoType.
     ///
     /// This is a value of type \c RefQualifierKind.
-    [[clang::preferred_type(RefQualifierKind)]] unsigned RefQualifier : 2;
+    [[clang::preferred_type(RefQualifierKind)]]
+    unsigned RefQualifier : 2;
 
     /// Used only by FunctionProtoType, put here to pack with the
     /// other bitfields.
@@ -1709,10 +1721,11 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     ///
     /// C++ 8.3.5p4: The return type, the parameter type list and the
     /// cv-qualifier-seq, [...], are part of the function type.
-    [[clang::preferred_type(Qualifiers)]] unsigned FastTypeQuals
-        : Qualifiers::FastWidth;
+    [[clang::preferred_type(Qualifiers)]]
+    unsigned FastTypeQuals : Qualifiers::FastWidth;
     /// Whether this function has extended Qualifiers.
-    [[clang::preferred_type(bool)]] unsigned HasExtQuals : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned HasExtQuals : 1;
 
     /// The number of parameters this function has, not counting '...'.
     /// According to [implimits] 8 bits should be enough here but this is
@@ -1721,26 +1734,31 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned NumParams : 16;
 
     /// The type of exception specification this function has.
-    [[clang::preferred_type(
-        ExceptionSpecificationType)]] unsigned ExceptionSpecType : 4;
+    [[clang::preferred_type(ExceptionSpecificationType)]]
+    unsigned ExceptionSpecType : 4;
 
     /// Whether this function has extended parameter information.
-    [[clang::preferred_type(bool)]] unsigned HasExtParameterInfos : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned HasExtParameterInfos : 1;
 
     /// Whether this function has extra bitfields for the prototype.
-    [[clang::preferred_type(bool)]] unsigned HasExtraBitfields : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned HasExtraBitfields : 1;
 
     /// Whether the function is variadic.
-    [[clang::preferred_type(bool)]] unsigned Variadic : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned Variadic : 1;
 
     /// Whether this function has a trailing return type.
-    [[clang::preferred_type(bool)]] unsigned HasTrailingReturn : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned HasTrailingReturn : 1;
   };
 
   class ObjCObjectTypeBitfields {
     friend class ObjCObjectType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// The number of type arguments stored directly on this object type.
     unsigned NumTypeArgs : 7;
@@ -1749,13 +1767,15 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned NumProtocols : 6;
 
     /// Whether this is a "kindof" type.
-    [[clang::preferred_type(bool)]] unsigned IsKindOf : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned IsKindOf : 1;
   };
 
   class ReferenceTypeBitfields {
     friend class ReferenceType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// True if the type was originally spelled with an lvalue sigil.
     /// This is never true of rvalue references but can also be false
@@ -1768,17 +1788,20 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     ///   ref &&a;             // lvalue, inner ref
     ///   rvref &a;            // lvalue, inner ref, spelled lvalue
     ///   rvref &&a;           // rvalue, inner ref
-    [[clang::preferred_type(bool)]] unsigned SpelledAsLValue : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned SpelledAsLValue : 1;
 
     /// True if the inner type is a reference type.  This only happens
     /// in non-canonical forms.
-    [[clang::preferred_type(bool)]] unsigned InnerRef : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned InnerRef : 1;
   };
 
   class TypeWithKeywordBitfields {
     friend class TypeWithKeyword;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// An ElaboratedTypeKeyword.  8 bits for efficient access.
     unsigned Keyword : 8;
@@ -1789,18 +1812,20 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class ElaboratedTypeBitfields {
     friend class ElaboratedType;
 
-    [[clang::preferred_type(TypeWithKeywordBitfields)]] unsigned
-        : NumTypeWithKeywordBits;
+    [[clang::preferred_type(TypeWithKeywordBitfields)]]
+    unsigned : NumTypeWithKeywordBits;
 
     /// Whether the ElaboratedType has a trailing OwnedTagDecl.
-    [[clang::preferred_type(bool)]] unsigned HasOwnedTagDecl : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned HasOwnedTagDecl : 1;
   };
 
   class VectorTypeBitfields {
     friend class VectorType;
     friend class DependentVectorType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// The kind of vector, either a generic vector type or some
     /// target-specific vector type such as for AltiVec or Neon.
@@ -1812,7 +1837,8 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class AttributedTypeBitfields {
     friend class AttributedType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// An AttributedType::Kind
     unsigned AttrKind : 32 - NumTypeBits;
@@ -1821,11 +1847,13 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class AutoTypeBitfields {
     friend class AutoType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// Was this placeholder type spelled as 'auto', 'decltype(auto)',
     /// or '__auto_type'?  AutoTypeKeyword value.
-    [[clang::preferred_type(AutoTypeKeyword)]] unsigned Keyword : 2;
+    [[clang::preferred_type(AutoTypeKeyword)]]
+    unsigned Keyword : 2;
 
     /// The number of template arguments in the type-constraints, which is
     /// expected to be able to hold at least 1024 according to [implimits].
@@ -1841,9 +1869,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     friend class TypeOfType;
     friend class TypeOfExprType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
-    [[clang::preferred_type(
-        bool)]] unsigned IsUnqual : 1; // If true: typeof_unqual, else: typeof
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
+    [[clang::preferred_type(bool)]]
+    unsigned IsUnqual : 1; // If true: typeof_unqual, else: typeof
   };
 
   class UsingBitfields {
@@ -1852,24 +1881,29 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
 
     /// True if the underlying type is different from the declared one.
-    [[clang::preferred_type(bool)]] unsigned hasTypeDifferentFromDecl : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned hasTypeDifferentFromDecl : 1;
   };
 
   class TypedefBitfields {
     friend class TypedefType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// True if the underlying type is different from the declared one.
-    [[clang::preferred_type(bool)]] unsigned hasTypeDifferentFromDecl : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned hasTypeDifferentFromDecl : 1;
   };
 
   class SubstTemplateTypeParmTypeBitfields {
     friend class SubstTemplateTypeParmType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
-    [[clang::preferred_type(bool)]] unsigned HasNonCanonicalUnderlyingType : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned HasNonCanonicalUnderlyingType : 1;
 
     // The index of the template parameter this substitution represents.
     unsigned Index : 15;
@@ -1885,7 +1919,8 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class SubstTemplateTypeParmPackTypeBitfields {
     friend class SubstTemplateTypeParmPackType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     // The index of the template parameter this substitution represents.
     unsigned Index : 16;
@@ -1900,10 +1935,12 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class TemplateSpecializationTypeBitfields {
     friend class TemplateSpecializationType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// Whether this template specialization type is a substituted type alias.
-    [[clang::preferred_type(bool)]] unsigned TypeAlias : 1;
+    [[clang::preferred_type(bool)]]
+    unsigned TypeAlias : 1;
 
     /// The number of template arguments named in this class template
     /// specialization, which is expected to be able to hold at least 1024
@@ -1933,7 +1970,8 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   class PackExpansionTypeBitfields {
     friend class PackExpansionType;
 
-    [[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
+    [[clang::preferred_type(TypeBitfields)]]
+    unsigned : NumTypeBits;
 
     /// The number of expansions that this pack expansion will
     /// generate when substituted (+1), which is expected to be able to



More information about the cfe-commits mailing list