JS: Use getUnderlyingValue() a few places in VariableCapture

This commit is contained in:
Asger F
2024-11-19 13:21:32 +01:00
parent d2daec4c66
commit 80a5a5909e
2 changed files with 10 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
private js::Function getLambdaFromVariable(js::LocalVariable variable) {
result.getVariable() = variable
or
result = variable.getAnAssignedExpr()
result = variable.getAnAssignedExpr().getUnderlyingValue()
or
exists(js::ClassDeclStmt cls |
result = cls.getConstructor().getBody() and
@@ -148,9 +148,11 @@ module VariableCaptureConfig implements InputSig<js::DbLocation> {
predicate hasAliasedAccess(Expr e) {
e = this
or
e.(js::Expr).getUnderlyingValue() = this
or
exists(js::LocalVariable variable |
this = getLambdaFromVariable(variable) and
e = variable.getAnAccess()
e.(js::Expr).getUnderlyingValue() = variable.getAnAccess()
)
}
}

View File

@@ -16,8 +16,8 @@ function f2() {
})(x);
return y;
}
sink(inner(source("f2.1"))); // $ MISSING: hasValueFlow=f2.1
sink(inner(source("f2.2"))); // $ MISSING: hasValueFlow=f2.2
sink(inner(source("f2.1"))); // $ hasValueFlow=f2.1
sink(inner(source("f2.2"))); // $ hasValueFlow=f2.2
}
function f3() {
@@ -64,8 +64,8 @@ function f6() {
(nested)(x); // same as f5, except the callee is parenthesised here
return y;
}
sink(inner(source("f6.1"))); // $ MISSING: hasValueFlow=f6.1
sink(inner(source("f6.2"))); // $ MISSING: hasValueFlow=f6.2
sink(inner(source("f6.1"))); // $ hasValueFlow=f6.1
sink(inner(source("f6.2"))); // $ hasValueFlow=f6.2
}
function f7() {
@@ -77,6 +77,6 @@ function f7() {
nested(x); // same as f5, except the function definition is parenthesised
return y;
}
sink(inner(source("f7.1"))); // $ MISSING: hasValueFlow=f7.1
sink(inner(source("f7.2"))); // $ MISSING: hasValueFlow=f7.2
sink(inner(source("f7.1"))); // $ hasValueFlow=f7.1
sink(inner(source("f7.2"))); // $ hasValueFlow=f7.2
}