mirror of
https://github.com/github/codeql.git
synced 2026-05-25 00:27:09 +02:00
PS: Add helper predicates for if statements.
This commit is contained in:
@@ -53,5 +53,13 @@ class If extends Expr, TIf {
|
||||
)
|
||||
}
|
||||
|
||||
StmtBlock getABranch(boolean b) {
|
||||
b = true and result = this.getAThen()
|
||||
or
|
||||
b = false and result = this.getElse()
|
||||
}
|
||||
|
||||
StmtBlock getABranch() { result = this.getAThen() or result = this.getElse() }
|
||||
|
||||
predicate hasElse() { exists(this.getElse()) }
|
||||
}
|
||||
|
||||
@@ -900,6 +900,16 @@ module ExprNodes {
|
||||
StmtCfgNode getAThen() { result = this.getThen(_) }
|
||||
|
||||
StmtCfgNode getElse() { e.hasCfgChild(e.getElse(), this, result) }
|
||||
|
||||
StmtCfgNode getABranch(boolean b) {
|
||||
b = true and
|
||||
result = this.getAThen()
|
||||
or
|
||||
b = false and
|
||||
result = this.getElse()
|
||||
}
|
||||
|
||||
StmtCfgNode getABranch() { result = this.getABranch(_) }
|
||||
}
|
||||
|
||||
private class LiteralChildMapping extends ExprChildMapping, Literal {
|
||||
|
||||
Reference in New Issue
Block a user