[ODRHash] Detect mismatches in anonymous `RecordDecl`.
authorVolodymyr Sapsai <vsapsai@apple.com>
Tue, 6 Dec 2022 02:03:08 +0000 (18:03 -0800)
committerVolodymyr Sapsai <vsapsai@apple.com>
Thu, 19 Jan 2023 21:58:31 +0000 (15:58 -0600)
commitf33b5b1bf703ee5ff73126fefe2a9bcbd54db457
tree9ba203ba9147b0fe2e00db93e9a42af080c8df61
parent160bc160b9b114069a8cb9b4cc887aa86e5ca7c4
[ODRHash] Detect mismatches in anonymous `RecordDecl`.

Allow completing a redeclaration check for anonymous structs/unions
inside `RecordDecl`, so we deserialize and compare anonymous entities
from different modules.

Completing the redeclaration chain for `RecordDecl` in
`ASTContext::getASTRecordLayout` mimics the behavior in
`CXXRecordDecl::dataPtr`. Instead of completing the redeclaration chain
every time we request a definition, do that right before we need a
complete definition in `ASTContext::getASTRecordLayout`.

Such code is required only for anonymous `RecordDecl` because we
deserialize named decls when we look them up by name. But it doesn't
work for anonymous decls as they don't have a name. That's why need to
force deserialization of anonymous decls in a different way.

rdar://81864186

Differential Revision: https://reviews.llvm.org/D140055
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/Serialization/ASTReader.cpp
clang/test/Modules/compare-record.c