[cfe-commits] r83395 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/virtual-function-calls.cpp
Anders Carlsson
andersca at mac.com
Tue Oct 6 10:54:23 PDT 2009
Author: andersca
Date: Tue Oct 6 12:54:23 2009
New Revision: 83395
URL: http://llvm.org/viewvc/llvm-project?rev=83395&view=rev
Log:
Pass the right type to GetAddrOfFunction when getting functions for the VTable. Fixes PR5021.
Added:
cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=83395&r1=83394&r2=83395&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Oct 6 12:54:23 2009
@@ -891,7 +891,13 @@
++mi)
if (mi->isVirtual()) {
const CXXMethodDecl *MD = *mi;
- llvm::Constant *m = wrap(CGM.GetAddrOfFunction(MD));
+ const FunctionProtoType *FPT =
+ MD->getType()->getAs<FunctionProtoType>();
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
+ FPT->isVariadic());
+
+ llvm::Constant *m = wrap(CGM.GetAddrOfFunction(MD, Ty));
OverrideMethod(MD, m, MorallyVirtual, Offset);
}
}
@@ -901,9 +907,15 @@
llvm::Constant *m = 0;
if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(MD))
m = wrap(CGM.GetAddrOfCXXDestructor(Dtor, Dtor_Complete));
- else
- m = wrap(CGM.GetAddrOfFunction(MD));
-
+ else {
+ const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
+ FPT->isVariadic());
+
+ m = wrap(CGM.GetAddrOfFunction(MD, Ty));
+ }
+
// If we can find a previously allocated slot for this, reuse it.
if (OverrideMethod(MD, m, MorallyVirtual, Offset))
return;
Added: cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp?rev=83395&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/virtual-function-calls.cpp Tue Oct 6 12:54:23 2009
@@ -0,0 +1,16 @@
+// PR5021
+struct A {
+ virtual void f(char);
+};
+
+void f(A *a) {
+ a->f('c');
+}
+// PR5021
+struct A {
+ virtual void f(char);
+};
+
+void f(A *a) {
+ a->f('c');
+}
More information about the cfe-commits
mailing list