[PATCH] D142384: [C++20] Fix a crash with modules.
    Utkarsh Saxena via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Thu Feb  2 08:07:14 PST 2023
    
    
  
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6121432da79: [C++20] Fix a crash with modules. (authored by usaxena95).
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142384/new/
https://reviews.llvm.org/D142384
Files:
  clang/lib/AST/Decl.cpp
Index: clang/lib/AST/Decl.cpp
===================================================================
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -4770,7 +4770,10 @@
 RecordDecl::field_iterator RecordDecl::field_begin() const {
   if (hasExternalLexicalStorage() && !hasLoadedFieldsFromExternalStorage())
     LoadFieldsFromExternalStorage();
-
+  // This is necessary for correctness for C++ with modules.
+  // FIXME: Come up with a test case that breaks without definition.
+  if (RecordDecl *D = getDefinition(); D && D != this)
+    return D->field_begin();
   return field_iterator(decl_iterator(FirstDecl));
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142384.494315.patch
Type: text/x-patch
Size: 629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230202/80505816/attachment.bin>
    
    
More information about the cfe-commits
mailing list