mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
Add StmtExpr flow
This commit is contained in:
committed by
Ian Lynagh
parent
b626e80a61
commit
c4c254587e
@@ -990,9 +990,7 @@ class ValueNEExpr extends BinaryExpr, @valueneexpr {
|
||||
* need to distinguish them, use `EQExpr` or `ValueEQExpr` instead.
|
||||
*/
|
||||
class AnyEqualsExpr extends BinaryExpr {
|
||||
AnyEqualsExpr() {
|
||||
this instanceof EQExpr or this instanceof ValueEQExpr
|
||||
}
|
||||
AnyEqualsExpr() { this instanceof EQExpr or this instanceof ValueEQExpr }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1002,9 +1000,7 @@ class AnyEqualsExpr extends BinaryExpr {
|
||||
* need to distinguish them, use `EQExpr` or `ValueEQExpr` instead.
|
||||
*/
|
||||
class AnyNotEqualsExpr extends BinaryExpr {
|
||||
AnyNotEqualsExpr() {
|
||||
this instanceof NEExpr or this instanceof ValueNEExpr
|
||||
}
|
||||
AnyNotEqualsExpr() { this instanceof NEExpr or this instanceof ValueNEExpr }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2353,6 +2349,16 @@ class StmtExpr extends Expr, @stmtexpr {
|
||||
override string getHalsteadID() { result = "StmtExpr" }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "StmtExpr" }
|
||||
|
||||
/**
|
||||
* Gets the result expression of the enclosed statement.
|
||||
*/
|
||||
Expr getResultExpr() { result = getStmtResultExpr(this.getStmt()) }
|
||||
}
|
||||
|
||||
private Expr getStmtResultExpr(Stmt stmt) {
|
||||
result = stmt.(ExprStmt).getExpr() or
|
||||
result = getStmtResultExpr(stmt.(BlockStmt).getLastStmt())
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -152,6 +152,8 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
|
||||
or
|
||||
node2.asExpr().(ArrayCreationExpr).getInit() = node1.asExpr()
|
||||
or
|
||||
node2.asExpr() = any(StmtExpr stmtExpr | node1.asExpr() = stmtExpr.getResultExpr())
|
||||
or
|
||||
exists(MethodAccess ma, ValuePreservingMethod m, int argNo |
|
||||
ma.getCallee().getSourceDeclaration() = m and m.returnsValue(argNo)
|
||||
|
|
||||
|
||||
Reference in New Issue
Block a user