diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ed3db3e003e5fd6302d3516ead51380ebc7ee5d3..513474842510e3baeb9cd27620a494b65fbe914e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2020-01-28 David Malcolm <dmalcolm@redhat.com> + + * diagnostic-core.h (warning_at): Rename overload to... + (warning_meta): ...this. + (emit_diagnostic_valist): Delete decl of overload taking + diagnostic_metadata. + * diagnostic.c (emit_diagnostic_valist): Likewise for defn. + (warning_at): Rename overload taking diagnostic_metadata to... + (warning_meta): ...this. + 2020-01-28 Richard Biener <rguenther@suse.de> PR tree-optimization/93439 diff --git a/gcc/analyzer/ChangeLog b/gcc/analyzer/ChangeLog index 9ba6adc6b0192830f0086984deb5d8455e5d2d38..cea973d9a47d5cae43eb9403e56fd953cdd1d33c 100644 --- a/gcc/analyzer/ChangeLog +++ b/gcc/analyzer/ChangeLog @@ -1,3 +1,20 @@ +2020-01-28 David Malcolm <dmalcolm@redhat.com> + + * region-model.cc (poisoned_value_diagnostic::emit): Update for + renaming of warning_at overload to warning_meta. + * sm-file.cc (file_leak::emit): Likewise. + * sm-malloc.cc (double_free::emit): Likewise. + (possible_null_deref::emit): Likewise. + (possible_null_arg::emit): Likewise. + (null_deref::emit): Likewise. + (null_arg::emit): Likewise. + (use_after_free::emit): Likewise. + (malloc_leak::emit): Likewise. + (free_of_non_heap::emit): Likewise. + * sm-sensitive.cc (exposure_through_output_file::emit): Likewise. + * sm-signal.cc (signal_unsafe_call::emit): Likewise. + * sm-taint.cc (tainted_array_index::emit): Likewise. + 2020-01-27 David Malcolm <dmalcolm@redhat.com> PR analyzer/93451 diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 62c96a6ceeae214750e9829d492a0407fe8156fe..acaadcf9d3be448fe14354a6f990880a33072f58 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -3827,27 +3827,26 @@ public: { diagnostic_metadata m; m.add_cwe (457); /* "CWE-457: Use of Uninitialized Variable". */ - return warning_at (rich_loc, m, - OPT_Wanalyzer_use_of_uninitialized_value, - "use of uninitialized value %qE", - m_expr); + return warning_meta (rich_loc, m, + OPT_Wanalyzer_use_of_uninitialized_value, + "use of uninitialized value %qE", + m_expr); } break; case POISON_KIND_FREED: { diagnostic_metadata m; m.add_cwe (416); /* "CWE-416: Use After Free". */ - return warning_at (rich_loc, m, - OPT_Wanalyzer_use_after_free, - "use after %<free%> of %qE", - m_expr); + return warning_meta (rich_loc, m, + OPT_Wanalyzer_use_after_free, + "use after %<free%> of %qE", + m_expr); } break; case POISON_KIND_POPPED_STACK: { - diagnostic_metadata m; /* TODO: which CWE? */ - return warning_at (rich_loc, m, + return warning_at (rich_loc, OPT_Wanalyzer_use_of_pointer_in_stale_stack_frame, "use of pointer %qE within stale stack frame", m_expr); diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc index 1144492653835446a9c3e866bf7df20ae8c1f248..7c546997a0cd9a2fa00125917ff5a47f3b7e3ad9 100644 --- a/gcc/analyzer/sm-file.cc +++ b/gcc/analyzer/sm-file.cc @@ -178,9 +178,9 @@ public: /* CWE-775: "Missing Release of File Descriptor or Handle after Effective Lifetime". */ m.add_cwe (775); - return warning_at (rich_loc, m, OPT_Wanalyzer_file_leak, - "leak of FILE %qE", - m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_file_leak, + "leak of FILE %qE", + m_arg); } label_text describe_state_change (const evdesc::state_change &change) diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc index 526680accf2b98bef9985147e472c265006393cd..9415a0741354036630bf2c98b524f047e0cfaab2 100644 --- a/gcc/analyzer/sm-malloc.cc +++ b/gcc/analyzer/sm-malloc.cc @@ -145,8 +145,8 @@ public: auto_diagnostic_group d; diagnostic_metadata m; m.add_cwe (415); /* CWE-415: Double Free. */ - return warning_at (rich_loc, m, OPT_Wanalyzer_double_free, - "double-%<free%> of %qE", m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_double_free, + "double-%<free%> of %qE", m_arg); } label_text describe_state_change (const evdesc::state_change &change) @@ -235,8 +235,9 @@ public: /* CWE-690: Unchecked Return Value to NULL Pointer Dereference. */ diagnostic_metadata m; m.add_cwe (690); - return warning_at (rich_loc, m, OPT_Wanalyzer_possible_null_dereference, - "dereference of possibly-NULL %qE", m_arg); + return warning_meta (rich_loc, m, + OPT_Wanalyzer_possible_null_dereference, + "dereference of possibly-NULL %qE", m_arg); } label_text describe_final_event (const evdesc::final_event &ev) FINAL OVERRIDE @@ -297,9 +298,9 @@ public: diagnostic_metadata m; m.add_cwe (690); bool warned - = warning_at (rich_loc, m, OPT_Wanalyzer_possible_null_argument, - "use of possibly-NULL %qE where non-null expected", - m_arg); + = warning_meta (rich_loc, m, OPT_Wanalyzer_possible_null_argument, + "use of possibly-NULL %qE where non-null expected", + m_arg); if (warned) inform_nonnull_attribute (m_fndecl, m_arg_idx); return warned; @@ -338,8 +339,9 @@ public: /* CWE-690: Unchecked Return Value to NULL Pointer Dereference. */ diagnostic_metadata m; m.add_cwe (690); - return warning_at (rich_loc, m, OPT_Wanalyzer_null_dereference, - "dereference of NULL %qE", m_arg); + return warning_meta (rich_loc, m, + OPT_Wanalyzer_null_dereference, + "dereference of NULL %qE", m_arg); } label_text describe_return_of_state (const evdesc::return_of_state &info) @@ -386,8 +388,9 @@ public: auto_diagnostic_group d; diagnostic_metadata m; m.add_cwe (690); - bool warned = warning_at (rich_loc, m, OPT_Wanalyzer_null_argument, - "use of NULL %qE where non-null expected", m_arg); + bool warned = warning_meta (rich_loc, m, OPT_Wanalyzer_null_argument, + "use of NULL %qE where non-null expected", + m_arg); if (warned) inform_nonnull_attribute (m_fndecl, m_arg_idx); return warned; @@ -419,8 +422,8 @@ public: /* CWE-416: Use After Free. */ diagnostic_metadata m; m.add_cwe (416); - return warning_at (rich_loc, m, OPT_Wanalyzer_use_after_free, - "use after %<free%> of %qE", m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_use_after_free, + "use after %<free%> of %qE", m_arg); } label_text describe_state_change (const evdesc::state_change &change) @@ -459,8 +462,8 @@ public: { diagnostic_metadata m; m.add_cwe (401); - return warning_at (rich_loc, m, OPT_Wanalyzer_malloc_leak, - "leak of %qE", m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_malloc_leak, + "leak of %qE", m_arg); } label_text describe_state_change (const evdesc::state_change &change) @@ -514,16 +517,16 @@ public: default: gcc_unreachable (); case KIND_UNKNOWN: - return warning_at (rich_loc, m, OPT_Wanalyzer_free_of_non_heap, - "%<free%> of %qE which points to memory" - " not on the heap", - m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_free_of_non_heap, + "%<free%> of %qE which points to memory" + " not on the heap", + m_arg); break; case KIND_ALLOCA: - return warning_at (rich_loc, m, OPT_Wanalyzer_free_of_non_heap, - "%<free%> of memory allocated on the stack by" - " %qs (%qE) will corrupt the heap", - "alloca", m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_free_of_non_heap, + "%<free%> of memory allocated on the stack by" + " %qs (%qE) will corrupt the heap", + "alloca", m_arg); break; } } diff --git a/gcc/analyzer/sm-sensitive.cc b/gcc/analyzer/sm-sensitive.cc index a067c18fba4daaf9b3c8180c61a599602061392a..ff0c3284843933b60a4c81e6cf89b7bb2253b75b 100644 --- a/gcc/analyzer/sm-sensitive.cc +++ b/gcc/analyzer/sm-sensitive.cc @@ -105,9 +105,10 @@ public: diagnostic_metadata m; /* CWE-532: Information Exposure Through Log Files */ m.add_cwe (532); - return warning_at (rich_loc, m, OPT_Wanalyzer_exposure_through_output_file, - "sensitive value %qE written to output file", - m_arg); + return warning_meta (rich_loc, m, + OPT_Wanalyzer_exposure_through_output_file, + "sensitive value %qE written to output file", + m_arg); } label_text describe_state_change (const evdesc::state_change &change) diff --git a/gcc/analyzer/sm-signal.cc b/gcc/analyzer/sm-signal.cc index b4daf3ad61729bd8f71e06d05764fba60081516e..247e0ec750c705f26d95e86b7f0abca137f8b294 100644 --- a/gcc/analyzer/sm-signal.cc +++ b/gcc/analyzer/sm-signal.cc @@ -126,10 +126,10 @@ public: diagnostic_metadata m; /* CWE-479: Signal Handler Use of a Non-reentrant Function. */ m.add_cwe (479); - return warning_at (rich_loc, m, - OPT_Wanalyzer_unsafe_call_within_signal_handler, - "call to %qD from within signal handler", - m_unsafe_fndecl); + return warning_meta (rich_loc, m, + OPT_Wanalyzer_unsafe_call_within_signal_handler, + "call to %qD from within signal handler", + m_unsafe_fndecl); } label_text describe_state_change (const evdesc::state_change &change) diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc index 00b794a36986e063e257e5dc7e022dc2b0e820c6..dff43a4ea800ed41b80d7fb0602d7c97b51e5995 100644 --- a/gcc/analyzer/sm-taint.cc +++ b/gcc/analyzer/sm-taint.cc @@ -114,22 +114,22 @@ public: default: gcc_unreachable (); case BOUNDS_NONE: - return warning_at (rich_loc, m, OPT_Wanalyzer_tainted_array_index, - "use of tainted value %qE in array lookup" - " without bounds checking", - m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_tainted_array_index, + "use of tainted value %qE in array lookup" + " without bounds checking", + m_arg); break; case BOUNDS_UPPER: - return warning_at (rich_loc, m, OPT_Wanalyzer_tainted_array_index, - "use of tainted value %qE in array lookup" - " without lower-bounds checking", - m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_tainted_array_index, + "use of tainted value %qE in array lookup" + " without lower-bounds checking", + m_arg); break; case BOUNDS_LOWER: - return warning_at (rich_loc, m, OPT_Wanalyzer_tainted_array_index, - "use of tainted value %qE in array lookup" - " without upper-bounds checking", - m_arg); + return warning_meta (rich_loc, m, OPT_Wanalyzer_tainted_array_index, + "use of tainted value %qE in array lookup" + " without upper-bounds checking", + m_arg); break; } } diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h index 38b8557fd552126d6756805320b379fa0073580b..a18d2e3206e4e3f775be54c76e274b4d9fca241d 100644 --- a/gcc/diagnostic-core.h +++ b/gcc/diagnostic-core.h @@ -81,8 +81,9 @@ extern bool warning_at (location_t, int, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); extern bool warning_at (rich_location *, int, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); -extern bool warning_at (rich_location *, const diagnostic_metadata &, int, - const char *, ...) +extern bool warning_meta (rich_location *, + const diagnostic_metadata &, int, + const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); extern void error_n (location_t, unsigned HOST_WIDE_INT, const char *, @@ -115,10 +116,6 @@ extern bool emit_diagnostic (diagnostic_t, rich_location *, int, const char *, ...) ATTRIBUTE_GCC_DIAG(4,5); extern bool emit_diagnostic_valist (diagnostic_t, location_t, int, const char *, va_list *) ATTRIBUTE_GCC_DIAG (4,0); -extern bool emit_diagnostic_valist (diagnostic_t, rich_location *, - const diagnostic_metadata *metadata, - int, const char *, va_list *) - ATTRIBUTE_GCC_DIAG (5,0); extern bool seen_error (void); #ifdef BUFSIZ diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 72afd7c6adf08fcce462e851daafce69b935f17f..3386f070256f6ca9c51959ea06a69f0c538fc268 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -1356,17 +1356,6 @@ emit_diagnostic_valist (diagnostic_t kind, location_t location, int opt, return diagnostic_impl (&richloc, NULL, opt, gmsgid, ap, kind); } -/* Wrapper around diagnostic_impl taking a va_list parameter. */ - -bool -emit_diagnostic_valist (diagnostic_t kind, rich_location *richloc, - const diagnostic_metadata *metadata, - int opt, - const char *gmsgid, va_list *ap) -{ - return diagnostic_impl (richloc, metadata, opt, gmsgid, ap, kind); -} - /* An informative note at LOCATION. Use this for additional details on an error message. */ void @@ -1457,8 +1446,9 @@ warning_at (rich_location *richloc, int opt, const char *gmsgid, ...) /* Same as "warning at" above, but using METADATA. */ bool -warning_at (rich_location *richloc, const diagnostic_metadata &metadata, - int opt, const char *gmsgid, ...) +warning_meta (rich_location *richloc, + const diagnostic_metadata &metadata, + int opt, const char *gmsgid, ...) { gcc_assert (richloc); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9e1af091bccb29f53ee5ec80fbb91da6f34b2f93..693650d24863d1985cf0b93251bf720356bbdb85 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-01-28 David Malcolm <dmalcolm@redhat.com> + + * gcc.dg/plugin/diagnostic_plugin_test_metadata.c: Update for + renaming of warning_at overload to warning_meta. + * gcc.dg/plugin/diagnostic_plugin_test_paths.c: Likewise. + 2020-01-28 Tobias Burnus <tobias@codesourcery.com> Julian Brown <julian@codesourcery.com> diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_metadata.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_metadata.c index 5e58115afba1b8375b4d24360b08fe717a5da29f..a6108919b241582c9679637e28e13a31957ae84f 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_metadata.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_metadata.c @@ -109,8 +109,8 @@ pass_test_metadata::execute (function *fun) /* CWE-242: Use of Inherently Dangerous Function. */ diagnostic_metadata m; m.add_cwe (242); - warning_at (&richloc, m, 0, - "never use %qs", "gets"); + warning_meta (&richloc, m, 0, + "never use %qs", "gets"); } } diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c index cf05ca3a5d325e6bbf15f678a7f24478b8f963d1..767287572904857fe685242cc056d8c05c7565ca 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.c @@ -328,7 +328,8 @@ example_2 () entry_to_wrapped_free, "wrapped_free"); path.add_leaf_call (call_to_free, 2, "free"); if (i == 0 && call_to_missing_location.m_fun) - path.add_leaf_call (call_to_missing_location, 0, "missing_location"); + path.add_leaf_call (call_to_missing_location, 0, + "missing_location"); } richloc.set_path (&path); @@ -336,8 +337,8 @@ example_2 () diagnostic_metadata m; m.add_cwe (415); /* CWE-415: Double Free. */ - warning_at (&richloc, m, 0, - "double-free of %qs", "ptr"); + warning_meta (&richloc, m, 0, + "double-free of %qs", "ptr"); } } @@ -415,9 +416,9 @@ example_3 () /* CWE-479: Signal Handler Use of a Non-reentrant Function. */ m.add_cwe (479); - warning_at (&richloc, m, 0, - "call to %qs from within signal handler", - "fprintf"); + warning_meta (&richloc, m, 0, + "call to %qs from within signal handler", + "fprintf"); } }