Start attempting to generate code for C++ ctors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69168 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 4df760d..7ef147f 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -114,7 +114,6 @@
Callee, Args, MD);
}
-
llvm::Value *CodeGenFunction::LoadCXXThis() {
assert(isa<CXXMethodDecl>(CurFuncDecl) &&
"Must be in a C++ member function decl to load 'this'");
@@ -124,3 +123,35 @@
// FIXME: What if we're inside a block?
return Builder.CreateLoad(LocalDeclMap[CXXThisDecl], "this");
}
+
+const char *CodeGenModule::getMangledCXXCtorName(const CXXConstructorDecl *D,
+ CXXCtorType Type) {
+ llvm::SmallString<256> Name;
+ llvm::raw_svector_ostream Out(Name);
+ mangleCXXCtor(D, Type, Context, Out);
+
+ Name += '\0';
+ return UniqueMangledName(Name.begin(), Name.end());
+}
+
+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));
+
+ CodeGenFunction(*this).GenerateCode(D, Fn);
+
+ SetFunctionDefinitionAttributes(D, Fn);
+ SetLLVMFunctionAttributesForDefinition(D, Fn);
+}
+
+void CodeGenModule::EmitCXXConstructors(const CXXConstructorDecl *D) {
+ ErrorUnsupported(D, "C++ constructor", true);
+
+ EmitCXXConstructor(D, Ctor_Complete);
+ EmitCXXConstructor(D, Ctor_Base);
+}