[cfe-commits] r171827 - in /cfe/trunk: include/clang/AST/Type.h lib/AST/Type.cpp
Richard Smith
richard at metafoo.co.uk
Mon Jan 7 20:21:37 PST 2013
On Mon, Jan 7, 2013 at 8:18 PM, Rafael EspĂndola
<rafael.espindola at gmail.com> wrote:
> On 7 January 2013 19:50, Richard Smith <richard-llvm at metafoo.co.uk> wrote:
>> Author: rsmith
>> Date: Mon Jan 7 18:50:27 2013
>> New Revision: 171827
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=171827&view=rev
>> Log:
>> 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.
>
> Should we add static asserts about the size of some really important classes?
This seems like a good idea to me. Does LLVM have a static assert
facility already?
>> Modified:
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/lib/AST/Type.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Type.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=171827&r1=171826&r2=171827&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/AST/Type.h (original)
>> +++ cfe/trunk/include/clang/AST/Type.h Mon Jan 7 18:50:27 2013
>> @@ -1274,11 +1274,6 @@
>> /// 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 @@
>>
>> 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 @@
>> ResultType(res) {
>> FunctionTypeBits.ExtInfo = Info.Bits;
>> FunctionTypeBits.TypeQuals = typeQuals;
>> - FunctionTypeBits.RefQualifier = static_cast<unsigned>(RefQualifier);
>> }
>> unsigned getTypeQuals() const { return FunctionTypeBits.TypeQuals; }
>>
>> - RefQualifierKind getRefQualifier() const {
>> - return static_cast<RefQualifierKind>(FunctionTypeBits.RefQualifier);
>> - }
>> -
>> public:
>>
>> QualType getResultType() const { return ResultType; }
>> @@ -2742,7 +2731,7 @@
>> /// 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 @@
>> 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 @@
>> /// 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 @@
>>
>> /// \brief Retrieve the ref-qualifier associated with this function type.
>> RefQualifierKind getRefQualifier() const {
>> - return FunctionType::getRefQualifier();
>> + return static_cast<RefQualifierKind>(RefQualifier);
>> }
>>
>> typedef const QualType *arg_type_iterator;
>>
>> Modified: cfe/trunk/lib/AST/Type.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=171827&r1=171826&r2=171827&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/AST/Type.cpp (original)
>> +++ cfe/trunk/lib/AST/Type.cpp Mon Jan 7 18:50:27 2013
>> @@ -1561,7 +1561,7 @@
>> 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 @@
>> 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<QualType*>(this+1);
>> for (unsigned i = 0; i != numArgs; ++i) {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list