[cfe-commits] r68635 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/member-functions.cpp

Anders Carlsson andersca at mac.com
Wed Apr 8 13:31:57 PDT 2009


Author: andersca
Date: Wed Apr  8 15:31:57 2009
New Revision: 68635

URL: http://llvm.org/viewvc/llvm-project?rev=68635&view=rev
Log:
We weren't generating correct code for calls to variadic member functions.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/test/CodeGenCXX/member-functions.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=68635&r1=68634&r2=68635&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Apr  8 15:31:57 2009
@@ -142,12 +142,10 @@
   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 @@
     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);
 }

Modified: cfe/trunk/test/CodeGenCXX/member-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/member-functions.cpp?rev=68635&r1=68634&r2=68635&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/member-functions.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/member-functions.cpp Wed Apr  8 15:31:57 2009
@@ -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);
+}





More information about the cfe-commits mailing list