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

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 15 23:39:27 PDT 2018


martong accepted this revision.
martong added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lib/AST/ASTImporter.cpp:1317
+  for (auto *D : FromRD->decls()) {
+    Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+    assert(ToRD == ToD->getDeclContext() && ToRD->containsDecl(ToD));
----------------
a_sidorin wrote:
> martong wrote:
> > Is it sure that `ToD` will never be a nullptr?
> > I think, `removeDecl` or `addDeclInternal` below may crash if we call it with a nullptr.
> > Also in the assert, `ToD->getDeclContext()` seems achy if `ToD` is a nullptr.
> We have an early return if such import failed before (line 1300).
Okay, that line did not catch my attention. Could you please provide a comment which describes that at this point we expect ToD to be non-null, or even better, we could have an explicit `assert(ToD) `. 


Repository:
  rC Clang

https://reviews.llvm.org/D44100





More information about the cfe-commits mailing list