mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
gdb: remove complaint_interceptor::g_complaint_interceptor
The thread_local g_complaint_interceptor pointer is unnecessary. The complaint_interceptor constructor registers itself as the warning hook via m_saved_warning_hook (this), so when complaint_internal dispatches through the warning hook, it lands in complaint_interceptor::warn with 'this' already pointing at the registered interceptor. Inside warn, g_complaint_interceptor and 'this' always refer to the same object. Replace g_complaint_interceptor->m_complaints with m_complaints in complaint_interceptor::warn and remove g_complaint_interceptor. Change-Id: I75565a5f2c0e51363f36be0e3544210c10bb5491 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
7ae086a3da
commit
1500a5d93a
2 changed files with 2 additions and 14 deletions
|
|
@ -77,13 +77,8 @@ clear_complaints ()
|
|||
|
||||
/* See complaints.h. */
|
||||
|
||||
thread_local complaint_interceptor *complaint_interceptor::g_complaint_interceptor;
|
||||
|
||||
/* See complaints.h. */
|
||||
|
||||
complaint_interceptor::complaint_interceptor ()
|
||||
: m_saved_complaint_interceptor (&g_complaint_interceptor, this),
|
||||
m_saved_warning_hook (this)
|
||||
: m_saved_warning_hook (this)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +117,7 @@ void
|
|||
complaint_interceptor::warn (const char *fmt, va_list args)
|
||||
{
|
||||
gdb::lock_guard<gdb::mutex> guard (complaint_mutex);
|
||||
g_complaint_interceptor->m_complaints.insert (string_vprintf (fmt, args));
|
||||
m_complaints.insert (string_vprintf (fmt, args));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#ifndef GDB_COMPLAINTS_H
|
||||
#define GDB_COMPLAINTS_H
|
||||
|
||||
#include "gdbsupport/scoped_restore.h"
|
||||
#include "gdbsupport/unordered_set.h"
|
||||
|
||||
/* Helper for complaint. */
|
||||
|
|
@ -89,17 +88,11 @@ private:
|
|||
/* The issued complaints. */
|
||||
complaint_collection m_complaints;
|
||||
|
||||
/* The saved value of g_complaint_interceptor. */
|
||||
scoped_restore_tmpl<complaint_interceptor *> m_saved_complaint_interceptor;
|
||||
|
||||
/* A helper function that is used by the 'complaint' implementation
|
||||
to issue a complaint. */
|
||||
void warn (const char *, va_list) override
|
||||
ATTRIBUTE_PRINTF (2, 0);
|
||||
|
||||
/* This object. Used by the static callback function. */
|
||||
static thread_local complaint_interceptor *g_complaint_interceptor;
|
||||
|
||||
/* Object to initialise the warning hook. */
|
||||
scoped_restore_warning_hook m_saved_warning_hook;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue