Skip to content

Commit b612143

Browse files
committed
[C++20] Fix a crash with modules.
Differential Revision: https://reviews.llvm.org/D142384
1 parent 1373f20 commit b612143

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4770,7 +4770,10 @@ bool RecordDecl::isOrContainsUnion() const {
47704770
RecordDecl::field_iterator RecordDecl::field_begin() const {
47714771
if (hasExternalLexicalStorage() && !hasLoadedFieldsFromExternalStorage())
47724772
LoadFieldsFromExternalStorage();
4773-
4773+
// This is necessary for correctness for C++ with modules.
4774+
// FIXME: Come up with a test case that breaks without definition.
4775+
if (RecordDecl *D = getDefinition(); D && D != this)
4776+
return D->field_begin();
47744777
return field_iterator(decl_iterator(FirstDecl));
47754778
}
47764779

0 commit comments

Comments
 (0)