Skip to content

Commit 7329f68

Browse files
committed
[clang][NFC] Annotate Type bit-fields with clang::preferred_type
1 parent a349092 commit 7329f68

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

clang/include/clang/AST/DeclBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ExternalSourceSymbolAttr;
4949
class FunctionDecl;
5050
class FunctionType;
5151
class IdentifierInfo;
52-
enum Linkage : unsigned char;
52+
enum Linkage : unsigned;
5353
class LinkageSpecDecl;
5454
class Module;
5555
class NamedDecl;

clang/include/clang/AST/DependenceFlags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct ExprDependenceScope {
4949
using ExprDependence = ExprDependenceScope::ExprDependence;
5050

5151
struct TypeDependenceScope {
52-
enum TypeDependence : uint8_t {
52+
enum TypeDependence : unsigned {
5353
/// Whether this type contains an unexpanded parameter pack
5454
/// (for C++11 variadic templates)
5555
UnexpandedPack = 1,

clang/include/clang/AST/Type.h

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,22 +1611,28 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
16111611
template <class T> friend class TypePropertyCache;
16121612

16131613
/// TypeClass bitfield - Enum that specifies what subclass this belongs to.
1614+
[[clang::preferred_type(TypeClass)]]
16141615
unsigned TC : 8;
16151616

16161617
/// Store information on the type dependency.
1618+
[[clang::preferred_type(TypeDependence)]]
16171619
unsigned Dependence : llvm::BitWidth<TypeDependence>;
16181620

16191621
/// True if the cache (i.e. the bitfields here starting with
16201622
/// 'Cache') is valid.
1623+
[[clang::preferred_type(bool)]]
16211624
mutable unsigned CacheValid : 1;
16221625

16231626
/// Linkage of this type.
1627+
[[clang::preferred_type(Linkage)]]
16241628
mutable unsigned CachedLinkage : 3;
16251629

16261630
/// Whether this type involves and local or unnamed types.
1631+
[[clang::preferred_type(bool)]]
16271632
mutable unsigned CachedLocalOrUnnamed : 1;
16281633

16291634
/// Whether this type comes from an AST file.
1635+
[[clang::preferred_type(bool)]]
16301636
mutable unsigned FromAST : 1;
16311637

16321638
bool isCacheValid() const {
@@ -1652,10 +1658,12 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
16521658
class ArrayTypeBitfields {
16531659
friend class ArrayType;
16541660

1661+
[[clang::preferred_type(TypeBitfields)]]
16551662
unsigned : NumTypeBits;
16561663

16571664
/// CVR qualifiers from declarations like
16581665
/// 'int X[static restrict 4]'. For function parameters only.
1666+
[[clang::preferred_type(Qualifiers)]]
16591667
unsigned IndexTypeQuals : 3;
16601668

16611669
/// Storage class qualifiers from declarations like
@@ -1671,12 +1679,14 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
16711679
unsigned : NumArrayTypeBits;
16721680

16731681
/// Whether we have a stored size expression.
1682+
[[clang::preferred_type(bool)]]
16741683
unsigned HasStoredSizeExpr : 1;
16751684
};
16761685

16771686
class BuiltinTypeBitfields {
16781687
friend class BuiltinType;
16791688

1689+
[[clang::preferred_type(TypeBitfields)]]
16801690
unsigned : NumTypeBits;
16811691

16821692
/// The kind (BuiltinType::Kind) of builtin type this is.
@@ -1691,15 +1701,18 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
16911701
friend class FunctionProtoType;
16921702
friend class FunctionType;
16931703

1704+
[[clang::preferred_type(TypeBitfields)]]
16941705
unsigned : NumTypeBits;
16951706

16961707
/// Extra information which affects how the function is called, like
16971708
/// regparm and the calling convention.
1709+
[[clang::preferred_type(CallingConv)]]
16981710
unsigned ExtInfo : 13;
16991711

17001712
/// The ref-qualifier associated with a \c FunctionProtoType.
17011713
///
17021714
/// This is a value of type \c RefQualifierKind.
1715+
[[clang::preferred_type(RefQualifierKind)]]
17031716
unsigned RefQualifier : 2;
17041717

17051718
/// Used only by FunctionProtoType, put here to pack with the
@@ -1708,8 +1721,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
17081721
///
17091722
/// C++ 8.3.5p4: The return type, the parameter type list and the
17101723
/// cv-qualifier-seq, [...], are part of the function type.
1724+
[[clang::preferred_type(Qualifiers)]]
17111725
unsigned FastTypeQuals : Qualifiers::FastWidth;
17121726
/// Whether this function has extended Qualifiers.
1727+
[[clang::preferred_type(bool)]]
17131728
unsigned HasExtQuals : 1;
17141729

17151730
/// The number of parameters this function has, not counting '...'.
@@ -1719,24 +1734,30 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
17191734
unsigned NumParams : 16;
17201735

17211736
/// The type of exception specification this function has.
1737+
[[clang::preferred_type(ExceptionSpecificationType)]]
17221738
unsigned ExceptionSpecType : 4;
17231739

17241740
/// Whether this function has extended parameter information.
1741+
[[clang::preferred_type(bool)]]
17251742
unsigned HasExtParameterInfos : 1;
17261743

17271744
/// Whether this function has extra bitfields for the prototype.
1745+
[[clang::preferred_type(bool)]]
17281746
unsigned HasExtraBitfields : 1;
17291747

17301748
/// Whether the function is variadic.
1749+
[[clang::preferred_type(bool)]]
17311750
unsigned Variadic : 1;
17321751

17331752
/// Whether this function has a trailing return type.
1753+
[[clang::preferred_type(bool)]]
17341754
unsigned HasTrailingReturn : 1;
17351755
};
17361756

17371757
class ObjCObjectTypeBitfields {
17381758
friend class ObjCObjectType;
17391759

1760+
[[clang::preferred_type(TypeBitfields)]]
17401761
unsigned : NumTypeBits;
17411762

17421763
/// The number of type arguments stored directly on this object type.
@@ -1746,12 +1767,14 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
17461767
unsigned NumProtocols : 6;
17471768

17481769
/// Whether this is a "kindof" type.
1770+
[[clang::preferred_type(bool)]]
17491771
unsigned IsKindOf : 1;
17501772
};
17511773

17521774
class ReferenceTypeBitfields {
17531775
friend class ReferenceType;
17541776

1777+
[[clang::preferred_type(TypeBitfields)]]
17551778
unsigned : NumTypeBits;
17561779

17571780
/// True if the type was originally spelled with an lvalue sigil.
@@ -1765,16 +1788,19 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
17651788
/// ref &&a; // lvalue, inner ref
17661789
/// rvref &a; // lvalue, inner ref, spelled lvalue
17671790
/// rvref &&a; // rvalue, inner ref
1791+
[[clang::preferred_type(bool)]]
17681792
unsigned SpelledAsLValue : 1;
17691793

17701794
/// True if the inner type is a reference type. This only happens
17711795
/// in non-canonical forms.
1796+
[[clang::preferred_type(bool)]]
17721797
unsigned InnerRef : 1;
17731798
};
17741799

17751800
class TypeWithKeywordBitfields {
17761801
friend class TypeWithKeyword;
17771802

1803+
[[clang::preferred_type(TypeBitfields)]]
17781804
unsigned : NumTypeBits;
17791805

17801806
/// An ElaboratedTypeKeyword. 8 bits for efficient access.
@@ -1786,17 +1812,19 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
17861812
class ElaboratedTypeBitfields {
17871813
friend class ElaboratedType;
17881814

1789-
unsigned : NumTypeBits;
1815+
[[clang::preferred_type(TypeWithKeywordBitfields)]]
17901816
unsigned : NumTypeWithKeywordBits;
17911817

17921818
/// Whether the ElaboratedType has a trailing OwnedTagDecl.
1819+
[[clang::preferred_type(bool)]]
17931820
unsigned HasOwnedTagDecl : 1;
17941821
};
17951822

17961823
class VectorTypeBitfields {
17971824
friend class VectorType;
17981825
friend class DependentVectorType;
17991826

1827+
[[clang::preferred_type(TypeBitfields)]]
18001828
unsigned : NumTypeBits;
18011829

18021830
/// The kind of vector, either a generic vector type or some
@@ -1809,6 +1837,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
18091837
class AttributedTypeBitfields {
18101838
friend class AttributedType;
18111839

1840+
[[clang::preferred_type(TypeBitfields)]]
18121841
unsigned : NumTypeBits;
18131842

18141843
/// An AttributedType::Kind
@@ -1818,10 +1847,12 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
18181847
class AutoTypeBitfields {
18191848
friend class AutoType;
18201849

1850+
[[clang::preferred_type(TypeBitfields)]]
18211851
unsigned : NumTypeBits;
18221852

18231853
/// Was this placeholder type spelled as 'auto', 'decltype(auto)',
18241854
/// or '__auto_type'? AutoTypeKeyword value.
1855+
[[clang::preferred_type(AutoTypeKeyword)]]
18251856
unsigned Keyword : 2;
18261857

18271858
/// The number of template arguments in the type-constraints, which is
@@ -1838,33 +1869,40 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
18381869
friend class TypeOfType;
18391870
friend class TypeOfExprType;
18401871

1872+
[[clang::preferred_type(TypeBitfields)]]
18411873
unsigned : NumTypeBits;
1874+
[[clang::preferred_type(bool)]]
18421875
unsigned IsUnqual : 1; // If true: typeof_unqual, else: typeof
18431876
};
18441877

18451878
class UsingBitfields {
18461879
friend class UsingType;
18471880

1848-
unsigned : NumTypeBits;
1881+
[[clang::preferred_type(TypeBitfields)]] unsigned : NumTypeBits;
18491882

18501883
/// True if the underlying type is different from the declared one.
1884+
[[clang::preferred_type(bool)]]
18511885
unsigned hasTypeDifferentFromDecl : 1;
18521886
};
18531887

18541888
class TypedefBitfields {
18551889
friend class TypedefType;
18561890

1891+
[[clang::preferred_type(TypeBitfields)]]
18571892
unsigned : NumTypeBits;
18581893

18591894
/// True if the underlying type is different from the declared one.
1895+
[[clang::preferred_type(bool)]]
18601896
unsigned hasTypeDifferentFromDecl : 1;
18611897
};
18621898

18631899
class SubstTemplateTypeParmTypeBitfields {
18641900
friend class SubstTemplateTypeParmType;
18651901

1902+
[[clang::preferred_type(TypeBitfields)]]
18661903
unsigned : NumTypeBits;
18671904

1905+
[[clang::preferred_type(bool)]]
18681906
unsigned HasNonCanonicalUnderlyingType : 1;
18691907

18701908
// The index of the template parameter this substitution represents.
@@ -1881,6 +1919,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
18811919
class SubstTemplateTypeParmPackTypeBitfields {
18821920
friend class SubstTemplateTypeParmPackType;
18831921

1922+
[[clang::preferred_type(TypeBitfields)]]
18841923
unsigned : NumTypeBits;
18851924

18861925
// The index of the template parameter this substitution represents.
@@ -1896,9 +1935,11 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
18961935
class TemplateSpecializationTypeBitfields {
18971936
friend class TemplateSpecializationType;
18981937

1938+
[[clang::preferred_type(TypeBitfields)]]
18991939
unsigned : NumTypeBits;
19001940

19011941
/// Whether this template specialization type is a substituted type alias.
1942+
[[clang::preferred_type(bool)]]
19021943
unsigned TypeAlias : 1;
19031944

19041945
/// The number of template arguments named in this class template
@@ -1929,6 +1970,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
19291970
class PackExpansionTypeBitfields {
19301971
friend class PackExpansionType;
19311972

1973+
[[clang::preferred_type(TypeBitfields)]]
19321974
unsigned : NumTypeBits;
19331975

19341976
/// The number of expansions that this pack expansion will

clang/include/clang/Basic/Linkage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace clang {
2020

2121
/// Describes the different kinds of linkage
2222
/// (C++ [basic.link], C99 6.2.2) that an entity may have.
23-
enum Linkage : unsigned char {
23+
enum Linkage : unsigned {
2424
/// No linkage, which means that the entity is unique and
2525
/// can only be referred to from within its scope.
2626
NoLinkage = 0,

0 commit comments

Comments
 (0)