r264913 - [modules] Write out identifiers if the ID is local, too.

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 30 13:16:03 PDT 2016


Author: vvassilev
Date: Wed Mar 30 15:16:03 2016
New Revision: 264913

URL: http://llvm.org/viewvc/llvm-project?rev=264913&view=rev
Log:
[modules] Write out identifiers if the ID is local, too.

In some cases a slot for an identifier is requested but it gets written to
another module, causing an assertion.

At the point when we start serializing Rtypes, we have no imported IdentifierID
for float_round_style. We start serializing stuff and allocate an ID for it.
Then, during the serialization process, we pull in the identifier info for it
from TSchemaHelper. Finally, WriteIdentifierTable decides that the identifier
has not changed since it was deserialized, so doesn't emit it.

Fixes https://llvm.org/bugs/show_bug.cgi?id=27041

Discussed on IRC with Richard Smith. Agreed on post commit review if needed.

Added:
    cfe/trunk/test/Modules/Inputs/PR27041/
    cfe/trunk/test/Modules/Inputs/PR27041/Rtypes.h
    cfe/trunk/test/Modules/Inputs/PR27041/TGenericClassInfo.h
    cfe/trunk/test/Modules/Inputs/PR27041/TSchemaHelper.h
    cfe/trunk/test/Modules/Inputs/PR27041/module.modulemap
    cfe/trunk/test/Modules/pr27041.cpp
Modified:
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=264913&r1=264912&r2=264913&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Mar 30 15:16:03 2016
@@ -3340,7 +3340,10 @@ void ASTWriter::WriteIdentifierTable(Pre
       auto *II = const_cast<IdentifierInfo *>(IdentIDPair.first);
       IdentID ID = IdentIDPair.second;
       assert(II && "NULL identifier in identifier table");
-      if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization() ||
+      // Write out identifiers if either the ID is local or the identifier has
+      // changed since it was loaded.
+      if (ID >= FirstIdentID || !Chain || !II->isFromAST()
+          || II->hasChangedSinceDeserialization() ||
           (Trait.needDecls() &&
            II->hasFETokenInfoChangedSinceDeserialization()))
         Generator.insert(II, ID, Trait);

Added: cfe/trunk/test/Modules/Inputs/PR27041/Rtypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27041/Rtypes.h?rev=264913&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27041/Rtypes.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27041/Rtypes.h Wed Mar 30 15:16:03 2016
@@ -0,0 +1 @@
+

Added: cfe/trunk/test/Modules/Inputs/PR27041/TGenericClassInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27041/TGenericClassInfo.h?rev=264913&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27041/TGenericClassInfo.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27041/TGenericClassInfo.h Wed Mar 30 15:16:03 2016
@@ -0,0 +1,3 @@
+namespace std {}
+namespace std { enum float_round_style { denorm_present }; }
+#include "TSchemaHelper.h"

Added: cfe/trunk/test/Modules/Inputs/PR27041/TSchemaHelper.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27041/TSchemaHelper.h?rev=264913&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27041/TSchemaHelper.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR27041/TSchemaHelper.h Wed Mar 30 15:16:03 2016
@@ -0,0 +1 @@
+namespace std { enum float_round_style { denorm_present }; }

Added: cfe/trunk/test/Modules/Inputs/PR27041/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR27041/module.modulemap?rev=264913&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/PR27041/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR27041/module.modulemap Wed Mar 30 15:16:03 2016
@@ -0,0 +1,2 @@
+module "Rtypes.h" { header "Rtypes.h" header "TGenericClassInfo.h" }
+module "TSchemaHelper.h" { header "TSchemaHelper.h" }

Added: cfe/trunk/test/Modules/pr27041.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/pr27041.cpp?rev=264913&view=auto
==============================================================================
--- cfe/trunk/test/Modules/pr27041.cpp (added)
+++ cfe/trunk/test/Modules/pr27041.cpp Wed Mar 30 15:16:03 2016
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR27041 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR27041/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR27041 -verify %s
+
+#include "Rtypes.h"
+
+// expected-no-diagnostics




More information about the cfe-commits mailing list