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 | 617482c6663de644fc491e0e9d4b750fcf35dbe6 (patch) | |
tree | 8f8aca1f8b2384beebb50167b97d86b95158d8ed /clang/lib/CodeGen | |
parent | 680eb1b893e7821eb3b4716d89a7620c21df2912 (diff) | |
download | bcm5719-llvm-617482c6663de644fc491e0e9d4b750fcf35dbe6.tar.gz bcm5719-llvm-617482c6663de644fc491e0e9d4b750fcf35dbe6.zip |
Actually generate code for the simple constructors we know we can generate code for.
llvm-svn: 69222
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 7ef147f5f2d..2e48ebec001 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/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); |