In CUDA/HIP a function may become implicit host device function by
pragma or constexpr. A host device function is checked in both
host and device compilation. However it may be emitted only
on host or device side, therefore the diagnostics should be
deferred until it is known to be emitted.
Currently clang is only able to defer certain diagnostics. This causes
false alarms and limits the usefulness of host device functions.
This patch lets clang defer all overloading resolution diagnostics for host device functions.
An option -fgpu-defer-diag is added to control this behavior. By default
it is off.
It is NFC for other languages.
Do you have tests that cover this case?
This section of code came up while I was investigating this bug report: https://github.com/llvm/llvm-project/issues/48974
I tried replacing hasUncompilableErrorOccurred() with hasAnyUnrecoverableErrorsInThisFunction() and it fixes the reported bug and it does not cause any tests to fail with check-clang but it looks like hasUncompilableErrorOccurred() is doing a lot more checks and so I expected some tests to fail when I swapped it out.
If we are missing test coverage we should add some.