[cfe-commits] r89802 - in /cfe/trunk/lib/Sema: Sema.h SemaDeclCXX.cpp SemaExpr.cpp SemaExprCXX.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Nov 24 13:37:28 PST 2009


Author: fjahanian
Date: Tue Nov 24 15:37:28 2009
New Revision: 89802

URL: http://llvm.org/viewvc/llvm-project?rev=89802&view=rev
Log:
Refactor argument collection of constructor calls using
the common routine.


Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=89802&r1=89801&r2=89802&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Nov 24 15:37:28 2009
@@ -3324,7 +3324,6 @@
                               unsigned FirstProtoArg,
                               Expr **Args, unsigned NumArgs,
                               llvm::SmallVector<Expr *, 8> &AllArgs,
-                              Expr *Fn = 0,
                               VariadicCallType CallType = VariadicDoesNotApply);
 
   // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=89802&r1=89801&r2=89802&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Nov 24 15:37:28 2009
@@ -3645,58 +3645,22 @@
     = Constructor->getType()->getAs<FunctionProtoType>();
   assert(Proto && "Constructor without a prototype?");
   unsigned NumArgsInProto = Proto->getNumArgs();
-  unsigned NumArgsToCheck = NumArgs;
   
   // If too few arguments are available, we'll fill in the rest with defaults.
-  if (NumArgs < NumArgsInProto) {
-    NumArgsToCheck = NumArgsInProto;
+  if (NumArgs < NumArgsInProto)
     ConvertedArgs.reserve(NumArgsInProto);
-  } else {
+  else
     ConvertedArgs.reserve(NumArgs);
-    if (NumArgs > NumArgsInProto)
-      NumArgsToCheck = NumArgsInProto;
-  }
-  
-  // Convert arguments
-  for (unsigned i = 0; i != NumArgsToCheck; i++) {
-    QualType ProtoArgType = Proto->getArgType(i);
-    
-    Expr *Arg;
-    if (i < NumArgs) {
-      Arg = Args[i];
-      
-      // Pass the argument.
-      if (PerformCopyInitialization(Arg, ProtoArgType, "passing"))
-        return true;
-      
-      Args[i] = 0;
-    } else {
-      ParmVarDecl *Param = Constructor->getParamDecl(i);
-      
-      OwningExprResult DefArg = BuildCXXDefaultArgExpr(Loc, Constructor, Param);
-      if (DefArg.isInvalid())
-        return true;
-      
-      Arg = DefArg.takeAs<Expr>();
-    }
-    
-    ConvertedArgs.push_back(Arg);
-  }
-  
-  // If this is a variadic call, handle args passed through "...".
-  if (Proto->isVariadic()) {
-    // Promote the arguments (C99 6.5.2.2p7).
-    for (unsigned i = NumArgsInProto; i != NumArgs; i++) {
-      Expr *Arg = Args[i];
-      if (DefaultVariadicArgumentPromotion(Arg, VariadicConstructor))
-        return true;
-      
-      ConvertedArgs.push_back(Arg);
-      Args[i] = 0;
-    }
-  }
-  
-  return false;
+
+  VariadicCallType CallType = 
+    Proto->isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
+  llvm::SmallVector<Expr *, 8> AllArgs;
+  bool Invalid = GatherArgumentsForCall(Loc, Constructor,
+                                        Proto, 0, Args, NumArgs, AllArgs, 
+                                        CallType);
+  for (unsigned i =0, size = AllArgs.size(); i < size; i++)
+    ConvertedArgs.push_back(AllArgs[i]);
+  return Invalid;
 }
 
 /// CompareReferenceRelationship - Compare the two types T1 and T2 to

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=89802&r1=89801&r2=89802&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Nov 24 15:37:28 2009
@@ -2627,7 +2627,7 @@
   else if (isa<MemberExpr>(Fn))
     CallType = VariadicMethod;
   Invalid = GatherArgumentsForCall(Call->getSourceRange().getBegin(), FDecl,
-                                   Proto, 0, Args, NumArgs, AllArgs, Fn, CallType);
+                                   Proto, 0, Args, NumArgs, AllArgs, CallType);
   if (Invalid)
     return true;
   unsigned TotalNumArgs = AllArgs.size();
@@ -2643,7 +2643,6 @@
                                   unsigned FirstProtoArg,
                                   Expr **Args, unsigned NumArgs,
                                   llvm::SmallVector<Expr *, 8> &AllArgs,
-                                  Expr *Fn,
                                   VariadicCallType CallType) {
   unsigned NumArgsInProto = Proto->getNumArgs();
   unsigned NumArgsToCheck = NumArgs;

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=89802&r1=89801&r2=89802&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Nov 24 15:37:28 2009
@@ -411,7 +411,7 @@
       Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply;
     bool Invalid = GatherArgumentsForCall(PlacementLParen, OperatorNew,
                                           Proto, 1, PlaceArgs, NumPlaceArgs, 
-                                          AllPlaceArgs, 0, CallType);
+                                          AllPlaceArgs, CallType);
     if (Invalid)
       return ExprError();
     





More information about the cfe-commits mailing list