From aa46d513f47280a9786e8e9aa77f7089b3f8fee6 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 8 Jan 2013 00:50:27 +0000 Subject: [PATCH] Move ref qualifiers from Type bitfields into FunctionProtoType, stealing two bits from the number of parameters. This brings the bitfields down from 33 bits to 32 bits, reducing the size of Types by 4 bytes on 32-bit systems. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171827 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Type.h | 24 +++++++++--------------- lib/AST/Type.cpp | 7 +++++-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 70f61cb041..98e2b6fb46 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -1274,11 +1274,6 @@ protected: /// C++ 8.3.5p4: The return type, the parameter type list and the /// cv-qualifier-seq, [...], are part of the function type. unsigned TypeQuals : 3; - - /// \brief The ref-qualifier associated with a \c FunctionProtoType. - /// - /// This is a value of type \c RefQualifierKind. - unsigned RefQualifier : 2; }; class ObjCObjectTypeBitfields { @@ -2693,8 +2688,7 @@ class FunctionType : public Type { protected: FunctionType(TypeClass tc, QualType res, - unsigned typeQuals, RefQualifierKind RefQualifier, - QualType Canonical, bool Dependent, + unsigned typeQuals, QualType Canonical, bool Dependent, bool InstantiationDependent, bool VariablyModified, bool ContainsUnexpandedParameterPack, ExtInfo Info) @@ -2703,14 +2697,9 @@ protected: ResultType(res) { FunctionTypeBits.ExtInfo = Info.Bits; FunctionTypeBits.TypeQuals = typeQuals; - FunctionTypeBits.RefQualifier = static_cast(RefQualifier); } unsigned getTypeQuals() const { return FunctionTypeBits.TypeQuals; } - RefQualifierKind getRefQualifier() const { - return static_cast(FunctionTypeBits.RefQualifier); - } - public: QualType getResultType() const { return ResultType; } @@ -2742,7 +2731,7 @@ public: /// no information available about its arguments. class FunctionNoProtoType : public FunctionType, public llvm::FoldingSetNode { FunctionNoProtoType(QualType Result, QualType Canonical, ExtInfo Info) - : FunctionType(FunctionNoProto, Result, 0, RQ_None, Canonical, + : FunctionType(FunctionNoProto, Result, 0, Canonical, /*Dependent=*/false, /*InstantiationDependent=*/false, Result->isVariablyModifiedType(), /*ContainsUnexpandedParameterPack=*/false, Info) {} @@ -2815,7 +2804,7 @@ private: QualType canonical, const ExtProtoInfo &epi); /// NumArgs - The number of arguments this function has, not counting '...'. - unsigned NumArgs : 17; + unsigned NumArgs : 15; /// NumExceptions - The number of types in the exception spec, if any. unsigned NumExceptions : 9; @@ -2832,6 +2821,11 @@ private: /// HasTrailingReturn - Whether this function has a trailing return type. unsigned HasTrailingReturn : 1; + /// \brief The ref-qualifier associated with a \c FunctionProtoType. + /// + /// This is a value of type \c RefQualifierKind. + unsigned RefQualifier : 2; + // ArgInfo - There is an variable size array after the class in memory that // holds the argument types. @@ -2979,7 +2973,7 @@ public: /// \brief Retrieve the ref-qualifier associated with this function type. RefQualifierKind getRefQualifier() const { - return FunctionType::getRefQualifier(); + return static_cast(RefQualifier); } typedef const QualType *arg_type_iterator; diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 378339242a..bb79b9b57b 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1561,7 +1561,7 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) { FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, unsigned numArgs, QualType canonical, const ExtProtoInfo &epi) - : FunctionType(FunctionProto, result, epi.TypeQuals, epi.RefQualifier, + : FunctionType(FunctionProto, result, epi.TypeQuals, canonical, result->isDependentType(), result->isInstantiationDependentType(), @@ -1571,8 +1571,11 @@ FunctionProtoType::FunctionProtoType(QualType result, const QualType *args, NumArgs(numArgs), NumExceptions(epi.NumExceptions), ExceptionSpecType(epi.ExceptionSpecType), HasAnyConsumedArgs(epi.ConsumedArguments != 0), - Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn) + Variadic(epi.Variadic), HasTrailingReturn(epi.HasTrailingReturn), + RefQualifier(epi.RefQualifier) { + assert(NumArgs == numArgs && "function has too many parameters"); + // Fill in the trailing argument array. QualType *argSlot = reinterpret_cast(this+1); for (unsigned i = 0; i != numArgs; ++i) { -- 2.40.0