diff options
author | Anders Carlsson <andersca@mac.com> | 2009-04-15 21:02:13 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-04-15 21:02:13 +0000 |
commit | 59d8e0ff383274d992b3fa9ebee48b5e4a5ebdd1 (patch) | |
tree | d982f836d2f4c10c82e60dd0bc2bdad8bf536137 /lib/CodeGen/CGCXX.cpp | |
parent | d7492c4f91fa374e1897293a01d08fab076db582 (diff) |
Actually generate code for the simple constructors we know we can generate code for.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69222 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 7ef147f5f2..2e48ebec00 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -149,8 +149,29 @@ void CodeGenModule::EmitCXXConstructor(const CXXConstructorDecl *D, SetLLVMFunctionAttributesForDefinition(D, Fn); } +static bool canGenerateCXXConstructor(const CXXConstructorDecl *D, + ASTContext &Context) { + const CXXRecordDecl *RD = D->getParent(); + + // The class has base classes - we don't support that right now. + if (RD->getNumBases() > 0) + return false; + + for (CXXRecordDecl::field_iterator I = RD->field_begin(Context), + E = RD->field_end(Context); I != E; ++I) { + // We don't support ctors for fields that aren't POD. + if (!I->getType()->isPODType()) + return false; + } + + return true; +} + void CodeGenModule::EmitCXXConstructors(const CXXConstructorDecl *D) { - ErrorUnsupported(D, "C++ constructor", true); + if (!canGenerateCXXConstructor(D, getContext())) { + ErrorUnsupported(D, "C++ constructor", true); + return; + } EmitCXXConstructor(D, Ctor_Complete); EmitCXXConstructor(D, Ctor_Base); |