Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b5cd48d

Browse files
author
Robert Marsh
committed
C++: comments on new classes and predicates
1 parent 0273b20 commit b5cd48d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

cpp/ql/src/semmle/code/cpp/controlflow/IRGuards.qll

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import cpp
22
import semmle.code.cpp.ir.IR
33

44
/**
5-
* A Boolean condition in the IR that guards one or more basic blocks. This includes
5+
* A Boolean condition in the AST that guards one or more basic blocks. This includes
66
* operands of logical operators but not switch statements.
77
*/
88
class GuardCondition extends Expr {
@@ -63,6 +63,9 @@ class GuardCondition extends Expr {
6363
abstract cached predicate ensuresEq(Expr left, Expr right, int k, BasicBlock block, boolean areEqual);
6464
}
6565

66+
/**
67+
* A binary logical operator in the AST that guards one or more basic blocks.
68+
*/
6669
private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
6770
GuardConditionFromBinaryLogicalOperator() {
6871
exists(GuardCondition gc |
@@ -106,6 +109,10 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
106109
}
107110
}
108111

112+
/**
113+
* A `!` operator in the AST that guards one or more basic blocks, and does not have a corresponding
114+
* IR instruction.
115+
*/
109116
private class GuardConditionFromShortCircuitNot extends GuardCondition, NotExpr {
110117
GuardConditionFromShortCircuitNot() {
111118
not exists (Instruction inst | this.getFullyConverted() = inst.getAST()) and
@@ -132,7 +139,10 @@ private class GuardConditionFromShortCircuitNot extends GuardCondition, NotExpr
132139
getOperand().(GuardCondition).ensuresEq(left, right, k, block, testIsTrue.booleanNot())
133140
}
134141
}
135-
142+
/**
143+
* A Boolean condition in the AST that guards one or more basic blocks and has a corresponding IR
144+
* instruction.
145+
*/
136146
private class GuardConditionFromIR extends GuardCondition {
137147
IRGuardCondition ir;
138148

@@ -463,7 +473,7 @@ private int int_value(Instruction i) {
463473
result = i.(IntegerConstantInstruction).getValue().toInt()
464474
}
465475

466-
476+
/** Gets the underlying expression of `e`. */
467477
private Expr remove_conversions(Expr e) {
468478
if e instanceof Conversion
469479
then result = e.(Conversion).getExpr*() and

0 commit comments

Comments
 (0)