This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Reduce emitting candidate notes for builtins
ClosedPublic

Authored by svenvh on Jun 16 2022, 6:26 AM.

Details

Summary

When overload resolution fails, clang emits a note diagnostic for each
candidate. For OpenCL builtins this often leads to many repeated note
diagnostics with no new information. Stop emitting such notes.

Update a test that was relying on counting those notes to check how
many builtins are available for certain extension configurations.

Diff Detail

Event Timeline

svenvh created this revision.Jun 16 2022, 6:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 16 2022, 6:26 AM
svenvh requested review of this revision.Jun 16 2022, 6:26 AM
Anastasia added inline comments.Jun 17 2022, 3:32 AM
clang/lib/Sema/SemaOverload.cpp
11272

It would have been nice to print each of those overloads but my guess is that it's too much work?

svenvh added inline comments.Jun 17 2022, 4:03 AM
clang/lib/Sema/SemaOverload.cpp
11272

It's not trivial to print those overloads because we don't have a real source declaration, but even if it was trivial I am not sure if there is much value in printing all overloads. Typically there are a lot of overloads for OpenCL builtins, partly because of all the vector versions. I don't think a user will get much value out of screens full of overloads that didn't match.

For example, for the following code

int i, j, k;
i = max(i, j, k);

without this patch clang produces 121 note diagnostics. If we manage to fit the diagnostic and candidate on a single line (which I doubt we can, normally they take 3 lines each), a user will still have to scroll through a few screens (on a 50-line terminal) of note diagnostics before reaching the actual error diagnostic.

Anastasia accepted this revision.Jun 21 2022, 2:17 AM

LGTM! Thanks

This revision is now accepted and ready to land.Jun 21 2022, 2:17 AM
This revision was landed with ongoing or failed builds.Jun 27 2022, 1:56 AM
This revision was automatically updated to reflect the committed changes.