Skip to content

Commit

Permalink
Add HACK to fix issue with COVERITY pragma collection, and test
Browse files Browse the repository at this point in the history
  • Loading branch information
lwaern-intel committed Dec 18, 2024
1 parent 476a6cc commit 0e67216
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
22 changes: 18 additions & 4 deletions py/dml/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,27 @@ def coverity_markers(markers, site=None):
if dml.globals.coverity and site_with_loc:
custom_markers = []
filename = site.filename()
lineno = site.lineno
tgt_lineno = site.lineno

while (filename, lineno) in dml.globals.coverity_pragmas:
(lineno,
inline_markers) = dml.globals.coverity_pragmas[(filename, lineno)]
while (filename, tgt_lineno) in dml.globals.coverity_pragmas:
(start_lineno,
inline_markers) = dml.globals.coverity_pragmas[(filename,
tgt_lineno)]
custom_markers.extend(reversed(inline_markers))

# A minor HACK to handle the case of:
# /*% COVERITY foo %*/ /*% COVERITY
# bar %*/
# some_statement
#
# Otherwise 'foo' won't be captured
if (start_lineno + 1 < tgt_lineno
and ((filename, start_lineno + 1)
in dml.globals.coverity_pragmas)):
tgt_lineno = start_lineno + 1
else:
tgt_lineno = start_lineno

custom_markers.reverse()
markers = custom_markers + markers

Expand Down
13 changes: 10 additions & 3 deletions test/1.4/pragmas/COVERITY.dml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ method init() {

/*% COVERITY irrelevant %*/

/*% COVERITY foo %*/
/*% COVERITY bar %*/ /*% COVERITY baz
/*% COVERITY foo
%*/ /*% COVERITY bar %*/
/*% COVERITY baz %*/ /*% COVERITY qux
FALSE
%*/
assert true;
// SUPPRESSIONS-ABOVE [foo] [bar] [baz:FALSE]
// SUPPRESSIONS-ABOVE [foo] [bar] [baz] [qux:FALSE]


/*% COVERITY foo %*/
/*% COVERITY bar %*/ /*% COVERITY irrelevant
%*/ assert true;
// SUPPRESSIONS-ABOVE [foo] [bar]

try {
if (s.x == 0) {
Expand Down

0 comments on commit 0e67216

Please sign in to comment.