From 59d8e0ff383274d992b3fa9ebee48b5e4a5ebdd1 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 15 Apr 2009 21:02:13 +0000 Subject: [PATCH] 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 --- lib/CodeGen/CGCXX.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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); -- 2.40.0