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 | 34b41d939a1328f484511c6002ba2456db879a29 (patch) | |
tree | 9631c2ce7dde0b9c680fe463d5718d0cb8f92e45 /lib/AST/TypePrinter.cpp | |
parent | 9ed9a250180f19b2c44df83a196fc3a2ac82f817 (diff) |
Implement the C++0x deduced 'auto' feature.
This fixes PR 8738, 9060 and 9132.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126069 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/TypePrinter.cpp')
-rw-r--r-- | lib/AST/TypePrinter.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 5e6046acdc..139073987a 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -80,6 +80,8 @@ void TypePrinter::print(const Type *T, Qualifiers Quals, std::string &buffer) { bool CanPrefixQualifiers = false; Type::TypeClass TC = T->getTypeClass(); + if (const AutoType *AT = dyn_cast<AutoType>(T)) + TC = AT->desugar()->getTypeClass(); if (const SubstTemplateTypeParmType *Subst = dyn_cast<SubstTemplateTypeParmType>(T)) TC = Subst->getReplacementType()->getTypeClass(); @@ -129,6 +131,7 @@ void TypePrinter::print(const Type *T, Qualifiers Quals, std::string &buffer) { case Type::Attributed: case Type::PackExpansion: case Type::SubstTemplateTypeParm: + case Type::Auto: CanPrefixQualifiers = false; break; } @@ -493,6 +496,17 @@ void TypePrinter::printDecltype(const DecltypeType *T, std::string &S) { S = "decltype(" + s.str() + ")" + S; } +void TypePrinter::printAuto(const AutoType *T, std::string &S) { + // If the type has been deduced, do not print 'auto'. + if (T->isDeduced()) { + print(T->getDeducedType(), S); + } else { + if (!S.empty()) // Prefix the basic type, e.g. 'auto X'. + S = ' ' + S; + S = "auto" + S; + } +} + /// Appends the given scope to the end of a string. void TypePrinter::AppendScope(DeclContext *DC, std::string &Buffer) { if (DC->isTranslationUnit()) return; |