Skip to content

Commit be19d72

Browse files
committed
Petty space optimizations in ElaboratedType and DependentNameType.
Petty time optimization in TemplateTypeParmType. llvm-svn: 116796
1 parent 1a1b53e commit be19d72

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

clang/include/clang/AST/Type.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,15 @@ class Type {
899899
unsigned InnerRef : 1;
900900
};
901901

902+
class TypeWithKeywordBitfields {
903+
friend class TypeWithKeyword;
904+
905+
unsigned : NumTypeBits;
906+
907+
/// An ElaboratedTypeKeyword. 8 bits for efficient access.
908+
unsigned Keyword : 8;
909+
};
910+
902911
class VectorTypeBitfields {
903912
friend class VectorType;
904913

@@ -919,6 +928,7 @@ class Type {
919928
FunctionTypeBitfields FunctionTypeBits;
920929
ObjCObjectTypeBitfields ObjCObjectTypeBits;
921930
ReferenceTypeBitfields ReferenceTypeBits;
931+
TypeWithKeywordBitfields TypeWithKeywordBits;
922932
VectorTypeBitfields VectorTypeBits;
923933
};
924934

@@ -2486,20 +2496,20 @@ class EnumType : public TagType {
24862496

24872497
class TemplateTypeParmType : public Type, public llvm::FoldingSetNode {
24882498
unsigned Depth : 15;
2489-
unsigned Index : 16;
24902499
unsigned ParameterPack : 1;
2500+
unsigned Index : 16;
24912501
IdentifierInfo *Name;
24922502

24932503
TemplateTypeParmType(unsigned D, unsigned I, bool PP, IdentifierInfo *N,
24942504
QualType Canon)
24952505
: Type(TemplateTypeParm, Canon, /*Dependent=*/true,
24962506
/*VariablyModified=*/false),
2497-
Depth(D), Index(I), ParameterPack(PP), Name(N) { }
2507+
Depth(D), ParameterPack(PP), Index(I), Name(N) { }
24982508

24992509
TemplateTypeParmType(unsigned D, unsigned I, bool PP)
25002510
: Type(TemplateTypeParm, QualType(this, 0), /*Dependent=*/true,
25012511
/*VariablyModified=*/false),
2502-
Depth(D), Index(I), ParameterPack(PP), Name(0) { }
2512+
Depth(D), ParameterPack(PP), Index(I), Name(0) { }
25032513

25042514
friend class ASTContext; // ASTContext creates these
25052515

@@ -2778,20 +2788,18 @@ enum ElaboratedTypeKeyword {
27782788
/// Also provides a few static helpers for converting and printing
27792789
/// elaborated type keyword and tag type kind enumerations.
27802790
class TypeWithKeyword : public Type {
2781-
/// Keyword - Encodes an ElaboratedTypeKeyword enumeration constant.
2782-
unsigned Keyword : 3;
2783-
27842791
protected:
27852792
TypeWithKeyword(ElaboratedTypeKeyword Keyword, TypeClass tc,
27862793
QualType Canonical, bool Dependent, bool VariablyModified)
2787-
: Type(tc, Canonical, Dependent, VariablyModified),
2788-
Keyword(Keyword) {}
2794+
: Type(tc, Canonical, Dependent, VariablyModified) {
2795+
TypeWithKeywordBits.Keyword = Keyword;
2796+
}
27892797

27902798
public:
27912799
virtual ~TypeWithKeyword(); // pin vtable to Type.cpp
27922800

27932801
ElaboratedTypeKeyword getKeyword() const {
2794-
return static_cast<ElaboratedTypeKeyword>(Keyword);
2802+
return static_cast<ElaboratedTypeKeyword>(TypeWithKeywordBits.Keyword);
27952803
}
27962804

27972805
/// getKeywordForTypeSpec - Converts a type specifier (DeclSpec::TST)

0 commit comments

Comments
 (0)