JS: Add some overlay[caller] and a pragma[nomagic] annotations

This commit is contained in:
Asger F
2025-10-15 10:46:42 +02:00
parent 889209719b
commit 66febb263d
3 changed files with 15 additions and 0 deletions

View File

@@ -356,6 +356,7 @@ module AccessPath {
* Gets a variable that is relevant for the computations in the `GetLaterAccess` module. * Gets a variable that is relevant for the computations in the `GetLaterAccess` module.
* This predicate restricts as much as it can, but without depending on `getAVariableRef`. * This predicate restricts as much as it can, but without depending on `getAVariableRef`.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
private SsaVariable getARelevantVariableSimple() { private SsaVariable getARelevantVariableSimple() {
// The variable might be used where `getLaterBaseAccess()` is called. // The variable might be used where `getLaterBaseAccess()` is called.
@@ -407,6 +408,7 @@ module AccessPath {
* } * }
* ``` * ```
*/ */
overlay[caller]
pragma[inline] pragma[inline]
DataFlow::Node getAReferenceTo(Root root, string path) { DataFlow::Node getAReferenceTo(Root root, string path) {
path = fromReference(result, root) and path = fromReference(result, root) and
@@ -430,6 +432,7 @@ module AccessPath {
* })(NS = NS || {}); * })(NS = NS || {});
* ``` * ```
*/ */
overlay[caller]
pragma[inline] pragma[inline]
DataFlow::Node getAReferenceTo(string path) { DataFlow::Node getAReferenceTo(string path) {
path = fromReference(result, DataFlow::globalAccessPathRootPseudoNode()) path = fromReference(result, DataFlow::globalAccessPathRootPseudoNode())
@@ -451,6 +454,7 @@ module AccessPath {
* } * }
* ``` * ```
*/ */
overlay[caller]
pragma[inline] pragma[inline]
DataFlow::Node getAnAssignmentTo(Root root, string path) { DataFlow::Node getAnAssignmentTo(Root root, string path) {
path = fromRhs(result, root) and path = fromRhs(result, root) and
@@ -472,6 +476,7 @@ module AccessPath {
* })(foo = foo || {}); * })(foo = foo || {});
* ``` * ```
*/ */
overlay[caller]
pragma[inline] pragma[inline]
DataFlow::Node getAnAssignmentTo(string path) { DataFlow::Node getAnAssignmentTo(string path) {
path = fromRhs(result, DataFlow::globalAccessPathRootPseudoNode()) path = fromRhs(result, DataFlow::globalAccessPathRootPseudoNode())
@@ -482,6 +487,7 @@ module AccessPath {
* *
* See `getAReferenceTo` and `getAnAssignmentTo` for more details. * See `getAReferenceTo` and `getAnAssignmentTo` for more details.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
DataFlow::Node getAReferenceOrAssignmentTo(string path) { DataFlow::Node getAReferenceOrAssignmentTo(string path) {
result = getAReferenceTo(path) result = getAReferenceTo(path)
@@ -494,6 +500,7 @@ module AccessPath {
* *
* See `getAReferenceTo` and `getAnAssignmentTo` for more details. * See `getAReferenceTo` and `getAnAssignmentTo` for more details.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
DataFlow::Node getAReferenceOrAssignmentTo(Root root, string path) { DataFlow::Node getAReferenceOrAssignmentTo(Root root, string path) {
result = getAReferenceTo(root, path) result = getAReferenceTo(root, path)
@@ -504,6 +511,7 @@ module AccessPath {
/** /**
* Holds if there is a step from `pred` to `succ` through an assignment to an access path. * Holds if there is a step from `pred` to `succ` through an assignment to an access path.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
predicate step(DataFlow::Node pred, DataFlow::Node succ) { predicate step(DataFlow::Node pred, DataFlow::Node succ) {
exists(string name, Root root | exists(string name, Root root |
@@ -521,6 +529,7 @@ module AccessPath {
/** /**
* Gets a `SourceNode` that refers to the same value or access path as the given node. * Gets a `SourceNode` that refers to the same value or access path as the given node.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
DataFlow::SourceNode getAnAliasedSourceNode(DataFlow::Node node) { DataFlow::SourceNode getAnAliasedSourceNode(DataFlow::Node node) {
exists(DataFlow::SourceNode root, string accessPath | exists(DataFlow::SourceNode root, string accessPath |

View File

@@ -1493,6 +1493,7 @@ private predicate stringifiedNode(Node node) {
} }
/** Gets the post-update node for which `node` is the corresponding pre-update node. */ /** Gets the post-update node for which `node` is the corresponding pre-update node. */
pragma[nomagic]
private Node getPostUpdateForStore(Node base) { private Node getPostUpdateForStore(Node base) {
exists(Expr expr | exists(Expr expr |
base = TValueNode(expr) and base = TValueNode(expr) and
@@ -1515,6 +1516,7 @@ private Node getPostUpdateForStore(Node base) {
} }
/** Gets node to target with a store to the given `base` object.. */ /** Gets node to target with a store to the given `base` object.. */
overlay[caller]
pragma[inline] pragma[inline]
private Node getStoreTarget(DataFlow::Node base) { private Node getStoreTarget(DataFlow::Node base) {
result = getPostUpdateForStore(base) result = getPostUpdateForStore(base)

View File

@@ -320,6 +320,7 @@ module Public {
/** /**
* Holds if this basic block strictly dominates `bb`. * Holds if this basic block strictly dominates `bb`.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
predicate strictlyDominates(ReachableBasicBlock bb) { this = immediateDominator+(bb) } predicate strictlyDominates(ReachableBasicBlock bb) { this = immediateDominator+(bb) }
@@ -328,12 +329,14 @@ module Public {
* *
* This predicate is reflexive: each reachable basic block dominates itself. * This predicate is reflexive: each reachable basic block dominates itself.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
predicate dominates(ReachableBasicBlock bb) { this = immediateDominator*(bb) } predicate dominates(ReachableBasicBlock bb) { this = immediateDominator*(bb) }
/** /**
* Holds if this basic block strictly post-dominates `bb`. * Holds if this basic block strictly post-dominates `bb`.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
predicate strictlyPostDominates(ReachableBasicBlock bb) { this = immediatePostDominator+(bb) } predicate strictlyPostDominates(ReachableBasicBlock bb) { this = immediatePostDominator+(bb) }
@@ -342,6 +345,7 @@ module Public {
* *
* This predicate is reflexive: each reachable basic block post-dominates itself. * This predicate is reflexive: each reachable basic block post-dominates itself.
*/ */
overlay[caller]
pragma[inline] pragma[inline]
predicate postDominates(ReachableBasicBlock bb) { this = immediatePostDominator*(bb) } predicate postDominates(ReachableBasicBlock bb) { this = immediatePostDominator*(bb) }
} }