]> granicus.if.org Git - clang/commitdiff
Add GetAddrOfCXXConstructor and use it.
authorAnders Carlsson <andersca@mac.com>
Thu, 16 Apr 2009 23:57:24 +0000 (23:57 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 16 Apr 2009 23:57:24 +0000 (23:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69328 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
lib/CodeGen/CodeGenModule.h

index 2e48ebec001e5566776b7af3d432d8f06e4c8649..f76bd122a056bf4176c0a68afb42bc06ed6abe3d 100644 (file)
@@ -136,12 +136,8 @@ const char *CodeGenModule::getMangledCXXCtorName(const CXXConstructorDecl *D,
 
 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 @@ void CodeGenModule::EmitCXXConstructors(const CXXConstructorDecl *D) {
   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));
+}
index e7a587fc8c0a849333d83e44d1429a13bbb24c3a..17a9a9f907e63e998e0d1ba76d421a845c408abd 100644 (file)
@@ -236,6 +236,11 @@ public:
   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);