[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44953)

Luboš Luňák via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 23 13:01:53 PST 2020


llunak updated this revision to Diff 246122.
llunak retitled this revision from "fix -fcodegen-modules code when used with PCH (PR44958)" to "fix -fcodegen-modules code when used with PCH (PR44953)".
llunak edited the summary of this revision.
llunak added a comment.

Upon further investigation it turns out I probably should not have enabled those two places for PCH in D69778 <https://reviews.llvm.org/D69778> at all, since they do not deal with -fmodules-codegen. So reverting those two places should be the right fix. That also makes a test irrelevant (not much point in testing a rare corner-case for a code path never taken).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74846/new/

https://reviews.llvm.org/D74846

Files:
  clang/lib/Serialization/ASTWriterDecl.cpp


Index: clang/lib/Serialization/ASTWriterDecl.cpp
===================================================================
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1011,16 +1011,15 @@
 
   if (D->getStorageDuration() == SD_Static) {
     bool ModulesCodegen = false;
-    if (!D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
+    if (Writer.WritingModule &&
+        !D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
         !isa<VarTemplateSpecializationDecl>(D)) {
       // When building a C++ Modules TS module interface unit, a strong
       // definition in the module interface is provided by the compilation of
       // that module interface unit, not by its users. (Inline variables are
       // still emitted in module users.)
       ModulesCodegen =
-          (((Writer.WritingModule &&
-             Writer.WritingModule->Kind == Module::ModuleInterfaceUnit) ||
-            Writer.Context->getLangOpts().BuildingPCHWithObjectFile) &&
+          (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit &&
            Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal);
     }
     Record.push_back(ModulesCodegen);
@@ -2451,9 +2450,8 @@
   bool ModulesCodegen = false;
   if (!FD->isDependentContext()) {
     Optional<GVALinkage> Linkage;
-    if ((Writer->WritingModule &&
-         Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) ||
-        Writer->Context->getLangOpts().BuildingPCHWithObjectFile) {
+    if (Writer->WritingModule &&
+        Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
       // When building a C++ Modules TS module interface unit, a strong
       // definition in the module interface is provided by the compilation of
       // that module interface unit, not by its users. (Inline functions are


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74846.246122.patch
Type: text/x-patch
Size: 1877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200223/1ba46a65/attachment.bin>


More information about the cfe-commits mailing list