diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 70f61cb04101..98e2b6fb469c 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/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/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 378339242a61..bb79b9b57bf8 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/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) {