mirror of
https://github.com/github/codeql.git
synced 2026-04-25 00:35:20 +02:00
Merge ConditionBlock and BarrierGuard
This commit is contained in:
@@ -159,22 +159,6 @@ class Content extends TContent {
|
||||
Location getLocation() { none() }
|
||||
}
|
||||
|
||||
/**
|
||||
* A node that controls whether other nodes are evaluated.
|
||||
*/
|
||||
class GuardNode extends CfgNodes::ExprCfgNode {
|
||||
ConditionBlock conditionBlock;
|
||||
|
||||
GuardNode() { this = conditionBlock.getLastNode() }
|
||||
|
||||
/** Holds if this guard controls block `b` upon evaluating to `branch`. */
|
||||
predicate controlsBlock(BasicBlock bb, boolean branch) {
|
||||
exists(SuccessorTypes::BooleanSuccessor s | s.getValue() = branch |
|
||||
conditionBlock.controls(bb, s)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A guard that validates some expression.
|
||||
*
|
||||
@@ -184,7 +168,18 @@ class GuardNode extends CfgNodes::ExprCfgNode {
|
||||
*
|
||||
* It is important that all extending classes in scope are disjoint.
|
||||
*/
|
||||
abstract class BarrierGuard extends GuardNode {
|
||||
abstract class BarrierGuard extends CfgNodes::ExprCfgNode {
|
||||
private ConditionBlock conditionBlock;
|
||||
|
||||
BarrierGuard() { this = conditionBlock.getLastNode() }
|
||||
|
||||
/** Holds if this guard controls block `b` upon evaluating to `branch`. */
|
||||
private predicate controlsBlock(BasicBlock bb, boolean branch) {
|
||||
exists(SuccessorTypes::BooleanSuccessor s | s.getValue() = branch |
|
||||
conditionBlock.controls(bb, s)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this guard validates `expr` upon evaluating to `branch`.
|
||||
* For example, the following code validates `foo` when the condition
|
||||
|
||||
@@ -26,6 +26,8 @@ end
|
||||
|
||||
unless foo != "foo"
|
||||
foo
|
||||
else
|
||||
foo
|
||||
end
|
||||
|
||||
foo
|
||||
|
||||
Reference in New Issue
Block a user