Change Sema::ActOnCallExpr to construct the CallExpr early and put it into
and OwningPtr instead of constructing only after all of sema is done.  This
has a couple of effects:
1. it fixes memory leaks from all the error cases in sema
2. it simplifies the code significantly.

The cost of this is that the error case now new's and delete's an expr where
it did not before, but we don't care about the perf of the error case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45380 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.h b/Sema/Sema.h
index b783f59..88c6dcc 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -34,6 +34,7 @@
   class ScopedDecl;
   class Expr;
   class InitListExpr;
+  class CallExpr;
   class VarDecl;
   class ParmVarDecl;
   class TypedefDecl;
@@ -582,8 +583,8 @@
     ExprTy **ArgExprs, unsigned NumArgs);
 private:
   // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
-  // functions and arrays to their respective pointers (C99 6.3.2.1). 
-  void UsualUnaryConversions(Expr *&expr); 
+  // functions and arrays to their respective pointers (C99 6.3.2.1).
+  Expr *UsualUnaryConversions(Expr *&expr); 
   
   // DefaultFunctionArrayConversion - converts functions and arrays
   // to their respective pointers (C99 6.3.2.1). 
@@ -592,7 +593,7 @@
   // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
   // do not have a prototype. Integer promotions are performed on each 
   // argument, and arguments that have type float are promoted to double.
-  void DefaultArgumentPromotion(Expr *&expr);
+  void DefaultArgumentPromotion(Expr *&Expr);
   
   // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
   // operands and then handles various conversions that are common to binary
@@ -712,26 +713,15 @@
   
   //===--------------------------------------------------------------------===//
   // Extra semantic analysis beyond the C type system
-  private:
-  
-  bool CheckFunctionCall(Expr *Fn, SourceLocation RParenLoc,
-                         FunctionDecl *FDecl,
-                         Expr** Args, unsigned NumArgsInCall);
-
-  void CheckPrintfArguments(Expr *Fn, SourceLocation RParenLoc,
-                            bool HasVAListArg, FunctionDecl *FDecl,
-                            unsigned format_idx, Expr** Args,
-                            unsigned NumArgsInCall);
-                            
+private:
+  bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
+  bool CheckBuiltinCFStringArgument(Expr* Arg);
+  bool SemaBuiltinVAStart(CallExpr *TheCall);
+  bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
+  void CheckPrintfArguments(CallExpr *TheCall,
+                            bool HasVAListArg, unsigned format_idx);
   void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
                             SourceLocation ReturnLoc);
-
-  
-  bool CheckBuiltinCFStringArgument(Expr* Arg);
-  bool SemaBuiltinVAStart(Expr *Fn, Expr** Args, unsigned NumArgs);
-  bool SemaBuiltinUnorderedCompare(Expr *Fn, Expr** Args, unsigned NumArgs,
-                                   SourceLocation RParenLoc);
-  
   void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
 };