From 4ebdf5c4f587daef4e0be499802eac3a7a49bf2f Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sat, 27 Jun 2009 10:45:02 +0000 Subject: Import Clang r74383. --- lib/AST/Type.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/AST/Type.cpp') diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 7b45b21e5d0c..41536612fec8 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -112,6 +112,8 @@ QualType Type::getDesugaredType(bool ForDisplay) const { return TOE->getUnderlyingExpr()->getType().getDesugaredType(); if (const TypeOfType *TOT = dyn_cast(this)) return TOT->getUnderlyingType().getDesugaredType(); + if (const DecltypeType *DTT = dyn_cast(this)) + return DTT->getUnderlyingExpr()->getType().getDesugaredType(); if (const TemplateSpecializationType *Spec = dyn_cast(this)) { if (ForDisplay) @@ -962,6 +964,7 @@ const char *BuiltinType::getName(bool CPlusPlus) const { case NullPtr: return "nullptr_t"; case Overload: return ""; case Dependent: return ""; + case UndeducedAuto: return ""; } } @@ -1052,6 +1055,13 @@ TypeOfExprType::TypeOfExprType(Expr *E, QualType can) assert(!isa(can) && "Invalid canonical type"); } +DecltypeType::DecltypeType(Expr *E, QualType can) + : Type(Decltype, can, E->isTypeDependent()), E(E) { + assert(can->isDependentType() == E->isTypeDependent() && + "type dependency mismatch!"); + assert(!isa(can) && "Invalid canonical type"); +} + TagType::TagType(TypeClass TC, TagDecl *D, QualType can) : Type(TC, can, D->isDependentType()), decl(D, 0) {} @@ -1421,6 +1431,16 @@ void TypeOfType::getAsStringInternal(std::string &InnerString, const PrintingPol InnerString = "typeof(" + Tmp + ")" + InnerString; } +void DecltypeType::getAsStringInternal(std::string &InnerString, + const PrintingPolicy &Policy) const { + if (!InnerString.empty()) // Prefix the basic type, e.g. 'decltype(t) X'. + InnerString = ' ' + InnerString; + std::string Str; + llvm::raw_string_ostream s(Str); + getUnderlyingExpr()->printPretty(s, 0, Policy); + InnerString = "decltype(" + s.str() + ")" + InnerString; +} + void FunctionNoProtoType::getAsStringInternal(std::string &S, const PrintingPolicy &Policy) const { // If needed for precedence reasons, wrap the inner part in grouping parens. if (!S.empty()) -- cgit v1.3