diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -4220,7 +4220,7 @@ using field_range = llvm::iterator_range>; field_range fields() const { return field_range(field_begin(), field_end()); } - field_iterator field_begin() const; + virtual field_iterator field_begin() const; field_iterator field_end() const { return field_iterator(decl_iterator()); diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -554,6 +554,11 @@ bool hasDefinition() const { return DefinitionData || dataPtr(); } + RecordDecl::field_iterator field_begin() const override { + assert(hasDefinition() && "Definition not available to get fields."); + return static_cast(getDefinition())->field_begin(); + } + static CXXRecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id,