[cfe-commits] r83045 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp test/CodeGenCXX/PR5093-static-member-function.cpp

Anders Carlsson andersca at mac.com
Mon Sep 28 20:54:13 PDT 2009


Author: andersca
Date: Mon Sep 28 22:54:11 2009
New Revision: 83045

URL: http://llvm.org/viewvc/llvm-project?rev=83045&view=rev
Log:
Handle CXXMemberCallExprs that point to a static method. Fixes PR5093.

Added:
    cfe/trunk/test/CodeGenCXX/PR5093-static-member-function.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=83045&r1=83044&r2=83045&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Sep 28 22:54:11 2009
@@ -202,6 +202,14 @@
   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 =

Added: cfe/trunk/test/CodeGenCXX/PR5093-static-member-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR5093-static-member-function.cpp?rev=83045&view=auto

==============================================================================
--- cfe/trunk/test/CodeGenCXX/PR5093-static-member-function.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/PR5093-static-member-function.cpp Mon Sep 28 22:54:11 2009
@@ -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();
+}





More information about the cfe-commits mailing list