diff options
author | Matheus Izvekov <mizvekov@gmail.com> | 2025-02-20 08:50:03 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-20 08:50:03 -0300 |
commit | 0948fc85aa99a8fd193d2d66a517e31b8b639f20 (patch) | |
tree | 5177a4c7348fd6f0fd5fc81b67fccf883752d709 /clang/lib/Sema/Sema.cpp | |
parent | d7784a649e80d346ba57ccc39f5e2a3e2f7e0a51 (diff) | |
download | llvm-0948fc85aa99a8fd193d2d66a517e31b8b639f20.zip llvm-0948fc85aa99a8fd193d2d66a517e31b8b639f20.tar.gz llvm-0948fc85aa99a8fd193d2d66a517e31b8b639f20.tar.bz2 |
[clang] print correct context for diagnostics suppressed by deduction (#125453)
This patch makes it so the correct instantiation context is printed for
diagnostics suppessed by template argument deduction.
The context is saved along with the suppressed diagnostic, and when the
declaration they were attached to becomes used, we print the correct
context, instead of whatever context was at this point.
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index afd1d7a..145cda6 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1655,11 +1655,20 @@ void Sema::EmitDiagnostic(unsigned DiagID, const DiagnosticBuilder &DB) { } case DiagnosticIDs::SFINAE_Suppress: + if (DiagnosticsEngine::Level Level = getDiagnostics().getDiagnosticLevel( + DiagInfo.getID(), DiagInfo.getLocation()); + Level == DiagnosticsEngine::Ignored) + return; // Make a copy of this suppressed diagnostic and store it with the // template-deduction information; if (*Info) { - (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(), - PartialDiagnostic(DiagInfo, Context.getDiagAllocator())); + (*Info)->addSuppressedDiagnostic( + DiagInfo.getLocation(), + PartialDiagnostic(DiagInfo, Context.getDiagAllocator())); + if (!Diags.getDiagnosticIDs()->isNote(DiagID)) + PrintContextStack([Info](SourceLocation Loc, PartialDiagnostic PD) { + (*Info)->addSuppressedDiagnostic(Loc, std::move(PD)); + }); } // Suppress this diagnostic. |