aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-04-30 13:56:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-04-30 13:56:41 +0000
commitdc7a4f5d7a7e3b60d4dc4a80338d7a2728540998 (patch)
tree0fdbc7f2427ae39e5c561332fb0d7c04e4dcb65b /lib/Sema/SemaTemplateDeduction.cpp
parent24cb36d9c212f82b3d9aedd34be27ae4911bfdba (diff)
Don't treat a non-deduced 'auto' type as being type-dependent. Instead, there
are now two distinct canonical 'AutoType's: one is the undeduced 'auto' placeholder type, and the other is a deduced-but-dependent type. All deduced-to-a-non-dependent-type cases are still non-canonical. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180789 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp52
1 files changed, 13 insertions, 39 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index a681371c9b..ea5b145871 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -3584,8 +3584,12 @@ namespace {
NewTL.setNameLoc(TL.getNameLoc());
return Result;
} else {
- QualType Result = RebuildAutoType(Replacement,
- TL.getTypePtr()->isDecltypeAuto());
+ bool Dependent =
+ !Replacement.isNull() && Replacement->isDependentType();
+ QualType Result =
+ SemaRef.Context.getAutoType(Dependent ? QualType() : Replacement,
+ TL.getTypePtr()->isDecltypeAuto(),
+ Dependent);
AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
NewTL.setNameLoc(TL.getNameLoc());
return Result;
@@ -3597,41 +3601,6 @@ namespace {
return E;
}
};
-
- /// Determine whether the specified type (which contains an 'auto' type
- /// specifier) is dependent. This is not trivial, because the 'auto' specifier
- /// itself claims to be type-dependent.
- bool isDependentAutoType(QualType Ty) {
- while (1) {
- QualType Pointee = Ty->getPointeeType();
- if (!Pointee.isNull()) {
- Ty = Pointee;
- } else if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>()){
- if (MPT->getClass()->isDependentType())
- return true;
- Ty = MPT->getPointeeType();
- } else if (const FunctionProtoType *FPT = Ty->getAs<FunctionProtoType>()){
- for (FunctionProtoType::arg_type_iterator I = FPT->arg_type_begin(),
- E = FPT->arg_type_end();
- I != E; ++I)
- if ((*I)->isDependentType())
- return true;
- Ty = FPT->getResultType();
- } else if (Ty->isDependentSizedArrayType()) {
- return true;
- } else if (const ArrayType *AT = Ty->getAsArrayTypeUnsafe()) {
- Ty = AT->getElementType();
- } else if (Ty->getAs<DependentSizedExtVectorType>()) {
- return true;
- } else if (const VectorType *VT = Ty->getAs<VectorType>()) {
- Ty = VT->getElementType();
- } else {
- break;
- }
- }
- assert(Ty->getAs<AutoType>() && "didn't find 'auto' in auto type");
- return false;
- }
}
/// \brief Deduce the type for an auto type-specifier (C++0x [dcl.spec.auto]p6)
@@ -3654,8 +3623,9 @@ Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *&Init,
Init = result.take();
}
- if (Init->isTypeDependent() || isDependentAutoType(Type->getType())) {
- Result = Type;
+ if (Init->isTypeDependent() || Type->getType()->isDependentType()) {
+ Result =
+ SubstituteAutoTransform(*this, Context.DependentTy).TransformType(Type);
return DAR_Succeeded;
}
@@ -3749,6 +3719,10 @@ Sema::DeduceAutoType(TypeSourceInfo *Type, Expr *&Init,
return DAR_Succeeded;
}
+QualType Sema::SubstAutoType(QualType Type, QualType Deduced) {
+ return SubstituteAutoTransform(*this, Deduced).TransformType(Type);
+}
+
void Sema::DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init) {
if (isa<InitListExpr>(Init))
Diag(VDecl->getLocation(),