[clang][Sema] Improve diagnostics for auto return type
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Tue, 9 May 2023 18:05:55 +0000 (14:05 -0400)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Wed, 31 May 2023 03:35:59 +0000 (23:35 -0400)
commit0442d08fdb173d89b0779d32eb929957a344f5e6
treecb469f6e809b5ae074d87b602051a98cc9c1b2e8
parentd5001e4f0daa19d41da8715e511acaa125cef0a4
[clang][Sema] Improve diagnostics for auto return type

Currently when clang fails to deduce auto return type of a function,
it does not emit any notes about why it fails. This causes difficulty
for users to fix such errors.

Actually, clang already generates the information for emitting notes
about the failed deduction. There is a TODO for actually emitting
them.

This patch tries to implement the TODO. Basically it passes the
failed template specialization candidate set from the point of
specialization failure back to the point where the deduction starts.

It is not comprehensive but would be a start for further improvement.

Reviewed by: Richard Smith, Matheus Izvekov

Differential Revision: https://reviews.llvm.org/D150212

Fixes: SWDEV-354278
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaCXX/auto-type-from-cxx.cpp