On 8/19/25 4:49 AM, Alfie Richards wrote:
This change refactors FMV handling in the frontend to allows greater
reasoning about versions in shared code.
This is needed for allowing target_clones and target_versions to be used
together in a function set, as there is then two distinct concerns when
encountering two declarations that previously were conflated:
1. Are these two declarations completely distinct FMV declarations
(ie. the sets of versions they define have no overlap). If so, they don't
conflict so there is no need to merge and both can be pushed.
2. For two declarations that aren't completely distinct, are they matching
and therefore mergeable. (ie. two target_clone decls that define the same set
of versions, or an un-annotated declaration, and a target_clones definition
containing the default version). If so, continue to the existing merging logic
to try to merge these and diagnose if it's not possible.
If not, then diagnose the confliciting declarations.
To do this the common_function_versions function has been renamed
distinct_function_versions (meaning, are the version sets defined by these
two decl's completely distinct from each other).
I think "disjoint" would be clearer than "distinct".
The common function version hook was modified to instead take two
string_slice's (each representing a single version) and determine if they
define the same version.
So you're reversing the sense of common_function_versions; previously it
returned true if they were different versions of the same function, now
it returns true if they're the same version? That seems problematic;
instead of reusing the same name let's use something clearer like "same"
or "equal".
A new function, called diagnose_versioned_decls is added, which checks
if two decls (with overlapping version sets) can be merged and diagnose when
they cannot be (only in terms of the attributes, the existing logic is used to
detect other mergability conflicts like redefinition).
Generally a "diagnose_" function returns true on error, please adjust
this one accordingly. Or rename it, perhaps to start with "check_",
which tends to mean returning true if OK.
Jason