[Serialization] Track whether a cross-reference came from Clang (#17333)

Cross-references are identified by their containing module, with the
assumption that two modules will never have the same name. However, an
overlay has the same name as its underlying Clang module, which means
that there can be two declarations with the same name, the same type,
and the same module name. This is the underlying cause of the
'UIEdgeInsetsZero' problem, but it also affects the CloudKit overlay.

By tracking a bit that just says "this came from Clang", we're able
to resolve otherwise ambiguous cross-references.

(Why didn't we do it this way all along? Because if a declaration
moves from Clang to Swift or vice versa, that would break the
cross-reference. But that's only interesting if the swiftmodule format
is meant to be persistent across changing dependencies, and it looks
like we're moving away from that anyway. It's also a little weird for
SerializedModuleLoader to have special cases for Clang, but this isn't
the first.)

Note that I'm not reverting the UIEdgeInsetsZero workaround here; the
end state will have that coming just from UIKit as originally
described.

rdar://problem/40839486
This commit is contained in:
Jordan Rose
2018-06-20 14:51:17 -07:00
committed by GitHub
parent a7209f6862
commit 6b894154d3
4 changed files with 53 additions and 23 deletions

View File

@@ -55,7 +55,7 @@ const uint16_t VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t VERSION_MINOR = 420; // Last change: accessor refactor
const uint16_t VERSION_MINOR = 421; // Last change: track whether xrefs come from Clang
using DeclIDField = BCFixed<31>;
@@ -1308,7 +1308,8 @@ namespace decls_block {
XREF_TYPE_PATH_PIECE,
IdentifierIDField, // name
IdentifierIDField, // private discriminator
BCFixed<1> // restrict to protocol extension
BCFixed<1>, // restrict to protocol extension
BCFixed<1> // imported from Clang?
>;
using XRefValuePathPieceLayout = BCRecordLayout<
@@ -1316,6 +1317,7 @@ namespace decls_block {
TypeIDField, // type
IdentifierIDField, // name
BCFixed<1>, // restrict to protocol extension
BCFixed<1>, // imported from Clang?
BCFixed<1> // static?
>;
@@ -1323,6 +1325,7 @@ namespace decls_block {
XREF_INITIALIZER_PATH_PIECE,
TypeIDField, // type
BCFixed<1>, // restrict to protocol extension
BCFixed<1>, // imported from Clang?
CtorInitializerKindField // initializer kind
>;