[cfe-commits] r69222 - /cfe/trunk/lib/CodeGen/CGCXX.cpp

Anders Carlsson andersca at mac.com
Wed Apr 15 14:02:15 PDT 2009


Author: andersca
Date: Wed Apr 15 16:02:13 2009
New Revision: 69222

URL: http://llvm.org/viewvc/llvm-project?rev=69222&view=rev
Log:
Actually generate code for the simple constructors we know we can generate code for.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=69222&r1=69221&r2=69222&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Apr 15 16:02:13 2009
@@ -149,8 +149,29 @@
   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);





More information about the cfe-commits mailing list