Skip to content

Commit

Permalink
[FMV] Allow multi versioning without default declaration.
Browse files Browse the repository at this point in the history
This was a limitation which has now been lifted upon request.
Please read the thread below for more details:

llvm#84405 (comment)

Basically it allows to separate versioned implementations across
different TUs without having to share private header files which
contain the default declaration.
  • Loading branch information
labrinea committed Mar 15, 2024
1 parent 6a49501 commit e8c659e
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 125 deletions.
6 changes: 3 additions & 3 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11447,9 +11447,9 @@ static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD) {
"Function lacks multiversion attribute");
const auto *TA = FD->getAttr<TargetAttr>();
const auto *TVA = FD->getAttr<TargetVersionAttr>();
// Target and target_version only causes MV if it is default, otherwise this
// is a normal function.
if ((TA && !TA->isDefaultVersion()) || (TVA && !TVA->isDefaultVersion()))
// The target attribute only causes MV if this declaration is the default,
// otherwise it is treated as a normal function.
if (TA && !TA->isDefaultVersion())
return false;

if ((TA || TVA) && CheckMultiVersionValue(S, FD)) {
Expand Down
Loading

0 comments on commit e8c659e

Please sign in to comment.