mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Java: Switch from ssaDefAssigns/ssaDefInitializesParam to ssaDefHasSource.
This commit is contained in:
@@ -26,6 +26,14 @@ private predicate deadcode(Expr e) {
|
||||
module SsaFlow {
|
||||
module Impl = SsaImpl::DataFlowIntegration;
|
||||
|
||||
private predicate ssaDefAssigns(SsaExplicitUpdate def, Expr value) {
|
||||
exists(VariableUpdate upd | upd = def.getDefiningExpr() |
|
||||
value = upd.(VariableAssign).getSource() or
|
||||
value = upd.(AssignOp) or
|
||||
value = upd.(RecordBindingVariableExpr)
|
||||
)
|
||||
}
|
||||
|
||||
Impl::Node asNode(Node n) {
|
||||
n = TSsaNode(result)
|
||||
or
|
||||
@@ -33,7 +41,12 @@ module SsaFlow {
|
||||
or
|
||||
result.(Impl::ExprPostUpdateNode).getExpr() = n.(PostUpdateNode).getPreUpdateNode().asExpr()
|
||||
or
|
||||
TExplicitParameterNode(result.(Impl::ParameterNode).getParameter()) = n
|
||||
exists(Parameter p |
|
||||
n = TExplicitParameterNode(p) and
|
||||
result.(Impl::WriteDefSourceNode).getDefinition().(SsaImplicitInit).isParameterDefinition(p)
|
||||
)
|
||||
or
|
||||
ssaDefAssigns(result.(Impl::WriteDefSourceNode).getDefinition(), n.asExpr())
|
||||
}
|
||||
|
||||
predicate localFlowStep(SsaSourceVariable v, Node nodeFrom, Node nodeTo, boolean isUseStep) {
|
||||
|
||||
@@ -649,21 +649,13 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
|
||||
|
||||
class Parameter = J::Parameter;
|
||||
|
||||
predicate ssaDefAssigns(Impl::WriteDefinition def, Expr value) {
|
||||
exists(VariableUpdate upd | upd = def.(SsaExplicitUpdate).getDefiningExpr() |
|
||||
value = upd.(VariableAssign).getSource() or
|
||||
value = upd.(AssignOp) or
|
||||
value = upd.(RecordBindingVariableExpr)
|
||||
)
|
||||
predicate ssaDefHasSource(WriteDefinition def) {
|
||||
def instanceof SsaExplicitUpdate or def.(SsaImplicitInit).isParameterDefinition(_)
|
||||
}
|
||||
|
||||
predicate ssaDefInitializesParam(Impl::WriteDefinition def, Parameter p) {
|
||||
def.(SsaImplicitInit).getSourceVariable() =
|
||||
any(SsaSourceVariable v |
|
||||
v.getVariable() = p and
|
||||
v.getEnclosingCallable() = p.getCallable()
|
||||
)
|
||||
}
|
||||
predicate ssaDefAssigns(Impl::WriteDefinition def, Expr value) { none() }
|
||||
|
||||
predicate ssaDefInitializesParam(Impl::WriteDefinition def, Parameter p) { none() }
|
||||
|
||||
predicate allowFlowIntoUncertainDef(UncertainWriteDefinition def) {
|
||||
def instanceof SsaUncertainImplicitUpdate
|
||||
|
||||
Reference in New Issue
Block a user