]> granicus.if.org Git - clang/commitdiff
Handle CXXMemberCallExprs that point to a static method. Fixes PR5093.
authorAnders Carlsson <andersca@mac.com>
Tue, 29 Sep 2009 03:54:11 +0000 (03:54 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 29 Sep 2009 03:54:11 +0000 (03:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83045 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
test/CodeGenCXX/PR5093-static-member-function.cpp [new file with mode: 0644]

index e37b4a854824b5759b76d756d8f96810b13c6d78..bf9af9c64da1b12fb2b5da17da31b2480d453f1b 100644 (file)
@@ -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 (file)
index 0000000..a27b08f
--- /dev/null
@@ -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();
+}