[cfe-commits] r69469 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Sat Apr 18 13:20:22 PDT 2009
Author: andersca
Date: Sat Apr 18 15:20:22 2009
New Revision: 69469
URL: http://llvm.org/viewvc/llvm-project?rev=69469&view=rev
Log:
Make CodeGenFunction::EmitCallArgs a template function that takes a generic "Type Info" parameter. The type info parameter knows how to iterate over its arguments.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=69469&r1=69468&r2=69469&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Sat Apr 18 15:20:22 2009
@@ -1935,38 +1935,6 @@
return EmitAnyExprToTemp(E);
}
-void CodeGenFunction::EmitCallArgs(CallArgList& Args,
- const FunctionProtoType *FPT,
- CallExpr::const_arg_iterator ArgBeg,
- CallExpr::const_arg_iterator ArgEnd) {
- CallExpr::const_arg_iterator Arg = ArgBeg;
-
- // First, use the function argument types.
- if (FPT) {
- for (FunctionProtoType::arg_type_iterator I = FPT->arg_type_begin(),
- E = FPT->arg_type_end(); I != E; ++I, ++Arg) {
- assert(getContext().getCanonicalType(I->getNonReferenceType()).
- getTypePtr() ==
- getContext().getCanonicalType(Arg->getType()).getTypePtr() &&
- "type mismatch in call argument!");
-
- QualType ArgType = *I;
- Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
- ArgType));
- }
-
- assert(Arg == ArgEnd || FPT->isVariadic() &&
- "Extra arguments in non-variadic function!");
- }
-
- // If we still have any arguments, emit them using the type of the argument.
- for (; Arg != ArgEnd; ++Arg) {
- QualType ArgType = Arg->getType();
- Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
- ArgType));
- }
-}
-
RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
llvm::Value *Callee,
const CallArgList &CallArgs,
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=69469&r1=69468&r2=69469&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Apr 18 15:20:22 2009
@@ -811,14 +811,46 @@
RValue EmitCallArg(const Expr *E, QualType ArgType);
/// EmitCallArgs - Emit call arguments for a function.
- /// FIXME: It should be possible to generalize this and pass a generic
- /// "argument type container" type instead of the FunctionProtoType. This way
- /// it can work on Objective-C methods as well.
- void EmitCallArgs(CallArgList& args, const FunctionProtoType *FPT,
+ /// The CallArgTypeInfo parameter is used for iterating over the known
+ /// argument types of the function being called.
+ template<typename T>
+ void EmitCallArgs(CallArgList& Args, const T* CallArgTypeInfo,
CallExpr::const_arg_iterator ArgBeg,
- CallExpr::const_arg_iterator ArgEnd);
+ CallExpr::const_arg_iterator ArgEnd) {
+ CallExpr::const_arg_iterator Arg = ArgBeg;
+ // First, use the argument types that the type info knows about
+ if (CallArgTypeInfo) {
+ for (typename T::arg_type_iterator I = CallArgTypeInfo->arg_type_begin(),
+ E = CallArgTypeInfo->arg_type_end(); I != E; ++I, ++Arg) {
+ QualType ArgType = *I;
+
+ assert(getContext().getCanonicalType(ArgType.getNonReferenceType()).
+ getTypePtr() ==
+ getContext().getCanonicalType(Arg->getType()).getTypePtr() &&
+ "type mismatch in call argument!");
+
+ Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
+ ArgType));
+ }
+
+ // Either we've emitted all the call args, or we have a call to a
+ // variadic function.
+ assert(Arg == ArgEnd || CallArgTypeInfo->isVariadic() &&
+ "Extra arguments in non-variadic function!");
+
+ }
+
+ // If we still have any arguments, emit them using the type of the argument.
+ for (; Arg != ArgEnd; ++Arg) {
+ QualType ArgType = Arg->getType();
+ Args.push_back(std::make_pair(EmitCallArg(*Arg, ArgType),
+ ArgType));
+ }
+ }
};
+
+
} // end namespace CodeGen
} // end namespace clang
More information about the cfe-commits
mailing list