JS: Remove synthetic locations

This commit is contained in:
Asger F
2025-08-27 11:20:24 +02:00
parent f1ca0ecc3c
commit dcf63fc434
13 changed files with 63 additions and 264 deletions

View File

@@ -4,7 +4,7 @@ private import semmle.javascript.dataflow.internal.VariableOrThis
private import codeql.dataflow.VariableCapture
private import semmle.javascript.dataflow.internal.sharedlib.DataFlowImplCommon as DataFlowImplCommon
module VariableCaptureConfig implements InputSig<js::DbLocation> {
module VariableCaptureConfig implements InputSig<js::Location> {
private js::Function getLambdaFromVariable(js::LocalVariable variable) {
result.getVariable() = variable
or
@@ -168,7 +168,7 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
string toString() { none() } // Overridden in subclass
js::DbLocation getLocation() { none() } // Overridden in subclass
js::Location getLocation() { none() } // Overridden in subclass
predicate hasCfgNode(BasicBlock bb, int i) { none() } // Overridden in subclass
@@ -186,7 +186,7 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
override string toString() { result = pattern.toString() }
/** Gets the location of this write. */
override js::DbLocation getLocation() { result = pattern.getLocation() }
override js::Location getLocation() { result = pattern.getLocation() }
override js::DataFlow::Node getSource() {
// Note: there is not always an expression corresponding to the RHS of the assignment.
@@ -222,7 +222,7 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
override string toString() { result = "[implicit init] " + variable }
override js::DbLocation getLocation() { result = variable.getLocation() }
override js::Location getLocation() { result = variable.getLocation() }
override CapturedVariable getVariable() { result = variable }
@@ -242,7 +242,7 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
predicate entryBlock(BasicBlock bb) { bb instanceof js::EntryBasicBlock }
}
module VariableCaptureOutput = Flow<js::DbLocation, VariableCaptureConfig>;
module VariableCaptureOutput = Flow<js::Location, VariableCaptureConfig>;
js::DataFlow::Node getNodeFromClosureNode(VariableCaptureOutput::ClosureNode node) {
result = TValueNode(node.(VariableCaptureOutput::ExprNode).getExpr())

View File

@@ -25,7 +25,7 @@ class LocalVariableOrThis extends TLocalVariableOrThis {
}
/** Gets the location of a declaration of this variable, or the declaring container if this is `this`. */
DbLocation getLocation() {
Location getLocation() {
result = this.asLocalVariable().getLocation()
or
result = this.asThisContainer().getLocation()
@@ -95,7 +95,7 @@ abstract class ThisUse instanceof ControlFlowNode {
string toString() { result = super.toString() }
/** Gets the location of this use of `this`. */
DbLocation getLocation() { result = super.getLocation() }
Location getLocation() { result = super.getLocation() }
}
private predicate implicitThisUse(ControlFlowNode node, StmtContainer thisBinder) {

View File

@@ -9,7 +9,7 @@ private import codeql.ssa.Ssa
private import semmle.javascript.internal.BasicBlockInternal as BasicBlockInternal
private import semmle.javascript.dataflow.internal.VariableOrThis
module SsaConfig implements InputSig<js::DbLocation> {
module SsaConfig implements InputSig<js::Location> {
class ControlFlowNode = js::ControlFlowNode;
class BasicBlock = js::BasicBlock;
@@ -47,7 +47,7 @@ module SsaConfig implements InputSig<js::DbLocation> {
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getASuccessor() }
}
import Make<js::DbLocation, SsaConfig>
import Make<js::Location, SsaConfig>
module SsaDataflowInput implements DataFlowIntegrationInputSig {
private import codeql.util.Boolean