Page MenuHomePhabricator

[ASTReader] Treat multiple defns of ObjC protocols the same as interfaces.

Authored by graydon on Jun 28 2017, 12:07 AM.



In change 2ba19793512, the ASTReader logic for ObjC interfaces was modified to
preserve the first definition-data read, "merging" later definitions into it
rather than overwriting it (though this "merging" is, in practice, a no-op that
discards the later definition-data).

Unfortunately this change was only made to ObjC interfaces, not protocols; this
means that when (for example) loading a protocol that references an interface,
if both the protocol and interface are multiply defined (as can easily happen
if the same header is read from multiple contexts), an _inconsistent_ pair of
definitions is loaded: first-read for the interface and last-read for the

This in turn causes very subtle downstream bugs in the Swift ClangImporter,
which filters the results of name lookups based on the owning module of a
definition; inconsistency between a pair of related definitions causes name
lookup failures at various stages of compilation.

To fix these downstream issues, this change replicates the logic applied to
interfaces in change 2ba19793512, but for ObjC protocols.


Diff Detail


Event Timeline

graydon created this revision.Jun 28 2017, 12:07 AM
doug.gregor accepted this revision.Jun 28 2017, 10:12 AM

Looks great!

This revision is now accepted and ready to land.Jun 28 2017, 10:12 AM
This revision was automatically updated to reflect the committed changes.