[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 10 07:31:35 PST 2018


martong added a comment.

@a_sidorin

The below diff on top of your patch successfully handles the failure with the `TestCModules.py` LLDB testcase:

  diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp
  index 05fec7f943..e6fb590025 100644
  --- a/lib/AST/ASTImporter.cpp
  +++ b/lib/AST/ASTImporter.cpp
  @@ -1695,15 +1695,22 @@ ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
     // LoadFieldsFromExternalStorage().
     auto ImportedDC = import(cast<Decl>(FromDC));
     assert(ImportedDC);
  -  auto *ToRD = cast<RecordDecl>(*ImportedDC);
  +  RecordDecl *ToRD = nullptr;
     for (auto *D : FromRD->decls()) {
       if (isa<FieldDecl>(D) || isa<FriendDecl>(D)) {
         Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
  -      assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD));
  -      ToRD->removeDecl(ToD);
  +      if (!ToRD)
  +        ToRD = cast<RecordDecl>(ToD->getDeclContext());
  +      else
  +        assert(ToRD == ToD->getDeclContext());
  +      if(ToRD->containsDecl(ToD))
  +        ToRD->removeDecl(ToD);
       }
     }
  
  +  if (!ToRD)
  +    return Error::success();
  +
     if (!ToRD->hasExternalLexicalStorage())
       assert(ToRD->field_empty());


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D44100/new/

https://reviews.llvm.org/D44100





More information about the cfe-commits mailing list