rsmith added inline comments.
================
Comment at: clang/lib/Sema/SemaStmt.cpp:3804-3809
+ if (DAR != DAR_Succeeded) {
+ if (OrigResultType.getBeginLoc().isValid())
+ Diag(OrigResultType.getBeginLoc(), diag::note_deducing_return_type_for)
+ << FD << OrigResultType.getSourceRange();
return true;
+ }
----------------
The approach of tacking a note onto the end of someone else's diagnostic is an
antipattern and should be avoided in new code. For example, if `DeduceAutoType`
produces an error (which is shown) then a warning (which is hidden), the note
will be attached to the warning, and will not appear.
The right thing to do is to create a new kind of `CodeSynthesisContext` for
this case and push that. Then we'll use the same logic as in template
instantiation backtraces, and the note will get properly attached to the first
emitted diagnostic within the context. This will also remove the need to track
down all the different places that emit diagnostics (like we see below): you
just push the context when you start doing the action you want to attach the
note to and pop it when you're done. It'll also properly order the note with
respect to other context notes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119778/new/
https://reviews.llvm.org/D119778
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits