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


Repository:
  rC Clang

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

https://reviews.llvm.org/D44100



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to