We weren't generating correct code for calls to variadic member functions.

llvm-svn: 68635
This commit is contained in:
Anders Carlsson 2009-04-08 20:31:57 +00:00
parent 17b36271e7
commit 03a409feda
2 changed files with 11 additions and 8 deletions

View File

@ -142,12 +142,10 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
assert(MD->isInstance() &&
"Trying to emit a member call expr on a static method!");
const CGFunctionInfo &FnInfo = CGM.getTypes().getFunctionInfo(MD);
bool IsVariadic = MD->getType()->getAsFunctionProtoType()->isVariadic();
const FunctionProtoType *FPT = MD->getType()->getAsFunctionProtoType();
const llvm::Type *Ty =
CGM.getTypes().GetFunctionType(FnInfo, IsVariadic);
CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
FPT->isVariadic());
llvm::Constant *Callee = CGM.GetAddrOfFunction(MD, Ty);
llvm::Value *BaseValue = 0;
@ -173,5 +171,6 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
Args.push_back(std::make_pair(EmitAnyExprToTemp(*I), I->getType()));
QualType ResultType = MD->getType()->getAsFunctionType()->getResultType();
return EmitCall(FnInfo, Callee, Args, MD);
return EmitCall(CGM.getTypes().getFunctionInfo(ResultType, Args),
Callee, Args, MD);
}

View File

@ -1,15 +1,19 @@
// RUN: clang-cc -emit-llvm %s -o %t &&
struct C {
void f();
void g(int, ...);
};
// RUN: grep "define void @_ZN1C1fEv" %t | count 1 &&
void C::f() {
}
// RUN: grep "call void @_ZN1C1fEv" %t | count 1
void f() {
C c;
// RUN: grep "call void @_ZN1C1fEv" %t | count 1 &&
c.f();
}
// RUN: grep "call void (.struct.C\*, i32, ...)\* @_ZN1C1gEiz" %t | count 1
c.g(1, 2, 3);
}