llvm-project
ebe084f9 - [Modules] Fix the inconsistency of which `Decl` should be serialized for an identifier. (#135887)

Commit
1 year ago
[Modules] Fix the inconsistency of which `Decl` should be serialized for an identifier. (#135887) Fixes the assertion failure > Assertion failed: (DeclIDs.contains(D) && "Declaration not emitted!"), function getDeclID, file ASTWriter.cpp, line 6873. We prepare to serialize a `Decl` by adding it to `DeclIDs` in `ASTWriter::GetDeclRef`. But the checks before this call aren't the same as when we are actually serializing a `Decl` in `ASTIdentifierTableTrait::EmitData` and `ASTWriter::WriteIdentifierTable`. That's how we can end up serializing a `Decl` not present in `DeclIDs` and hitting the assertion. With the assertions disabled clang crashes when trying to use a deserialized null `Decl`. Fix by making the code checks before `ASTWriter::GetDeclRef` call similar to those we have before the serialization. rdar://139319683
Author
Parents
Loading