diff options
author | Anders Carlsson <andersca@mac.com> | 2009-04-15 15:55:24 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-04-15 15:55:24 +0000 |
commit | 95d4e5d2f87a0f07fb143ccb824dfc4c5c595c78 (patch) | |
tree | 9fab5013466209889fdd7462cecc5af7db1a4365 /lib/CodeGen/CGCXX.cpp | |
parent | ee3899e1cabcbf70d9a316b33f9b79bf3189bd01 (diff) |
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
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 4df760d593..7ef147f5f2 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -114,7 +114,6 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) { 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 @@ llvm::Value *CodeGenFunction::LoadCXXThis() { // 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); +} |