]> granicus.if.org Git - clang/commitdiff
[modules] Remove IRGen special case for emitting implicit special members if
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 1 Aug 2014 01:56:39 +0000 (01:56 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 1 Aug 2014 01:56:39 +0000 (01:56 +0000)
they're somehow missing a body. Looks like this was left behind when the loop
was generalized, and it's not been problematic before because without modules,
a used, implicit special member function declaration must be a definition.

This was resulting in us trying to emit a constructor declaration rather than
a definition, and producing a constructor missing its member initializers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214473 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGClass.cpp
lib/CodeGen/CodeGenModule.cpp
lib/Serialization/ASTReaderDecl.cpp
test/Modules/cxx-irgen.cpp

index 9427de14d70464f691fbe158772bf2002bb7b45e..920a071d8c7f6a8de8a282d88427c367de2d9a1d 100644 (file)
@@ -711,7 +711,9 @@ void CodeGenFunction::EmitConstructorBody(FunctionArgList &Args) {
     return;
   }
 
-  Stmt *Body = Ctor->getBody();
+  const FunctionDecl *Definition = 0;
+  Stmt *Body = Ctor->getBody(Definition);
+  assert(Definition == Ctor && "emitting wrong constructor body");
 
   // Enter the function-try-block before the constructor prologue if
   // applicable.
index 48823befcc071d86adda690cdc09e477f997dbd8..a14558f975aafbf2d7f44df8c94f3430896b96be 100644 (file)
@@ -1510,26 +1510,18 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName,
       // this will be unnecessary.
       //
       // We also don't emit a definition for a function if it's going to be an
-      // entry
-      // in a vtable, unless it's already marked as used.
+      // entry in a vtable, unless it's already marked as used.
     } else if (getLangOpts().CPlusPlus && D) {
       // Look for a declaration that's lexically in a record.
-      const auto *FD = cast<FunctionDecl>(D);
-      FD = FD->getMostRecentDecl();
-      do {
+      for (const auto *FD = cast<FunctionDecl>(D)->getMostRecentDecl(); FD;
+           FD = FD->getPreviousDecl()) {
         if (isa<CXXRecordDecl>(FD->getLexicalDeclContext())) {
-          if (FD->isImplicit() && !ForVTable) {
-            assert(FD->isUsed() &&
-                   "Sema didn't mark implicit function as used!");
-            addDeferredDeclToEmit(F, GD.getWithDecl(FD));
-            break;
-          } else if (FD->doesThisDeclarationHaveABody()) {
+          if (FD->doesThisDeclarationHaveABody()) {
             addDeferredDeclToEmit(F, GD.getWithDecl(FD));
             break;
           }
         }
-        FD = FD->getPreviousDecl();
-      } while (FD);
+      }
     }
   }
 
index ea3f61fdc8955c519babc9b3c249b914e7bc65a8..441427cc5687edf968f514e9f0fbc23a9e0782f6 100644 (file)
@@ -3241,6 +3241,8 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
     case UPD_CXX_ADDED_IMPLICIT_MEMBER: {
       Decl *MD = Reader.ReadDecl(ModuleFile, Record, Idx);
       assert(MD && "couldn't read decl from update record");
+      // FIXME: We should call addHiddenDecl instead, to add the member
+      // to its DeclContext.
       cast<CXXRecordDecl>(D)->addedMember(MD);
       break;
     }
index eea6b316e3f4418faef2e713fdbf99beb697a9d0..9fb38cedacf144a10bd7e2b9d386b6ea1092fb13 100644 (file)
@@ -30,7 +30,7 @@ namespace ImplicitSpecialMembers {
   // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2EOS0_(
   // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
   // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
-  // FIXME CHECK-NOT: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
+  // CHECK: call {{.*}} @_ZN22ImplicitSpecialMembers1AC1ERKS0_(
 
   extern B b1;
   B b2(b1);