Add support for C++'s "type-specifier ( expression-list )" expression:

-The Parser calls a new "ActOnCXXTypeConstructExpr" action.
-Sema, depending on the type and expressions number:
   -If the type is a class, it will treat it as a class constructor. [TODO]
   -If there's only one expression (i.e. "int(0.5)" ), creates a new "CXXFunctionalCastExpr" Expr node
   -If there are no expressions (i.e "int()" ), creates a new "CXXZeroInitValueExpr" Expr node.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55177 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index a3efab6..9085d2c 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -360,6 +360,7 @@
     return false;
   }
   case ExplicitCastExprClass:
+  case CXXFunctionalCastExprClass:
     // If this is a cast to void, check the operand.  Otherwise, the result of
     // the cast is unused.
     if (getType()->isVoidType())
@@ -643,7 +644,8 @@
     return true;
   }
   case ImplicitCastExprClass:
-  case ExplicitCastExprClass: {
+  case ExplicitCastExprClass:
+  case CXXFunctionalCastExprClass: {
     const Expr *SubExpr = cast<CastExpr>(this)->getSubExpr();
     SourceLocation CastLoc = getLocStart();
     if (!SubExpr->isConstantExpr(Ctx, Loc)) {
@@ -931,7 +933,8 @@
     break;
   }
   case ImplicitCastExprClass:
-  case ExplicitCastExprClass: {
+  case ExplicitCastExprClass:
+  case CXXFunctionalCastExprClass: {
     const Expr *SubExpr = cast<CastExpr>(this)->getSubExpr();
     SourceLocation CastLoc = getLocStart();
     
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 6069438..cf85ae2 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -45,3 +45,11 @@
 Stmt::child_iterator CXXDefaultArgExpr::child_end() {
   return child_iterator();
 }
+
+// CXXZeroInitValueExpr
+Stmt::child_iterator CXXZeroInitValueExpr::child_begin() { 
+  return child_iterator();
+}
+Stmt::child_iterator CXXZeroInitValueExpr::child_end() {
+  return child_iterator();
+}
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index 5b4c0ec..a765060 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -818,6 +818,17 @@
   // Nothing to print: we picked up the default argument
 }
 
+void StmtPrinter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *Node) {
+  OS << Node->getType().getAsString();
+  OS << "(";
+  PrintExpr(Node->getSubExpr());
+  OS << ")";
+}
+
+void StmtPrinter::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *Node) {
+  OS << Node->getType().getAsString() << "()";
+}
+
 // Obj-C 
 
 void StmtPrinter::VisitObjCStringLiteral(ObjCStringLiteral *Node) {
diff --git a/lib/AST/StmtSerialization.cpp b/lib/AST/StmtSerialization.cpp
index 9859846..1c61b66 100644
--- a/lib/AST/StmtSerialization.cpp
+++ b/lib/AST/StmtSerialization.cpp
@@ -197,6 +197,12 @@
       
     case CXXDefaultArgExprClass:
       return CXXDefaultArgExpr::CreateImpl(D, C);      
+
+    case CXXFunctionalCastExprClass:
+      return CXXFunctionalCastExpr::CreateImpl(D, C);
+
+    case CXXZeroInitValueExprClass:
+      return CXXZeroInitValueExpr::CreateImpl(D, C);
   }
 }
 
@@ -1101,3 +1107,33 @@
   D.ReadPtr(Param, false);
   return new CXXDefaultArgExpr(Param);
 }
+
+void CXXFunctionalCastExpr::EmitImpl(Serializer& S) const {
+  S.Emit(getType());
+  S.Emit(TyBeginLoc);
+  S.Emit(RParenLoc);
+  S.EmitOwnedPtr(getSubExpr());
+}
+
+CXXFunctionalCastExpr *
+CXXFunctionalCastExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+  QualType Ty = QualType::ReadVal(D);
+  SourceLocation TyBeginLoc = SourceLocation::ReadVal(D);
+  SourceLocation RParenLoc = SourceLocation::ReadVal(D);
+  Expr* SubExpr = D.ReadOwnedPtr<Expr>(C);
+  return new CXXFunctionalCastExpr(Ty, TyBeginLoc, SubExpr, RParenLoc);
+}
+
+void CXXZeroInitValueExpr::EmitImpl(Serializer& S) const {
+  S.Emit(getType());
+  S.Emit(TyBeginLoc);
+  S.Emit(RParenLoc);
+}
+
+CXXZeroInitValueExpr *
+CXXZeroInitValueExpr::CreateImpl(Deserializer& D, ASTContext& C) {
+  QualType Ty = QualType::ReadVal(D);
+  SourceLocation TyBeginLoc = SourceLocation::ReadVal(D);
+  SourceLocation RParenLoc = SourceLocation::ReadVal(D);
+  return new CXXZeroInitValueExpr(Ty, TyBeginLoc, RParenLoc);
+}