================
@@ -34,16 +35,38 @@ enum class IsSubstitution_t : bool { Original, Replacement
};
struct VersionedInfoMetadata {
/// An empty version refers to unversioned metadata.
VersionTuple Version;
+ /// Which lookup group this slice came from.
+ /// See the SwiftVersionedAddition comment in Attr.td.
+ unsigned SliceGroup;
unsigned IsActive : 1;
unsigned IsReplacement : 1;
- VersionedInfoMetadata(VersionTuple Version, IsActive_t Active,
- IsSubstitution_t Replacement)
- : Version(Version), IsActive(Active == IsActive_t::Active),
+ VersionedInfoMetadata(VersionTuple Version, unsigned SliceGroup,
+ IsActive_t Active, IsSubstitution_t Replacement)
+ : Version(Version), SliceGroup(SliceGroup),
+ IsActive(Active == IsActive_t::Active),
IsReplacement(Replacement == IsSubstitution_t::Replacement) {}
};
} // end anonymous namespace
+/// The slice lookup groups a declaration can receive, numbered so that
+/// ascending group order is the order Sema applies them in.
+///
+/// Sema makes up to two lookups per API notes reader. The broad lookup matches
+/// on the declaration's name alone. The parameter-selector lookup matches on
+/// the name plus a `Where: Parameters:` entry, and runs only for a declaration
+/// that has a parameter selector. Sema applies them reader by reader, broad
+/// first, so giving each reader an adjacent pair keeps the ordinals in
+/// application order. A consumer needs that order to resolve two groups whose
+/// winners set the same key.
+static unsigned broadSliceGroup(unsigned ReaderIndex) {
----------------
artemcm wrote:
I have convinced myself that you're right.
I first implemented this on a fork which didn't have `Where: Parameters:` logic
yet and had a simple counter and added this when making sense of the added
parameter-specific slices.
But I think a simple counter should still do the right thing by incrementing in
lookup order. Will amend, thanks.
https://github.com/llvm/llvm-project/pull/224860
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits