diff options
author | Anders Carlsson <andersca@mac.com> | 2009-09-29 03:54:11 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-09-29 03:54:11 +0000 |
commit | 2472bf0a1735fa9c60a01946d5ed53b64c9c2422 (patch) | |
tree | 7f4eba424a146c8240aa66ddd40a06554703d775 | |
parent | 7b69956387785006244e7868f8dab09b371dbb6d (diff) |
Handle CXXMemberCallExprs that point to a static method. Fixes PR5093.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83045 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 8 | ||||
-rw-r--r-- | test/CodeGenCXX/PR5093-static-member-function.cpp | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index e37b4a8548..bf9af9c64d 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -202,6 +202,14 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) { const MemberExpr *ME = cast<MemberExpr>(CE->getCallee()); const CXXMethodDecl *MD = cast<CXXMethodDecl>(ME->getMemberDecl()); + if (MD->isStatic()) { + // The method is static, emit it as we would a regular call. + llvm::Value *Callee = CGM.GetAddrOfFunction(MD); + return EmitCall(Callee, getContext().getPointerType(MD->getType()), + CE->arg_begin(), CE->arg_end(), 0); + + } + const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>(); const llvm::Type *Ty = diff --git a/test/CodeGenCXX/PR5093-static-member-function.cpp b/test/CodeGenCXX/PR5093-static-member-function.cpp new file mode 100644 index 0000000000..a27b08f6ad --- /dev/null +++ b/test/CodeGenCXX/PR5093-static-member-function.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s +struct a { + static void f(); +}; + +void g(a *a) { + // CHECK: call void @_ZN1a1fEv() + a->f(); +} |