[committed] Add diagnostic_metadata and CWE support

Jakub Jelinek jakub@redhat.com
Tue Jan 28 10:40:00 GMT 2020


On Wed, Dec 18, 2019 at 07:08:25PM -0500, David Malcolm wrote:
> This patch adds support for associating a diagnostic message with an
> optional diagnostic_metadata object, so that plugins can add extra data
> to their diagnostics (e.g. mapping a diagnostic to a taxonomy or coding
> standard such as from CERT or MISRA).
> 
> Currently this only supports associating a CWE identifier with a
> diagnostic (which is what I'm using for the warnings in the analyzer
> patch kit), but adding a diagnostic_metadata class allows for future
> growth in this area without an explosion of further "warning_at"
> overloads for all of the different kinds of custom data that a plugin
> might want to add.
> 
> This version of the patch renames the overly-general
> -fdiagnostics-show-metadata to -fdiagnostics-show-cwe and adds test
> coverage for it via a plugin.
> 
> It also adds a note to the documentation that no GCC diagnostics
> currently use this; it's a feature for plugins (and, at some point,
> I hope, the analyzer).
> 
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
> 
> Committed to trunk as r279556.

Unfortunately, this patch broke the i18n.
$ make gcc.pot
/bin/sh ../../gcc/../mkinstalldirs po
make srcextra
make[1]: Entering directory '/usr/src/gcc/obj/gcc'
cp -p gengtype-lex.c ../../gcc
cp -p gengtype-lex.c ../../gcc
make[1]: Leaving directory '/usr/src/gcc/obj/gcc'
AWK=gawk /bin/sh ../../gcc/po/exgettext \
	/usr/bin/xgettext gcc ../../gcc
scanning for keywords, %e and %n strings...
emit_diagnostic_valist used incompatibly as both --keyword=emit_diagnostic_valist:4
--flag=emit_diagnostic_valist:4:gcc-internal-format and --keyword=emit_diagnostic_valist:5
--flag=emit_diagnostic_valist:5:gcc-internal-format
make: *** [Makefile:4338: po/gcc.pot] Error 1

While C++ can have overloads, xgettext can't deal with overloads that have
different argument positions.
emit_diagnostic_valist with the new args (i.e. the :5 one) isn't used right
now, so one way around at least for now is to remove it again, another is to
rename it.

	Jakub



More information about the Gcc-patches mailing list