aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/Diagnostic.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-10 18:03:33 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-10 18:03:33 +0000
commitee1828a6b5ae1bc4ea300e48f3840ac1ec5be295 (patch)
treed5796fa6d18a14ebaa512f6cb27ed8631ba0cc8e /lib/Basic/Diagnostic.cpp
parent3523d4f59eb0aa1f200dcb943093ecfe75008735 (diff)
Add a notion of "post-diagnostic hooks", which are callbacks attached
to a diagnostic that will be invoked after the diagnostic (if it is not suppressed). The hooks are allowed to produce additional diagnostics (typically notes) that provide more information. We should be able to use this to help diagnostic clients link notes back to the diagnostic they clarify. Comments welcome; I'll write up documentation and convert other clients (e.g., overload resolution failures) if there are no screams of protest. As the first client of post-diagnostic hooks, we now produce a template instantiation backtrace when a failure occurs during template instantiation. There's still more work to do to make this output pretty, if that's even possible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Diagnostic.cpp')
-rw-r--r--lib/Basic/Diagnostic.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp
index 893eae5d1a..fa5ca57dfe 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -201,6 +201,8 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
ArgToStringFn = DummyArgToStringFn;
ArgToStringCookie = 0;
+
+ InPostDiagnosticHook = false;
}
Diagnostic::~Diagnostic() {
@@ -225,6 +227,12 @@ bool Diagnostic::isBuiltinWarningOrExtension(unsigned DiagID) {
return DiagID < diag::DIAG_UPPER_LIMIT && getBuiltinDiagClass(DiagID) < ERROR;
}
+/// \brief Determine whether the given built-in diagnostic ID is a
+/// Note.
+bool Diagnostic::isBuiltinNote(unsigned DiagID) {
+ return DiagID < diag::DIAG_UPPER_LIMIT && getBuiltinDiagClass(DiagID) == NOTE;
+}
+
/// getDescription - Given a diagnostic ID, return a description of the
/// issue.
@@ -373,6 +381,16 @@ void Diagnostic::ProcessDiag() {
// Finally, report it.
Client->HandleDiagnostic(DiagLevel, Info);
if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics;
+
+ // Invoke any post-diagnostic hooks.
+ unsigned LastDiag = CurDiagID;
+ CurDiagID = ~0U;
+
+ InPostDiagnosticHook = true;
+ for (unsigned Hook = 0; Hook < NumPostDiagnosticHooks; ++Hook)
+ PostDiagnosticHooks[Hook].Hook(LastDiag,
+ PostDiagnosticHooks[Hook].Cookie);
+ InPostDiagnosticHook = false;
}