diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-04-30 13:56:41 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-04-30 13:56:41 +0000 |
commit | dc7a4f5d7a7e3b60d4dc4a80338d7a2728540998 (patch) | |
tree | 0fdbc7f2427ae39e5c561332fb0d7c04e4dcb65b /lib/AST/ASTContext.cpp | |
parent | 24cb36d9c212f82b3d9aedd34be27ae4911bfdba (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/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index de6a30a981..49a470eace 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1597,7 +1597,8 @@ ASTContext::getTypeInfoImpl(const Type *T) const { case Type::Auto: { const AutoType *A = cast<AutoType>(T); - assert(A->isDeduced() && "Cannot request the size of a dependent type"); + assert(!A->getDeducedType().isNull() && + "cannot request the size of an undeduced or dependent auto type"); return getTypeInfo(A->getDeducedType().getTypePtr()); } @@ -3564,18 +3565,20 @@ QualType ASTContext::getUnaryTransformType(QualType BaseType, /// getAutoType - We only unique auto types after they've been deduced. QualType ASTContext::getAutoType(QualType DeducedType, - bool IsDecltypeAuto) const { + bool IsDecltypeAuto, + bool IsDependent) const { void *InsertPos = 0; if (!DeducedType.isNull()) { // Look in the folding set for an existing type. llvm::FoldingSetNodeID ID; - AutoType::Profile(ID, DeducedType, IsDecltypeAuto); + AutoType::Profile(ID, DeducedType, IsDecltypeAuto, IsDependent); if (AutoType *AT = AutoTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(AT, 0); } AutoType *AT = new (*this, TypeAlignment) AutoType(DeducedType, - IsDecltypeAuto); + IsDecltypeAuto, + IsDependent); Types.push_back(AT); if (InsertPos) AutoTypes.InsertNode(AT, InsertPos); @@ -5387,6 +5390,11 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, // FIXME. We should do a better job than gcc. return; + case Type::Auto: + // We could see an undeduced auto type here during error recovery. + // Just ignore it. + return; + #define ABSTRACT_TYPE(KIND, BASE) #define TYPE(KIND, BASE) #define DEPENDENT_TYPE(KIND, BASE) \ @@ -7028,6 +7036,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, #include "clang/AST/TypeNodes.def" llvm_unreachable("Non-canonical and dependent types shouldn't get here"); + case Type::Auto: case Type::LValueReference: case Type::RValueReference: case Type::MemberPointer: |