[PATCH] D142384: [C++20] Fix a crash with modules.
Utkarsh Saxena via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 31 02:49:40 PST 2023
usaxena95 updated this revision to Diff 493538.
usaxena95 added a comment.
Moved the use of definition where fields are accessed.
This now resolves several other C++20/Module related crashes as well.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142384/new/
https://reviews.llvm.org/D142384
Files:
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
Index: clang/include/clang/AST/DeclCXX.h
===================================================================
--- clang/include/clang/AST/DeclCXX.h
+++ 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<const RecordDecl *>(getDefinition())->field_begin();
+ }
+
static CXXRecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
IdentifierInfo *Id,
Index: clang/include/clang/AST/Decl.h
===================================================================
--- clang/include/clang/AST/Decl.h
+++ clang/include/clang/AST/Decl.h
@@ -4220,7 +4220,7 @@
using field_range = llvm::iterator_range<specific_decl_iterator<FieldDecl>>;
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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142384.493538.patch
Type: text/x-patch
Size: 1246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230131/cf010e0a/attachment-0001.bin>
More information about the cfe-commits
mailing list