Modernization; no functional change intended.
gcc/ChangeLog:
* diagnostic-color.cc: Use nullptr rather than NULL.
* diagnostic-format-sarif.cc: Likewise.
* diagnostic-format-text.cc: Likewise.
* diagnostic-macro-unwinding.cc: Likewise.
* diagnostic-path-output.cc: Likewise.
* diagnostic-path.cc: Likewise.
* diagnostic-show-locus.cc: Likewise.
* diagnostic-spec.cc: Likewise.
* diagnostic.cc: Likewise.
* lazy-diagnostic-path.cc: Likewise.
* simple-diagnostic-path.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
size_t name_len = 0, val_len = 0;
name = q = envvar_value;
- val = NULL;
+ val = nullptr;
/* From now on, be well-formed or you're gone. */
for (;;)
if (*q == ':' || *q == '\0')
if (*q == '\0')
return true;
name = ++q;
- val = NULL;
+ val = nullptr;
}
else if (*q == '=')
{
name_len = q - name;
val = ++q; /* Can be the empty string. */
}
- else if (val == NULL)
+ else if (val == nullptr)
q++; /* Accumulate name. */
else if (*q == ';' || (*q >= '0' && *q <= '9'))
q++; /* Accumulate val. Protect the terminal from being sent
handle = GetStdHandle (STD_ERROR_HANDLE);
- if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL))
+ if ((handle != INVALID_HANDLE_VALUE) && (handle != nullptr))
isconsole = GetConsoleMode (handle, &mode);
#ifdef ENABLE_VIRTUAL_TERMINAL_PROCESSING
const char *p;
p = getenv ("GCC_URLS"); /* Plural! */
- if (p == NULL)
+ if (p == nullptr)
p = getenv ("TERM_URLS");
- if (p == NULL)
+ if (p == nullptr)
return URL_FORMAT_DEFAULT;
if (*p == '\0')
DWORD mode;
handle = GetStdHandle (STD_ERROR_HANDLE);
- if ((handle == INVALID_HANDLE_VALUE) || (handle == NULL))
+ if ((handle == INVALID_HANDLE_VALUE) || (handle == nullptr))
return false;
/* If ansi escape sequences aren't supported by the console, then URLs will
/* If we don't have any useful information, don't print
anything. */
- if (filename == NULL && function == NULL)
+ if (filename == nullptr && function == nullptr)
return 0;
/* Skip functions in diagnostic.cc or diagnostic-global-context.cc. */
if (closure->m_frames_arr->size () == 0
- && filename != NULL
+ && filename != nullptr
&& (strcmp (lbasename (filename), "diagnostic.cc") == 0
|| strcmp (lbasename (filename),
"diagnostic-global-context.cc") == 0))
return 1;
}
- char *alc = NULL;
- if (function != NULL)
+ char *alc = nullptr;
+ if (function != nullptr)
{
char *str = cplus_demangle_v3 (function,
(DMGL_VERBOSE | DMGL_ANSI
| DMGL_GNU_V3 | DMGL_PARAMS));
- if (str != NULL)
+ if (str != nullptr)
{
alc = str;
function = str;
if (strncmp (function, bt_stop[i], len) == 0
&& (function[len] == '\0' || function[len] == '('))
{
- if (alc != NULL)
+ if (alc != nullptr)
free (alc);
/* Returning a non-zero value stops the backtrace. */
return 1;
frame_obj->set_integer ("lineno", lineno);
closure->m_frames_arr->append (std::move (frame_obj));
- if (alc != NULL)
+ if (alc != nullptr)
free (alc);
return 0;
pretty_printer *const pp = get_printer ();
char *saved_prefix = pp_take_prefix (pp);
- pp_set_prefix (pp, NULL);
+ pp_set_prefix (pp, nullptr);
/* Use a newline before and after and a two-space indent
to make the diagram stand out a little from the wall of text. */
pp_newline (pp);
void
diagnostic_text_output_format::print_any_cwe (const diagnostic_info &diagnostic)
{
- if (diagnostic.metadata == NULL)
+ if (!diagnostic.metadata)
return;
int cwe = diagnostic.metadata->get_cwe ();
diagnostic_text_output_format::
print_any_rules (const diagnostic_info &diagnostic)
{
- if (diagnostic.metadata == NULL)
+ if (!diagnostic.metadata)
return;
for (unsigned idx = 0; idx < diagnostic.metadata->get_num_rules (); idx++)
const char *kind_color
= diagnostic_get_color_for_kind (diagnostic.kind);
pp_string (pp, colorize_start (pp_show_color (pp), kind_color));
- char *url = NULL;
+ char *url = nullptr;
if (pp->supports_urls_p ())
{
url = rule.make_url ();
diagnostic_text_output_format::report_current_module (location_t where)
{
pretty_printer *pp = get_printer ();
- const line_map_ordinary *map = NULL;
+ const line_map_ordinary *map = nullptr;
if (pp_needs_newline (pp))
{
const char *line_col = maybe_line_and_column (s.line, col);
static const char *const msgs[] =
{
- NULL,
+ nullptr,
N_(" from"),
N_("In file included from"), /* 2 */
N_(" included from"),
{
pretty_printer *const pp = text_output.get_printer ();
char *saved_prefix = pp_take_prefix (pp);
- pp_set_prefix (pp, NULL);
+ pp_set_prefix (pp, nullptr);
pp_newline (pp);
diagnostic_show_locus (&text_output.get_context (),
text_output.get_source_printing_options (),
comment above. */
location_t resolved_def_loc =
linemap_resolve_location (line_table, iter->where,
- LRK_MACRO_DEFINITION_LOCATION, NULL);
+ LRK_MACRO_DEFINITION_LOCATION, nullptr);
/* Don't print trace for locations that are reserved or from
within a system header. */
- const line_map_ordinary *m = NULL;
+ const line_map_ordinary *m = nullptr;
location_t l =
linemap_resolve_location (line_table, resolved_def_loc,
LRK_SPELLING_LOCATION, &m);
location_t resolved_exp_loc =
linemap_resolve_location (line_table,
iter->map->get_expansion_point_location (),
- LRK_MACRO_DEFINITION_LOCATION, NULL);
+ LRK_MACRO_DEFINITION_LOCATION, nullptr);
text_output.append_note (resolved_exp_loc,
"in expansion of macro %qs",
{
const unsigned num_events = path.num_events ();
- event_range *cur_event_range = NULL;
+ event_range *cur_event_range = nullptr;
for (unsigned idx = 0; idx < num_events; idx++)
{
const diagnostic_event &event = path.get_event (idx);
|| this_logical_loc != curr_frame->m_logical_loc)
{
curr_frame = end_html_stack_frame (xp, std::move (curr_frame));
- if (curr_frame == NULL)
+ if (curr_frame == nullptr)
{
curr_frame
= begin_html_stack_frame (xp,
else
{
curr_frame = begin_html_stack_frame (xp,
- NULL,
+ nullptr,
range->m_logical_loc,
range->m_stack_depth,
logical_loc_mgr);
colorize,
show_event_links);
char *saved_prefix = pp_take_prefix (pp);
- pp_set_prefix (pp, NULL);
+ pp_set_prefix (pp, nullptr);
print_path_summary_as_text (summary, *this,
get_context ().show_path_depths_p ());
pp_flush (pp);
pp_character (pp, '}');
}
-/* Get a string (or NULL) for V suitable for use within a SARIF
+/* Get a string (or nullptr) for V suitable for use within a SARIF
threadFlowLocation "kinds" property (SARIF v2.1.0 section 3.38.8). */
const char *
}
}
-/* Get a string (or NULL) for N suitable for use within a SARIF
+/* Get a string (or nullptr) for N suitable for use within a SARIF
threadFlowLocation "kinds" property (SARIF v2.1.0 section 3.38.8). */
const char *
}
}
-/* Get a string (or NULL) for P suitable for use within a SARIF
+/* Get a string (or nullptr) for P suitable for use within a SARIF
threadFlowLocation "kinds" property (SARIF v2.1.0 section 3.38.8). */
const char *
int start_line, int start_col, int end_line, int end_col)
{
const expanded_location start_exploc
- = {"", start_line, start_col, NULL, false};
+ = {"", start_line, start_col, nullptr, false};
const expanded_location finish_exploc
- = {"", end_line, end_col, NULL, false};
+ = {"", end_line, end_col, nullptr, false};
return layout_range (exploc_with_display_col (fc,
start_exploc, def_policy (),
LOCATION_ASPECT_START),
exploc_with_display_col (fc,
start_exploc, def_policy (),
LOCATION_ASPECT_CARET),
- 0, NULL);
+ 0, nullptr);
}
/* Selftests for layout_range::contains_point and
struct pod_label_text
{
pod_label_text ()
- : m_buffer (NULL), m_caller_owned (false)
+ : m_buffer (nullptr), m_caller_owned (false)
{}
pod_label_text (label_text &&other)
FOR_EACH_VEC_ELT (m_layout.m_layout_ranges, i, range)
{
/* Most ranges don't have labels, so reject this first. */
- if (range->m_label == NULL)
+ if (range->m_label == nullptr)
continue;
/* The range's caret must be on this line. */
label_text text;
text = range->m_label->get_text (range->m_original_idx);
- /* Allow for labels that return NULL from their get_text
+ /* Allow for labels that return nullptr from their get_text
implementation (so e.g. such labels can control their own
visibility). */
- if (text.get () == NULL)
+ if (text.get () == nullptr)
continue;
labels.safe_push (line_label (range->m_original_idx,
if (loc == m_last_location
&& richloc.get_num_fixit_hints () == 0
&& richloc.get_num_locations () == 1
- && richloc.get_range (0)->m_label == NULL)
+ && richloc.get_range (0)->m_label == nullptr)
return;
m_last_location = loc;
if (loc == m_last_location
&& richloc.get_num_fixit_hints () == 0
&& richloc.get_num_locations () == 1
- && richloc.get_range (0)->m_label == NULL)
+ && richloc.get_range (0)->m_label == nullptr)
return;
m_last_location = loc;
layout_printer<to_text> lp (sink, test_layout, false);
lp.print (policy);
const char *out = pp_formatted_text (dc.get_reference_printer ());
- ASSERT_EQ (NULL, strchr (out, '\t'));
+ ASSERT_EQ (nullptr, strchr (out, '\t'));
const char *left_quote = strchr (out, '`');
const char *right_quote = strchr (out, '\'');
- ASSERT_NE (NULL, left_quote);
- ASSERT_NE (NULL, right_quote);
+ ASSERT_NE (nullptr, left_quote);
+ ASSERT_NE (nullptr, right_quote);
ASSERT_EQ (right_quote - left_quote, extra_width[tabstop] + 2);
}
dc.test_show_locus (richloc));
}
- /* Verify that a NULL result from range_label::get_text is
+ /* Verify that a nullptr result from range_label::get_text is
handled gracefully. */
{
- text_range_label label (NULL);
+ text_range_label label (nullptr);
gcc_rich_location richloc (bar, &label, nullptr);
test_diagnostic_context dc;
const nowarn_spec_t optspec (supp ? opt : opt_code ());
- if (nowarn_spec_t *pspec = nowarn_map ? nowarn_map->get (loc) : NULL)
+ if (nowarn_spec_t *pspec = nowarn_map ? nowarn_map->get (loc) : nullptr)
{
if (supp)
{
nowarn_spec_t *from_spec;
if (RESERVED_LOCATION_P (from))
- from_spec = NULL;
+ from_spec = nullptr;
else
from_spec = nowarn_map->get (from);
if (RESERVED_LOCATION_P (to))
get_terminal_width (void)
{
const char * s = getenv ("COLUMNS");
- if (s != NULL) {
+ if (s != nullptr) {
int n = atoi (s);
if (n > 0)
return n;
diagnostic->message.m_format_spec = msg;
diagnostic->message.m_richloc = richloc;
diagnostic->richloc = richloc;
- diagnostic->metadata = NULL;
+ diagnostic->metadata = nullptr;
diagnostic->kind = kind;
diagnostic->option_id = 0;
}
#define DEFINE_DIAGNOSTIC_KIND(K, T, C) (C),
#include "diagnostic.def"
#undef DEFINE_DIAGNOSTIC_KIND
- NULL
+ nullptr
};
/* Get a color name for diagnostics of type KIND
- Result could be NULL. */
+ Result could be nullptr. */
const char *
diagnostic_get_color_for_kind (diagnostic_t kind)
/* If we don't have any useful information, don't print
anything. */
- if (filename == NULL && function == NULL)
+ if (filename == nullptr && function == nullptr)
return 0;
/* Skip functions in diagnostic.cc. */
if (*pcount == 0
- && filename != NULL
+ && filename != nullptr
&& strcmp (lbasename (filename), "diagnostic.cc") == 0)
return 0;
}
++*pcount;
- char *alc = NULL;
- if (function != NULL)
+ char *alc = nullptr;
+ if (function != nullptr)
{
char *str = cplus_demangle_v3 (function,
(DMGL_VERBOSE | DMGL_ANSI
| DMGL_GNU_V3 | DMGL_PARAMS));
- if (str != NULL)
+ if (str != nullptr)
{
alc = str;
function = str;
if (strncmp (function, bt_stop[i], len) == 0
&& (function[len] == '\0' || function[len] == '('))
{
- if (alc != NULL)
+ if (alc != nullptr)
free (alc);
/* Returning a non-zero value stops the backtrace. */
return 1;
fprintf (stderr, "0x%lx %s\n\t%s:%d\n",
(unsigned long) pc,
- function == NULL ? "???" : function,
- filename == NULL ? "???" : filename,
+ function == nullptr ? "???" : function,
+ filename == nullptr ? "???" : filename,
lineno);
- if (alc != NULL)
+ if (alc != nullptr)
free (alc);
return 0;
finish ();
}
- struct backtrace_state *state = NULL;
+ struct backtrace_state *state = nullptr;
if (diag_kind == DK_ICE)
- state = backtrace_create_state (NULL, 0, bt_err_callback, NULL);
+ state = backtrace_create_state (nullptr, 0, bt_err_callback, nullptr);
int count = 0;
- if (state != NULL)
+ if (state != nullptr)
backtrace_full (state, 2, bt_callback, bt_err_callback,
(void *) &count);
gcc_assert (richloc);
char *saved_prefix = pp_take_prefix (pp);
- pp_set_prefix (pp, NULL);
+ pp_set_prefix (pp, nullptr);
for (unsigned i = 0; i < richloc->get_num_fixit_hints (); i++)
{
|| diagnostic->kind == DK_ICE
|| diagnostic->kind == DK_ICE_NOBT)
action_after_output (diagnostic->kind);
- diagnostic->x_data = NULL;
+ diagnostic->x_data = nullptr;
if (m_edit_context_ptr)
if (diagnostic->richloc->fixits_can_be_auto_applied_p ())
/* Attempt to print a backtrace. */
struct backtrace_state *state
- = backtrace_create_state (NULL, 0, bt_err_callback, NULL);
+ = backtrace_create_state (nullptr, 0, bt_err_callback, nullptr);
int count = 0;
- if (state != NULL)
+ if (state != nullptr)
backtrace_full (state, 2, bt_callback, bt_err_callback,
(void *) &count);
/* Initialize this context's m_diagrams based on CHARSET.
Specifically, make a text_art::theme object for m_diagrams.m_theme,
- (or NULL for "no diagrams"). */
+ (or nullptr for "no diagrams"). */
void
diagnostic_context::
linemap_add (line_table, LC_ENTER, false, "test.c", 0);
linemap_line_start (line_table, 5, 100);
- linemap_add (line_table, LC_LEAVE, false, NULL, 0);
+ linemap_add (line_table, LC_LEAVE, false, nullptr, 0);
location_t where = linemap_position_for_column (line_table, 10);
richloc.add_fixit_insert_before (where, "added content");
linemap_add (line_table, LC_ENTER, false, "test.c", 0);
linemap_line_start (line_table, 5, 100);
- linemap_add (line_table, LC_LEAVE, false, NULL, 0);
+ linemap_add (line_table, LC_LEAVE, false, nullptr, 0);
source_range where;
where.m_start = linemap_position_for_column (line_table, 10);
where.m_finish = linemap_position_for_column (line_table, 20);
linemap_add (line_table, LC_ENTER, false, "test.c", 0);
linemap_line_start (line_table, 5, 100);
- linemap_add (line_table, LC_LEAVE, false, NULL, 0);
+ linemap_add (line_table, LC_LEAVE, false, nullptr, 0);
source_range where;
where.m_start = linemap_position_for_column (line_table, 10);
where.m_finish = linemap_position_for_column (line_table, 20);
linemap_add (line_table, LC_ENTER, false, fname, 0);
linemap_line_start (line_table, 1, 100);
- linemap_add (line_table, LC_LEAVE, false, NULL, 0);
+ linemap_add (line_table, LC_LEAVE, false, nullptr, 0);
source_range where;
where.m_start = linemap_position_for_column (line_table, 12);
where.m_finish = linemap_position_for_column (line_table, 17);
xloc.file = filename;
xloc.line = line;
xloc.column = column;
- xloc.data = NULL;
+ xloc.data = nullptr;
xloc.sysp = false;
diagnostic_column_policy column_policy (dc);
{
const char *old_progname = progname;
progname = "PROGNAME";
- assert_location_text ("PROGNAME:", NULL, 0, 0, true);
+ assert_location_text ("PROGNAME:", nullptr, 0, 0, true);
char *built_in_colon = concat (special_fname_builtin (), ":", (char *) 0);
assert_location_text (built_in_colon, special_fname_builtin (),
42, 10, true);
std::unique_ptr<diagnostic_path> make_inner_path () const final override
{
tree fntype_void_void
- = build_function_type_array (void_type_node, 0, NULL);
+ = build_function_type_array (void_type_node, 0, nullptr);
tree fndecl_foo = build_fn_decl ("foo", fntype_void_void);
auto path
= std::make_unique<simple_diagnostic_path> (m_logical_loc_mgr,
{
tree_logical_location_manager mgr;
tree fntype_void_void
- = build_function_type_array (void_type_node, 0, NULL);
+ = build_function_type_array (void_type_node, 0, nullptr);
tree fndecl_foo = build_fn_decl ("foo", fntype_void_void);
simple_diagnostic_path path (mgr, event_pp);
stderr.
Implement this by cleaning up the global timer instance now. */
delete g_timer;
- g_timer = NULL;
+ g_timer = nullptr;
}
}