This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add missing diagnostics for invalid overloads of multiversion functions in C.
ClosedPublic

Authored by tahonermann on Mar 17 2022, 2:28 PM.

Details

Summary

Previously, an attempt to declare an overload of a multiversion function
in C was not properly diagnosed. In some cases, diagnostics were simply
missing. In other cases the following assertion failure occured...

Assertion `(Previous.empty() || llvm::any_of(Previous, [](const NamedDecl *ND) { return ND->hasAttr(); })) && "Non-redecls shouldn't happen without overloadable present"' failed.

... or the following diagnostic was spuriously issued.

error: at most one overload for a given name may lack the 'overloadable' attribute

The diagnostics issued in some cases could be improved. When the function
type of a redeclaration does not match the prior declaration, it would be
preferable to diagnose the type mismatch before diagnosing mismatched
attributes. Diagnostics are also missing for some cases.

Diff Detail

Event Timeline

tahonermann created this revision.Mar 17 2022, 2:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 2:28 PM
tahonermann published this revision for review.Mar 17 2022, 2:52 PM

This change resolves both LLVM issue https://github.com/llvm/llvm-project/issues/50192 and Intel issue CMPLRLLVM-28177.

Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2022, 2:52 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Intel issue CMPLRLLVM-28177.

These words have no power here.

erichkeane accepted this revision.Mar 18 2022, 7:04 AM

Generally looks fine to me. Just 1 test that looks suspicious.

clang/test/Sema/attr-cpuspecific.c
133

In what way is this test different than bad_overload1?

This revision is now accepted and ready to land.Mar 18 2022, 7:04 AM

These words have no power here.

No power, but not uninformative to some. I promise to keep such references out of git's permanent record :)

clang/test/Sema/attr-cpuspecific.c
133

bad_overload1 has cpu_specific in both declarations while the declarations for bad_overload3 exercise both cpu_dispatch and cpu_specific.

LGTM, thanks for the clarification!

clang/test/Sema/attr-cpuspecific.c
133

Ah!

Corrected a clang-format issue.

This might've caused a regression? (https://github.com/llvm/llvm-project/issues/54892)

@dblaikie, it most definitely did. Note that I'm the author of the patch that introduced the regression, the reporter of the regression, and the assignee for fixing the regression ;)

This might've caused a regression? (https://github.com/llvm/llvm-project/issues/54892)

@dblaikie, it most definitely did. Note that I'm the author of the patch that introduced the regression, the reporter of the regression, and the assignee for fixing the regression ;)

Ah, sorry, didn't check the author/folks involved. It's not uncommon for non-contributors to file bugs for new breakages and for contributors not to be monitoring the bugs that closely - so usually a conversation on the commit/review is a better place for visibility - so was passing it along to make sure it didn't get lost :)