[cfe-commits] r89789 - in /cfe/trunk/lib/Sema: Sema.h SemaExpr.cpp SemaExprCXX.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Nov 24 11:27:49 PST 2009
Author: fjahanian
Date: Tue Nov 24 13:27:49 2009
New Revision: 89789
URL: http://llvm.org/viewvc/llvm-project?rev=89789&view=rev
Log:
More cleanup of argument call collection.
Modified:
cfe/trunk/lib/Sema/Sema.h
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=89789&r1=89788&r2=89789&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Nov 24 13:27:49 2009
@@ -1523,14 +1523,6 @@
Expr **Args, unsigned NumArgs,
SourceLocation RParenLoc);
- bool GatherArgumentsForCall(SourceLocation CallLoc,
- FunctionDecl *FDecl,
- const FunctionProtoType *Proto,
- unsigned FirstProtoArg,
- Expr **Args, unsigned NumArgs,
- llvm::SmallVector<Expr *, 8> &AllArgs,
- Expr *Fn = 0);
-
void DeconstructCallFunction(Expr *FnExpr,
llvm::SmallVectorImpl<NamedDecl*>& Fns,
DeclarationName &Name,
@@ -3320,9 +3312,21 @@
VariadicFunction,
VariadicBlock,
VariadicMethod,
- VariadicConstructor
+ VariadicConstructor,
+ VariadicDoesNotApply
};
+ /// GatherArgumentsForCall - Collector argument expressions for various
+ /// form of call prototypes.
+ bool GatherArgumentsForCall(SourceLocation CallLoc,
+ FunctionDecl *FDecl,
+ const FunctionProtoType *Proto,
+ unsigned FirstProtoArg,
+ Expr **Args, unsigned NumArgs,
+ llvm::SmallVector<Expr *, 8> &AllArgs,
+ Expr *Fn = 0,
+ VariadicCallType CallType = VariadicDoesNotApply);
+
// DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
// will warn if the resulting type is not a POD type.
bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT);
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=89789&r1=89788&r2=89789&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Nov 24 13:27:49 2009
@@ -2620,8 +2620,14 @@
}
}
llvm::SmallVector<Expr *, 8> AllArgs;
+ VariadicCallType CallType =
+ Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply;
+ if (Fn->getType()->isBlockPointerType())
+ CallType = VariadicBlock; // Block
+ else if (isa<MemberExpr>(Fn))
+ CallType = VariadicMethod;
Invalid = GatherArgumentsForCall(Call->getSourceRange().getBegin(), FDecl,
- Proto, 0, Args, NumArgs, AllArgs, Fn);
+ Proto, 0, Args, NumArgs, AllArgs, Fn, CallType);
if (Invalid)
return true;
unsigned TotalNumArgs = AllArgs.size();
@@ -2637,7 +2643,8 @@
unsigned FirstProtoArg,
Expr **Args, unsigned NumArgs,
llvm::SmallVector<Expr *, 8> &AllArgs,
- Expr *Fn) {
+ Expr *Fn,
+ VariadicCallType CallType) {
unsigned NumArgsInProto = Proto->getNumArgs();
unsigned NumArgsToCheck = NumArgs;
bool Invalid = false;
@@ -2679,14 +2686,7 @@
}
// If this is a variadic call, handle args passed through "...".
- if (Proto->isVariadic()) {
- VariadicCallType CallType = VariadicFunction;
- if (Fn) {
- if (Fn->getType()->isBlockPointerType())
- CallType = VariadicBlock; // Block
- else if (isa<MemberExpr>(Fn))
- CallType = VariadicMethod;
- }
+ if (CallType != VariadicDoesNotApply) {
// Promote the arguments (C99 6.5.2.2p7).
for (unsigned i = ArgIx; i < NumArgs; i++) {
Expr *Arg = Args[i];
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=89789&r1=89788&r2=89789&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Nov 24 13:27:49 2009
@@ -407,9 +407,11 @@
// Add default arguments, if any.
const FunctionProtoType *Proto =
OperatorNew->getType()->getAs<FunctionProtoType>();
+ VariadicCallType CallType =
+ Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply;
bool Invalid = GatherArgumentsForCall(PlacementLParen, OperatorNew,
Proto, 1, PlaceArgs, NumPlaceArgs,
- AllPlaceArgs);
+ AllPlaceArgs, 0, CallType);
if (Invalid)
return ExprError();
More information about the cfe-commits
mailing list