diag.add_location (annotation.m_phys_loc);
}
+static bool
+should_add_rule_p (const char *rule_id_str, const char *url)
+{
+ if (url)
+ return true;
+
+ /* GCC's sarif output uses "error" for "ruleId", which is already
+ captured in the "level", so don't add a rule for that. */
+ if (!strcmp (rule_id_str, "error"))
+ return false;
+
+ return true;
+}
+
/* Process a result object (SARIF v2.1.0 section 3.27).
Known limitations:
- doesn't yet handle "ruleIndex" property (§3.27.6)
prop_help_uri))
url = url_val->get_string ();
}
- err.add_rule (rule_id->get_string (), url);
+
+ const char *rule_id_str = rule_id->get_string ();
+ if (should_add_rule_p (rule_id_str, url))
+ err.add_rule (rule_id_str, url);
}
err.set_location (physical_loc);
err.set_logical_location (logical_loc);
/* Verify that we underline and label the ranges for the
"annotations" above. */
/* { dg-begin-multiline-output "" }
-bad-binary-ops-highlight-colors.c:19:23: error: invalid operands to binary + (have ‘S’ {aka ‘struct s’} and ‘T’ {aka ‘struct t’}) [error]
+bad-binary-ops-highlight-colors.c:19:23: error: invalid operands to binary + (have ‘S’ {aka ‘struct s’} and ‘T’ {aka ‘struct t’})
19 | return callee_4a () + callee_4b ();
| ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
| | |
| | T {aka struct t}
| S {aka struct s}
{ dg-end-multiline-output "" } */
-// TODO: trailing [error]
/* Verify that we underline the "42" here. */
/* { dg-begin-multiline-output "" }
In function 'test_known_fn':
-too-many-arguments.c:5:3: error: too many arguments to function 'fn_a'; expected 0, have 1 [error]
+too-many-arguments.c:5:3: error: too many arguments to function 'fn_a'; expected 0, have 1
5 | fn_a (42);
| ^~~~ ~~
too-many-arguments.c:1:13: note: declared here
1 | extern void fn_a ();
| ^~~~
{ dg-end-multiline-output "" } */
-// TODO: trailing [error]