mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
C++: Simplify defDependsOnDef for AssignOperation
These cases were unnecessarily transitive. There is no need for `defDependsOnDef` to be transitive since that's handled in `defDependsOnDefTransitively`. The dependency information from the LHS of an `AssignmentOperation` is now deduced the say way as the information from the RHS: by calling `exprDependsOnDef`. This should effectively give us the same information and recursion structure as if the operation (`x += e`) were desugared (`x = x + e`).
This commit is contained in:
@@ -239,33 +239,27 @@ private predicate defDependsOnDef(
|
||||
// Definitions with a defining value.
|
||||
exists(Expr expr | assignmentDef(def, v, expr) | exprDependsOnDef(expr, srcDef, srcVar))
|
||||
or
|
||||
exists(AssignAddExpr assignAdd, RangeSsaDefinition nextDef |
|
||||
exists(AssignAddExpr assignAdd |
|
||||
def = assignAdd and
|
||||
assignAdd.getLValue() = nextDef.getAUse(v)
|
||||
|
|
||||
defDependsOnDef(nextDef, v, srcDef, srcVar) or
|
||||
exprDependsOnDef(assignAdd.getRValue(), srcDef, srcVar)
|
||||
def.getAVariable() = v and
|
||||
exprDependsOnDef(assignAdd.getAnOperand(), srcDef, srcVar)
|
||||
)
|
||||
or
|
||||
exists(AssignSubExpr assignSub, RangeSsaDefinition nextDef |
|
||||
exists(AssignSubExpr assignSub |
|
||||
def = assignSub and
|
||||
assignSub.getLValue() = nextDef.getAUse(v)
|
||||
|
|
||||
defDependsOnDef(nextDef, v, srcDef, srcVar) or
|
||||
exprDependsOnDef(assignSub.getRValue(), srcDef, srcVar)
|
||||
def.getAVariable() = v and
|
||||
exprDependsOnDef(assignSub.getAnOperand(), srcDef, srcVar)
|
||||
)
|
||||
or
|
||||
exists(UnsignedAssignMulExpr assignMul, RangeSsaDefinition nextDef |
|
||||
exists(UnsignedAssignMulExpr assignMul |
|
||||
def = assignMul and
|
||||
assignMul.getLValue() = nextDef.getAUse(v)
|
||||
|
|
||||
defDependsOnDef(nextDef, v, srcDef, srcVar) or
|
||||
exprDependsOnDef(assignMul.getRValue(), srcDef, srcVar)
|
||||
def.getAVariable() = v and
|
||||
exprDependsOnDef(assignMul.getAnOperand(), srcDef, srcVar)
|
||||
)
|
||||
or
|
||||
exists(CrementOperation crem |
|
||||
def = crem and
|
||||
crem.getOperand() = v.getAnAccess() and
|
||||
def.getAVariable() = v and
|
||||
exprDependsOnDef(crem.getOperand(), srcDef, srcVar)
|
||||
)
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user