@@ -2,7 +2,7 @@ import cpp
22import 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 */
88class 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+ */
6669private 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+ */
109116private 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+ */
136146private 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`. */
467477private Expr remove_conversions ( Expr e ) {
468478 if e instanceof Conversion
469479 then result = e .( Conversion ) .getExpr * ( ) and
0 commit comments