JS: replace .stripParens query uses w. .getUnderlyingReference

This commit is contained in:
Esben Sparre Andreasen
2018-10-15 09:56:38 +02:00
parent f04293f73c
commit e6a190c06e
4 changed files with 5 additions and 5 deletions

View File

@@ -65,7 +65,7 @@ predicate maybeNegativeVar(Variable v) {
// is v ever assigned a potentially negative value?
maybeNegative(v.getAnAssignedExpr()) or
// is v ever decremented?
exists (DecExpr dec | dec.getOperand().stripParens() = v.getAnAccess()) or
exists (DecExpr dec | dec.getOperand().getUnderlyingReference() = v.getAnAccess()) or
// is v ever subject to a compound assignment other than +=, or to
// += with potentially negative rhs?
exists (CompoundAssignExpr assgn | assgn.getTarget() = v.getAnAccess() |

View File

@@ -26,7 +26,7 @@ class IncrementExpr extends Expr {
// x = x + e
exists (AssignExpr assgn, Variable v | assgn = this |
assgn.getTarget() = v.getAnAccess() and
assgn.getRhs().(AddExpr).getAnOperand().stripParens() = v.getAnAccess()
assgn.getRhs().(AddExpr).getAnOperand().getUnderlyingReference() = v.getAnAccess()
)
}
}

View File

@@ -28,7 +28,7 @@ import semmle.javascript.dataflow.Refinements
*/
predicate isDefensiveInit(VarAccess va) {
exists (LogOrExpr o, VarRef va2 |
va = o.getLeftOperand().stripParens() and va2.getVariable() = va.getVariable() |
va = o.getLeftOperand().getUnderlyingReference() and va2.getVariable() = va.getVariable() |
exists (AssignExpr assgn | va2 = assgn.getTarget() |
assgn = o.getRightOperand().stripParens() or
o = assgn.getRhs().getUnderlyingValue()

View File

@@ -19,7 +19,7 @@ private import Declarations.Declarations
* `x` has kind `"V"`.
*/
string refKind(RefExpr r) {
if exists(InvokeExpr invk | r = invk.getCallee().stripParens()) then
if exists(InvokeExpr invk | r = invk.getCallee().getUnderlyingReference()) then
result = "M"
else
result = "V"
@@ -143,7 +143,7 @@ predicate typedInvokeLookup(ASTNode ref, ASTNode decl, string kind) {
not variableDefLookup(ref, decl, _) and
not propertyLookup(ref, decl, _) and
exists (InvokeExpr invoke, Expr callee |
callee = invoke.getCallee().stripParens() and
callee = invoke.getCallee().getUnderlyingReference() and
(ref = callee.(Identifier) or ref = callee.(DotExpr).getPropertyNameExpr()) and
decl = invoke.getResolvedCallee() and
kind = "M")