https://gcc.gnu.org/g:f102b82d3da6dd4d5f9af1cd622fce93d0c494eb

commit r15-6095-gf102b82d3da6dd4d5f9af1cd622fce93d0c494eb
Author: David Malcolm <dmalc...@redhat.com>
Date:   Tue Dec 10 18:31:24 2024 -0500

    sarif-replay: fix missing URLs [PR117944]
    
    gcc/ChangeLog:
            PR other/117944
            * libsarifreplay.cc (sarif_replayer::handle_result_obj): Get any
            helpUri from the rule_obj and pass it to add_rule.
    
    Signed-off-by: David Malcolm <dmalc...@redhat.com>

Diff:
---
 gcc/libsarifreplay.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/gcc/libsarifreplay.cc b/gcc/libsarifreplay.cc
index 9a053f7fe612..e8b5a55b9188 100644
--- a/gcc/libsarifreplay.cc
+++ b/gcc/libsarifreplay.cc
@@ -1004,7 +1004,20 @@ sarif_replayer::handle_result_obj (const json::object 
&result_obj,
   libgdiagnostics::group g (m_output_mgr);
   auto err (m_output_mgr.begin_diagnostic (level));
   if (rule_id)
-    err.add_rule (rule_id->get_string (), nullptr);
+    {
+      const char *url = nullptr;
+      if (rule_obj)
+       {
+         /* rule_obj should be a reportingDescriptor object (3.49).
+            Get any ยง3.49.12 helpUri property.  */
+         const property_spec_ref prop_help_uri
+           ("reportingDescriptor", "helpUri", "3.49.12");
+         if (auto url_val = get_optional_property<json::string>(*rule_obj,
+                                                                prop_help_uri))
+           url = url_val->get_string ();
+       }
+      err.add_rule (rule_id->get_string (), url);
+    }
   err.set_location (physical_loc);
   err.set_logical_location (logical_loc);
   if (path.m_inner)

Reply via email to