From e9918d2443ad524e0f488e8f15d9bce4e7373cd1 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 8 Apr 2009 20:31:57 +0000 Subject: [PATCH] We weren't generating correct code for calls to variadic member functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68635 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCXX.cpp | 11 +++++------ test/CodeGenCXX/member-functions.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 000a0a9123..217f63a9df 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -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); } diff --git a/test/CodeGenCXX/member-functions.cpp b/test/CodeGenCXX/member-functions.cpp index a6fa000319..9cdab0a662 100644 --- a/test/CodeGenCXX/member-functions.cpp +++ b/test/CodeGenCXX/member-functions.cpp @@ -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(); -} \ No newline at end of file + +// RUN: grep "call void (.struct.C\*, i32, ...)\* @_ZN1C1gEiz" %t | count 1 + c.g(1, 2, 3); +} -- 2.50.1