Skip to content

Commit 92c933e

Browse files
committed
Refactor a Supression predicate into a class
1 parent 7848c04 commit 92c933e

1 file changed

Lines changed: 21 additions & 22 deletions

File tree

src/drivers/libraries/Suppression.qll

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,6 @@
22
// Licensed under the MIT license.
33
import cpp
44

5-
/**
6-
* --- AI-generated ---
7-
*
8-
* Gets the minimum start line of a non-suppression Locatable in `f` that is
9-
* strictly after `afterLine`. Pre-computing distinct lines avoids iterating
10-
* over every Locatable individually in the aggregate.
11-
*/
12-
pragma[nomagic]
13-
private int nextNonSuppressionLine(File f, int afterLine) {
14-
afterLine = any(SuppressPragma sp | sp.getFile() = f).getLocation().getEndLine() and
15-
result =
16-
min(int line |
17-
exists(Locatable l |
18-
l.getFile() = f and
19-
not l instanceof CASuppression and
20-
line = l.getLocation().getStartLine() and
21-
line > afterLine
22-
)
23-
)
24-
}
25-
265
/**
276
* --- AI-generated ---
287
*
@@ -256,10 +235,30 @@ class SuppressPragma extends CASuppression {
256235
pragma[nomagic]
257236
int getMinimumLocationOffset() {
258237
exists(int nextLine |
259-
nextLine = nextNonSuppressionLine(this.getFile(), this.getLocation().getEndLine()) and
238+
nextLine = nextNonSuppressionLine() and
260239
result = nextLine - this.getLocation().getEndLine()
261240
)
262241
}
242+
243+
/**
244+
* --- AI-generated ---
245+
*
246+
* Gets the minimum start line of a non-suppression Locatable in `f` that is
247+
* strictly after `afterLine`. Pre-computing distinct lines avoids iterating
248+
* over every Locatable individually in the aggregate.
249+
*/
250+
pragma[nomagic]
251+
private int nextNonSuppressionLine() {
252+
result =
253+
min(int line |
254+
exists(Locatable l |
255+
l.getFile() = this.getFile() and
256+
not l instanceof CASuppression and
257+
line = l.getLocation().getStartLine() and
258+
line > this.getLocation().getEndLine()
259+
)
260+
)
261+
}
263262
}
264263

265264
/**

0 commit comments

Comments
 (0)