[cfe-commits] r77641 - in /cfe/trunk/lib/CodeGen: CodeGenFunction.cpp CodeGenModule.cpp

Fariborz Jahanian fjahanian at apple.com
Thu Jul 30 16:22:00 PDT 2009


Author: fjahanian
Date: Thu Jul 30 18:22:00 2009
New Revision: 77641

URL: http://llvm.org/viewvc/llvm-project?rev=77641&view=rev
Log:
Synthesize the default constructor which has not
been declared as needed.

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Jul 30 18:22:00 2009
@@ -238,7 +238,17 @@
       EmitDtorEpilogue(DD);
     FinishFunction(S->getRBracLoc());
   }
-
+  else 
+    if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
+      assert(
+             !cast<CXXRecordDecl>(CD->getDeclContext())->
+              hasUserDeclaredConstructor() &&
+             "bogus constructor is being synthesize");
+      StartFunction(FD, FD->getResultType(), Fn, Args, SourceLocation());
+      EmitCtorPrologue(CD);
+      FinishFunction();
+    }
+    
   // Destroy the 'this' declaration.
   if (CXXThisDecl)
     CXXThisDecl->Destroy(getContext());

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Jul 30 18:22:00 2009
@@ -640,6 +640,14 @@
     // top-level declarations.
     if (FD->isThisDeclarationADefinition() && MayDeferGeneration(FD))
       DeferredDeclsToEmit.push_back(D);
+    // A called constructor which has no definition or declaration need be
+    // synthesized.
+    else if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
+      const CXXRecordDecl *ClassDecl = 
+        cast<CXXRecordDecl>(CD->getDeclContext());
+      if (!ClassDecl->hasUserDeclaredConstructor())
+        DeferredDeclsToEmit.push_back(D);
+    }
   }
   
   // This function doesn't have a complete type (for example, the return





More information about the cfe-commits mailing list