File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
ql/ql/src/queries/overlay Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @name Cannot inline predicate across overlay frontier
3+ * @description Local inline predicates that are not annotated with `overlay[caller]` are
4+ * not inlined across the overlay frontier. This may negatively affect performance.
5+ * @kind problem
6+ * @problem.severity warning
7+ * @id ql/inline-overlay-caller
8+ * @tags performance
9+ * @precision high
10+ */
11+
12+ import ql
13+
14+ predicate mayBeLocal ( AstNode n ) {
15+ n .getAnAnnotation ( ) instanceof OverlayLocal
16+ or
17+ n .getAnAnnotation ( ) instanceof OverlayLocalQ
18+ or
19+ // The tree-sitter-ql grammar doesn't handle annotations on file-level
20+ // module declarations correctly. To work around that, we consider any
21+ // node in a file that contains an overlay[local] or overlay[local?]
22+ // annotation to be potentially local.
23+ exists ( AstNode m |
24+ n .getLocation ( ) .getFile ( ) = m .getLocation ( ) .getFile ( ) and
25+ mayBeLocal ( m )
26+ )
27+ }
28+
29+ from Predicate p
30+ where
31+ mayBeLocal ( p ) and
32+ p .getAnAnnotation ( ) instanceof Inline and
33+ not p .getAnAnnotation ( ) instanceof OverlayCaller and
34+ not p .isPrivate ( )
35+ select p ,
36+ "This possibly local non-private inline predicate will not " +
37+ "be inlined across the overlay frontier. This may negatively " +
38+ "affect evaluation performance. Consider adding an " +
39+ "`overlay[caller]` annotation to allow inlining across the " +
40+ "overlay frontier. Note that adding an `overlay[caller]` " +
41+ "annotation affects semantics under overlay evaluation."
You can’t perform that action at this time.
0 commit comments