While working on https://reviews.llvm.org/D110280 I've tried to merge
decl contexts as it seems to be correct and matching our handling of
decl contexts from different modules. It's not required for the fix in
https://reviews.llvm.org/D110280 but it revealed a missing diagnostic,
so separating this change into a separate commit.
Renamed some variables to distinguish diagnostic like "declaration of
'x' does not match" for different cases.
A couple of other things you should consider doing in this case:
For the latter, Reader.mergeDefinitionVisibility(DD.Definition, NewDD.Definition) should be sufficient, assuming that all code treats the first definition as being the canonical one (for example, name lookups are performed into the first definition).