[RFC] analyzer: Add exit, and _exit replacement, to sm-signal.

David Malcolm dmalcolm@redhat.com
Sun May 17 22:42:14 GMT 2020


On Sun, 2020-05-17 at 18:39 -0400, David Malcolm via Gcc-patches wrote:
> On Mon, 2020-05-18 at 00:05 +0200, Mark Wielaard wrote:

[...snip...]

> How about something like this (though I even haven't checked if it
> compiles, and am not 100% sure what the wording should be):
> 
>   bool emit (rich_location *rich_loc) FINAL OVERRIDE
>   {
>     diagnostic_metadata m;
>     /* CWE-479: Signal Handler Use of a Non-reentrant Function.  */
>     m.add_cwe (479);

...and there should be this here:
      auto_diagnostic_group d;

to associate the note with the warning.

>     if (warning_meta (rich_loc, m,
> 		      OPT_Wanalyzer_unsafe_call_within_signal_handler,
> 		      "call to %qD from within signal handler",
> 		      m_unsafe_fndecl))
>       {
> 	if (m_replacement)
> 	  {
> 	    gcc_rich_location note_rich_loc (gimple_location
> (m_unsafe_call));
> 	    note_rich_loc.add_fixit_replace (m_replacement);
> 	    inform (&note_rich_loc, "%qs is a signal-safe replacement
> for %qD",
> 		    m_replacement, unsafe_fndecl);
> 	  }
> 	return true;
>       }
>     return false;
>   }




More information about the Gcc-patches mailing list