diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/NestedNameSpecifier.cpp | 18 | ||||
-rw-r--r-- | lib/AST/TemplateBase.cpp | 33 | ||||
-rw-r--r-- | lib/AST/TemplateName.cpp | 16 | ||||
-rw-r--r-- | lib/AST/Type.cpp | 86 |
4 files changed, 143 insertions, 10 deletions
diff --git a/lib/AST/NestedNameSpecifier.cpp b/lib/AST/NestedNameSpecifier.cpp index 212def8565..10035acdcf 100644 --- a/lib/AST/NestedNameSpecifier.cpp +++ b/lib/AST/NestedNameSpecifier.cpp @@ -113,6 +113,24 @@ bool NestedNameSpecifier::isDependent() const { return false; } +bool NestedNameSpecifier::containsUnexpandedParameterPack() const { + switch (getKind()) { + case Identifier: + return getPrefix() && getPrefix()->containsUnexpandedParameterPack(); + + case Namespace: + case Global: + return false; + + case TypeSpec: + case TypeSpecWithTemplate: + return getAsType()->containsUnexpandedParameterPack(); + } + + // Necessary to suppress a GCC warning. + return false; +} + /// \brief Print this nested name specifier to the given output /// stream. void diff --git a/lib/AST/TemplateBase.cpp b/lib/AST/TemplateBase.cpp index 4a1ebb46c1..ef2deea8c8 100644 --- a/lib/AST/TemplateBase.cpp +++ b/lib/AST/TemplateBase.cpp @@ -26,6 +26,39 @@ using namespace clang; // TemplateArgument Implementation //===----------------------------------------------------------------------===// +bool TemplateArgument::containsUnexpandedParameterPack() const { + switch (getKind()) { + case Null: + case Declaration: + case Integral: + break; + + case Type: + if (getAsType()->containsUnexpandedParameterPack()) + return true; + break; + + case Template: + if (getAsTemplate().containsUnexpandedParameterPack()) + return true; + break; + + case Expression: + if (getAsExpr()->containsUnexpandedParameterPack()) + return true; + break; + + case Pack: + for (pack_iterator P = pack_begin(), PEnd = pack_end(); P != PEnd; ++P) + if (P->containsUnexpandedParameterPack()) + return true; + + break; + } + + return false; +} + void TemplateArgument::Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context) const { ID.AddInteger(Kind); diff --git a/lib/AST/TemplateName.cpp b/lib/AST/TemplateName.cpp index 439f4e81ad..73ff402b07 100644 --- a/lib/AST/TemplateName.cpp +++ b/lib/AST/TemplateName.cpp @@ -60,6 +60,22 @@ bool TemplateName::isDependent() const { return true; } +bool TemplateName::containsUnexpandedParameterPack() const { + if (TemplateDecl *Template = getAsTemplateDecl()) { + if (TemplateTemplateParmDecl *TTP + = dyn_cast<TemplateTemplateParmDecl>(Template)) + return TTP->isParameterPack(); + + return false; + } + + if (DependentTemplateName *DTN = getAsDependentTemplateName()) + return DTN->getQualifier() && + DTN->getQualifier()->containsUnexpandedParameterPack(); + + return false; +} + void TemplateName::print(llvm::raw_ostream &OS, const PrintingPolicy &Policy, bool SuppressNNS) const { diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index ed05a39305..127613ed32 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -63,6 +63,18 @@ unsigned ConstantArrayType::getMaxSizeBits(ASTContext &Context) { return Bits; } +DependentSizedArrayType::DependentSizedArrayType(ASTContext &Context, + QualType et, QualType can, + Expr *e, ArraySizeModifier sm, + unsigned tq, + SourceRange brackets) + : ArrayType(DependentSizedArray, et, can, sm, tq, + (et->containsUnexpandedParameterPack() || + (e && e->containsUnexpandedParameterPack()))), + Context(Context), SizeExpr((Stmt*) e), Brackets(brackets) +{ +} + void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, QualType ET, @@ -75,6 +87,20 @@ void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID, E->Profile(ID, Context, true); } +DependentSizedExtVectorType::DependentSizedExtVectorType(ASTContext &Context, + QualType ElementType, + QualType can, + Expr *SizeExpr, + SourceLocation loc) + : Type(DependentSizedExtVector, can, /*Dependent=*/true, + ElementType->isVariablyModifiedType(), + (ElementType->containsUnexpandedParameterPack() || + (SizeExpr && SizeExpr->containsUnexpandedParameterPack()))), + Context(Context), SizeExpr(SizeExpr), ElementType(ElementType), + loc(loc) +{ +} + void DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context, @@ -83,6 +109,28 @@ DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID, SizeExpr->Profile(ID, Context, true); } +VectorType::VectorType(QualType vecType, unsigned nElements, QualType canonType, + VectorKind vecKind) + : Type(Vector, canonType, vecType->isDependentType(), + vecType->isVariablyModifiedType(), + vecType->containsUnexpandedParameterPack()), + ElementType(vecType) +{ + VectorTypeBits.VecKind = vecKind; + VectorTypeBits.NumElements = nElements; +} + +VectorType::VectorType(TypeClass tc, QualType vecType, unsigned nElements, + QualType canonType, VectorKind vecKind) + : Type(tc, canonType, vecType->isDependentType(), + vecType->isVariablyModifiedType(), + vecType->containsUnexpandedParameterPack()), + ElementType(vecType) +{ + VectorTypeBits.VecKind = vecKind; + VectorTypeBits.NumElements = nElements; +} + /// getArrayElementTypeNoTypeQual - If this is an array type, return the /// element type of the array, potentially with type qualifiers missing. /// This method should never be used when type qualifiers are meaningful. @@ -321,8 +369,9 @@ const RecordType *Type::getAsUnionType() const { ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base, ObjCProtocolDecl * const *Protocols, unsigned NumProtocols) - : Type(ObjCObject, Canonical, false, false), - BaseType(Base) { + : Type(ObjCObject, Canonical, false, false, false), + BaseType(Base) +{ ObjCObjectTypeBits.NumProtocols = NumProtocols; assert(getNumProtocols() == NumProtocols && "bitfield overflow in protocol count"); @@ -924,12 +973,17 @@ DependentTemplateSpecializationType::DependentTemplateSpecializationType( unsigned NumArgs, const TemplateArgument *Args, QualType Canon) : TypeWithKeyword(Keyword, DependentTemplateSpecialization, Canon, true, - false), + /*VariablyModified=*/false, + NNS->containsUnexpandedParameterPack()), NNS(NNS), Name(Name), NumArgs(NumArgs) { assert(NNS && NNS->isDependent() && "DependentTemplateSpecializatonType requires dependent qualifier"); - for (unsigned I = 0; I != NumArgs; ++I) + for (unsigned I = 0; I != NumArgs; ++I) { + if (Args[I].containsUnexpandedParameterPack()) + setContainsUnexpandedParameterPack(); + new (&getArgBuffer()[I]) TemplateArgument(Args[I]); + } } void @@ -1052,6 +1106,7 @@ FunctionProtoType::FunctionProtoType(QualType Result, const QualType *ArgArray, : FunctionType(FunctionProto, Result, isVariadic, typeQuals, Canonical, Result->isDependentType(), Result->isVariablyModifiedType(), + Result->containsUnexpandedParameterPack(), Info), NumArgs(numArgs), NumExceptions(numExs), HasExceptionSpec(hasExs), AnyExceptionSpec(hasAnyExs) @@ -1061,7 +1116,10 @@ FunctionProtoType::FunctionProtoType(QualType Result, const QualType *ArgArray, for (unsigned i = 0; i != numArgs; ++i) { if (ArgArray[i]->isDependentType()) setDependent(); - + + if (ArgArray[i]->containsUnexpandedParameterPack()) + setContainsUnexpandedParameterPack(); + ArgInfo[i] = ArgArray[i]; } @@ -1106,7 +1164,9 @@ QualType TypedefType::desugar() const { TypeOfExprType::TypeOfExprType(Expr *E, QualType can) : Type(TypeOfExpr, can, E->isTypeDependent(), - E->getType()->isVariablyModifiedType()), TOExpr(E) { + E->getType()->isVariablyModifiedType(), + E->containsUnexpandedParameterPack()), + TOExpr(E) { } QualType TypeOfExprType::desugar() const { @@ -1120,7 +1180,9 @@ void DependentTypeOfExprType::Profile(llvm::FoldingSetNodeID &ID, DecltypeType::DecltypeType(Expr *E, QualType underlyingType, QualType can) : Type(Decltype, can, E->isTypeDependent(), - E->getType()->isVariablyModifiedType()), E(E), + E->getType()->isVariablyModifiedType(), + E->containsUnexpandedParameterPack()), + E(E), UnderlyingType(underlyingType) { } @@ -1133,7 +1195,8 @@ void DependentDecltypeType::Profile(llvm::FoldingSetNodeID &ID, } TagType::TagType(TypeClass TC, const TagDecl *D, QualType can) - : Type(TC, can, D->isDependentType(), /*VariablyModified=*/false), + : Type(TC, can, D->isDependentType(), /*VariablyModified=*/false, + /*ContainsUnexpandedParameterPack=*/false), decl(const_cast<TagDecl*>(D)) {} static TagDecl *getInterestingTagDecl(TagDecl *decl) { @@ -1233,7 +1296,8 @@ TemplateSpecializationType(TemplateName T, unsigned NumArgs, QualType Canon) : Type(TemplateSpecialization, Canon.isNull()? QualType(this, 0) : Canon, - T.isDependent(), false), + T.isDependent(), false, + T.containsUnexpandedParameterPack()), Template(T), NumArgs(NumArgs) { assert((!Canon.isNull() || @@ -1249,7 +1313,9 @@ TemplateSpecializationType(TemplateName T, if (Args[Arg].getKind() == TemplateArgument::Type && Args[Arg].getAsType()->isVariablyModifiedType()) setVariablyModified(); - + if (Args[Arg].containsUnexpandedParameterPack()) + setContainsUnexpandedParameterPack(); + new (&TemplateArgs[Arg]) TemplateArgument(Args[Arg]); } } |