Author: Alexandros Lamprineas Date: 2024-08-01T09:02:41+02:00 New Revision: bb412b723139a7a7f20f768857d9d4c656ac6fbb
URL: https://github.com/llvm/llvm-project/commit/bb412b723139a7a7f20f768857d9d4c656ac6fbb DIFF: https://github.com/llvm/llvm-project/commit/bb412b723139a7a7f20f768857d9d4c656ac6fbb.diff LOG: Changes from last revision: * Replaced areFMVCompatible with hasSameType. Looks like this change was unnecessary in the first place. Most likely a residue from my WIP before I raised the PR. Thanks Sander for finding this! * Removed the corresponding sema test for variadic type mismatch. Added: Modified: clang/include/clang/AST/ASTContext.h clang/lib/AST/ASTContext.cpp clang/test/Sema/attr-target-version.c Removed: ################################################################################ diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 419104059838f..6d1c8ca8a2f96 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -3189,25 +3189,6 @@ class ASTContext : public RefCountedBase<ASTContext> { const FunctionDecl *FD, llvm::function_ref<void(FunctionDecl *)> Pred) const; - bool areFMVCompatible(const FunctionDecl *FD1, - const FunctionDecl *FD2) const { - if (!hasSameType(FD1->getReturnType(), FD2->getReturnType())) - return false; - - if (FD1->isVariadic() != FD2->isVariadic()) - return false; - - if (FD1->getNumParams() != FD2->getNumParams()) - return false; - - for (unsigned I = 0; I < FD1->getNumParams(); ++I) - if (!hasSameType(FD1->getParamDecl(I)->getOriginalType(), - FD2->getParamDecl(I)->getOriginalType())) - return false; - - return true; - } - const CXXConstructorDecl * getCopyConstructorForExceptionObject(CXXRecordDecl *RD); diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 8f121ed0fe86c..7af9ea7105bb0 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -12451,7 +12451,8 @@ void ASTContext::forEachMultiversionedFunctionVersion( for (auto *CurDecl : FD->getDeclContext()->getRedeclContext()->lookup(FD->getDeclName())) { FunctionDecl *CurFD = CurDecl->getAsFunction()->getMostRecentDecl(); - if (CurFD && areFMVCompatible(CurFD, FD) && !SeenDecls.contains(CurFD)) { + if (CurFD && hasSameType(CurFD->getType(), FD->getType()) && + !SeenDecls.contains(CurFD)) { SeenDecls.insert(CurFD); Pred(CurFD); } diff --git a/clang/test/Sema/attr-target-version.c b/clang/test/Sema/attr-target-version.c index 91c89cfd1e7b0..88a927a58f991 100644 --- a/clang/test/Sema/attr-target-version.c +++ b/clang/test/Sema/attr-target-version.c @@ -112,15 +112,3 @@ int unspec_args_implicit_default_first(); // expected-note@+1 {{function multiversioning caused by this declaration}} int __attribute__((target_version("aes"))) unspec_args_implicit_default_first() { return -1; } int __attribute__((target_version("default"))) unspec_args_implicit_default_first() { return 0; } - -void __attribute__((target_version("default"))) variadic_ok(int x, ...) {} -void __attribute__((target_version("fp"))) variadic_ok(int x, ...) {} -// expected-note@+1 {{candidate function}} -void __attribute__((target_version("default"))) variadic_bad(int x) {} -void __attribute__((target_version("fp"))) variadic_bad(int x, ...) {} - -void calls_variadic() { - variadic_ok(3); - //expected-error@+1 {{call to 'variadic_bad' is ambiguous}} - variadic_bad(3); -} _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits