With this patch, -fdiagnostics-format=sarif-stderr emits: "sourceLanguage": "cobol"
for its artifacts, as per Appendix J of the SARIF spec. gcc/ChangeLog: * cobol/cobol1.cc (cobol_get_sarif_source_language): New. (LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE): Set it to the above. Signed-off-by: David Malcolm <dmalc...@redhat.com> --- gcc/cobol/cobol1.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc index 3819411edd3..5938c9a2c09 100644 --- a/gcc/cobol/cobol1.cc +++ b/gcc/cobol/cobol1.cc @@ -703,6 +703,14 @@ cobol_set_decl_assembler_name (tree decl) SET_DECL_ASSEMBLER_NAME (decl, id); } +/* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property, + based on the list in SARIF v2.1.0 Appendix J. */ + +const char * +cobol_get_sarif_source_language(const char *) + { + return "cobol"; + } #undef LANG_HOOKS_BUILTIN_FUNCTION #undef LANG_HOOKS_GETDECLS @@ -717,6 +725,7 @@ cobol_set_decl_assembler_name (tree decl) #undef LANG_HOOKS_TYPE_FOR_MODE #undef LANG_HOOKS_TYPE_FOR_SIZE #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME +#undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE #define LANG_HOOKS_NAME "Cobol" @@ -737,6 +746,8 @@ cobol_set_decl_assembler_name (tree decl) #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME cobol_set_decl_assembler_name +#define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE cobol_get_sarif_source_language + struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; #include "gt-cobol-cobol1.h" -- 2.26.3