Skip to content

Commit c380c5f

Browse files
authored
Merge pull request #19863 from github/kaspersv/ql4ql-overlay-caller-q
QL4QL: Extend ql/inline-overlay-caller
2 parents d7f1460 + e1fc138 commit c380c5f

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

ql/ql/src/codeql_ql/ast/Ast.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,10 @@ private class CallerArg extends AnnotationArg {
25422542
CallerArg() { this.getValue() = "caller" }
25432543
}
25442544

2545+
private class CallerQArg extends AnnotationArg {
2546+
CallerQArg() { this.getValue() = "caller?" }
2547+
}
2548+
25452549
private class LocalArg extends AnnotationArg {
25462550
LocalArg() { this.getValue() = "local" }
25472551
}
@@ -2616,6 +2620,13 @@ class OverlayCaller extends Annotation {
26162620
override string toString() { result = "overlay[caller]" }
26172621
}
26182622

2623+
/** An `overlay[caller?]` annotation. */
2624+
class OverlayCallerQ extends Annotation {
2625+
OverlayCallerQ() { this.getName() = "overlay" and this.getArgs(0) instanceof CallerQArg }
2626+
2627+
override string toString() { result = "overlay[caller?]" }
2628+
}
2629+
26192630
/** An `overlay[local]` annotation. */
26202631
class OverlayLocal extends Annotation {
26212632
OverlayLocal() { this.getName() = "overlay" and this.getArgs(0) instanceof LocalArg }

ql/ql/src/queries/overlay/InlineOverlayCaller.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ where
3131
mayBeLocal(p) and
3232
p.getAnAnnotation() instanceof Inline and
3333
not p.getAnAnnotation() instanceof OverlayCaller and
34+
not p.getAnAnnotation() instanceof OverlayCallerQ and
3435
not p.isPrivate()
3536
select p,
3637
"This possibly local non-private inline predicate will not " +
3738
"be inlined across the overlay frontier. This may negatively " +
3839
"affect evaluation performance. Consider adding an " +
39-
"`overlay[caller]` annotation to allow inlining across the " +
40-
"overlay frontier. Note that adding an `overlay[caller]` " +
40+
"`overlay[caller]` or `overlay[caller?]` annotation to allow inlining across the " +
41+
"overlay frontier. Note that adding an `overlay[caller]` or `overlay[caller?]` " +
4142
"annotation affects semantics under overlay evaluation."
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| Test.qll:7:11:7:13 | ClasslessPredicate foo | This possibly local non-private inline predicate will not be inlined across the overlay frontier. This may negatively affect evaluation performance. Consider adding an `overlay[caller]` annotation to allow inlining across the overlay frontier. Note that adding an `overlay[caller]` annotation affects semantics under overlay evaluation. |
1+
| Test.qll:7:11:7:13 | ClasslessPredicate foo | This possibly local non-private inline predicate will not be inlined across the overlay frontier. This may negatively affect evaluation performance. Consider adding an `overlay[caller]` or `overlay[caller?]` annotation to allow inlining across the overlay frontier. Note that adding an `overlay[caller]` or `overlay[caller?]` annotation affects semantics under overlay evaluation. |

ql/ql/test/queries/overlay/InlineOverlayCaller/Test.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ predicate bar(int x) { x = 43 }
1212

1313
pragma[inline]
1414
private predicate baz(int x) { x = 44 }
15+
16+
overlay[caller?]
17+
pragma[inline]
18+
predicate baw(int x) { x = 45 }

0 commit comments

Comments
 (0)