aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r--lib/AST/Type.cpp20
1 files changed, 20 insertions, 0 deletions
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<TypeOfType>(this))
return TOT->getUnderlyingType().getDesugaredType();
+ if (const DecltypeType *DTT = dyn_cast<DecltypeType>(this))
+ return DTT->getUnderlyingExpr()->getType().getDesugaredType();
if (const TemplateSpecializationType *Spec
= dyn_cast<TemplateSpecializationType>(this)) {
if (ForDisplay)
@@ -962,6 +964,7 @@ const char *BuiltinType::getName(bool CPlusPlus) const {
case NullPtr: return "nullptr_t";
case Overload: return "<overloaded function type>";
case Dependent: return "<dependent type>";
+ case UndeducedAuto: return "<undeduced auto type>";
}
}
@@ -1052,6 +1055,13 @@ TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
assert(!isa<TypedefType>(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<TypedefType>(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())