[cfe-commits] r69328 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CodeGenModule.h

Anders Carlsson andersca at mac.com
Thu Apr 16 16:57:24 PDT 2009


Author: andersca
Date: Thu Apr 16 18:57:24 2009
New Revision: 69328

URL: http://llvm.org/viewvc/llvm-project?rev=69328&view=rev
Log:
Add GetAddrOfCXXConstructor and use it.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu Apr 16 18:57:24 2009
@@ -136,12 +136,8 @@
 
 void CodeGenModule::EmitCXXConstructor(const CXXConstructorDecl *D, 
                                        CXXCtorType Type) {
-  const llvm::FunctionType *Ty =
-    getTypes().GetFunctionType(getTypes().getFunctionInfo(D), false);
   
-  const char *Name = getMangledCXXCtorName(D, Type);
-  llvm::Function *Fn = 
-    cast<llvm::Function>(GetOrCreateLLVMFunction(Name, Ty, D));
+  llvm::Function *Fn = GetAddrOfCXXConstructor(D, Type);
  
   CodeGenFunction(*this).GenerateCode(D, Fn);
   
@@ -176,3 +172,13 @@
   EmitCXXConstructor(D, Ctor_Complete);
   EmitCXXConstructor(D, Ctor_Base);
 }
+
+llvm::Function *
+CodeGenModule::GetAddrOfCXXConstructor(const CXXConstructorDecl *D, 
+                                       CXXCtorType Type) {
+  const llvm::FunctionType *FTy =
+    getTypes().GetFunctionType(getTypes().getFunctionInfo(D), false);
+  
+  const char *Name = getMangledCXXCtorName(D, Type);
+  return cast<llvm::Function>(GetOrCreateLLVMFunction(Name, FTy, D));
+}

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=69328&r1=69327&r2=69328&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu Apr 16 18:57:24 2009
@@ -236,6 +236,11 @@
   llvm::Constant *GetAddrOfConstantCString(const std::string &str,
                                            const char *GlobalName=0);
 
+  /// GetAddrOfCXXConstructor - Return the address of the constructor of the
+  /// given type.
+  llvm::Function *GetAddrOfCXXConstructor(const CXXConstructorDecl *D, 
+                                          CXXCtorType Type);
+  
   /// getBuiltinLibFunction - Given a builtin id for a function like
   /// "__builtin_fabsf", return a Function* for "fabsf".
   llvm::Value *getBuiltinLibFunction(unsigned BuiltinID);





More information about the cfe-commits mailing list