On 8/28/25 5:49 AM, [email protected] wrote:
From: Alfie Richards <[email protected]>
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 disjoint 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 dijoint, are they matching
"disjoint"
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.
"conflicting"
To do this the common_function_versions function has been renamed
disjoint_function_versions (meaning, are the version sets defined by these
two decl's completely distinct from eachother).
each other
A new hook called same_function_version is introduces taking two
string_slice's (each representing a single version) and determining if they
define the same version.
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).
mergeability
+/* Check if the target_version/target_clones attributes are mergeable
+ for two decls, and if so returns false.
+ If they aren't mergeable, diagnose this and return true.
+ Only works for target_version semantics. */
+bool
+diagnose_versioned_decls (tree old_decl, tree new_decl)
+{
...
+ /* The only remaining case is two target_version annoteted decls. Must
"annotated"
C++ changes are OK with these typos fixed.
Jason