[clang] [FMV] Allow target version definitions in any order. (PR #83887)

Pavel Iliin via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 5 03:20:03 PST 2024


================
@@ -11429,6 +11429,16 @@ static bool CheckTargetCausesMultiVersioning(Sema &S, FunctionDecl *OldFD,
                                              bool &Redeclaration,
                                              NamedDecl *&OldDecl,
                                              LookupResult &Previous) {
+  assert(!OldFD->isMultiVersion() && "Unexpected MultiVersion");
+
+  // The definitions should be allowed in any order. If we have discovered
+  // a new target version and the preceeding was the default, then add the
+  // corresponding attribute to it.
+  if (OldFD->getMultiVersionKind() == MultiVersionKind::None &&
----------------
ilinpv wrote:

Should it work for case target_version("default") declared first? It would good to add tests for various orders of function definition and target_version attributes. 

https://github.com/llvm/llvm-project/pull/83887


More information about the cfe-commits mailing list