[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 17 06:46:56 PST 2018

martong added a comment.

Alexey, simply put, the crux of the problem is this:
The imported decl context is different than what we get by calling the `getDeclContext()` on an imported field/friend of the "from" decl context.

With other words:
`import(cast<Decl>(FromDC)` gives us a different value than what we get from `ToD->getDeclContext()` inside the for loop which iterates over the fields/friends of `FromDC`.

This seems abnormal, because we would expect the two to be equal. This is why I suspect something related to an LLDB specific use case (and what's worse it happens only on macOS). In LLDB, I have seen they first do a minimal import then they require the definition with `ASTImporter::importDefinition` (but I am not sure if this is the real root cause here). I guess this is a scenario we don't have any unittest neither lit tests for in Clang. In an ideal world we should fix this inequivalence first and then could we apply this patch.

The workaround I provided is to use the  decl context of the first imported field and use that as target decl context (and not use the decl context given by import(FromDC)).

Hope this helps

  rC Clang



More information about the cfe-commits mailing list