diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-02-20 03:19:35 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-02-20 03:19:35 +0000 |
| commit | 30482bc78659a3bf2bc8515bff417bc9887e9349 (patch) | |
| tree | b4b027ed95b4cb5438999e65259a7b1970e3800d /clang/lib/AST/ASTContext.cpp | |
| parent | ba1186c23e31207c2e11866beb978bd966a45e19 (diff) | |
| download | bcm5719-llvm-30482bc78659a3bf2bc8515bff417bc9887e9349.tar.gz bcm5719-llvm-30482bc78659a3bf2bc8515bff417bc9887e9349.zip | |
Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.
llvm-svn: 126069
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 50c295f241f..945dfb87f29 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -380,10 +380,6 @@ void ASTContext::InitBuiltinTypes() { // Placeholder type for functions. InitBuiltinType(OverloadTy, BuiltinType::Overload); - // Placeholder type for C++0x auto declarations whose real type has - // not yet been deduced. - InitBuiltinType(UndeducedAutoTy, BuiltinType::UndeducedAuto); - // C99 6.2.5p11. FloatComplexTy = getComplexType(FloatTy); DoubleComplexTy = getComplexType(DoubleTy); @@ -875,6 +871,12 @@ ASTContext::getTypeInfo(const Type *T) const { return getTypeInfo(cast<SubstTemplateTypeParmType>(T)-> getReplacementType().getTypePtr()); + case Type::Auto: { + const AutoType *A = cast<AutoType>(T); + assert(A->isDeduced() && "Cannot request the size of a dependent type"); + return getTypeInfo(cast<AutoType>(T)->getDeducedType().getTypePtr()); + } + case Type::Paren: return getTypeInfo(cast<ParenType>(T)->getInnerType().getTypePtr()); @@ -1532,6 +1534,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { case Type::DependentTemplateSpecialization: case Type::TemplateTypeParm: case Type::SubstTemplateTypeParmPack: + case Type::Auto: case Type::PackExpansion: llvm_unreachable("type should never be variably-modified"); @@ -2680,6 +2683,14 @@ QualType ASTContext::getDecltypeType(Expr *e) const { return QualType(dt, 0); } +/// getAutoType - Unlike many "get<Type>" functions, we don't unique +/// AutoType AST's. +QualType ASTContext::getAutoType(QualType DeducedType) const { + AutoType *at = new (*this, TypeAlignment) AutoType(DeducedType); + Types.push_back(at); + return QualType(at, 0); +} + /// getTagDeclType - Return the unique reference to the type for the /// specified TagDecl (struct/union/class/enum) decl. QualType ASTContext::getTagDeclType(const TagDecl *Decl) const { |

