@@ -90,13 +90,57 @@ class CallExprTree extends StandardPostOrderTree instanceof CallExpr {
9090}
9191
9292class BinaryOpExprTree extends StandardPostOrderTree instanceof BinaryOpExpr {
93+ BinaryOpExprTree ( ) { super .getOp ( ) != "&&" and super .getOp ( ) != "||" }
94+
9395 override ControlFlowTree getChildNode ( int i ) {
9496 i = 0 and result = super .getLhs ( )
9597 or
9698 i = 1 and result = super .getRhs ( )
9799 }
98100}
99101
102+ class LogicalOrBinaryOpExprTree extends PostOrderTree instanceof BinaryOpExpr {
103+ LogicalOrBinaryOpExprTree ( ) { super .getOp ( ) = "||" }
104+
105+ final override predicate propagatesAbnormal ( AstNode child ) {
106+ child = [ super .getRhs ( ) , super .getLhs ( ) ]
107+ }
108+
109+ override predicate first ( AstNode node ) { first ( super .getLhs ( ) , node ) }
110+
111+ override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
112+ last ( super .getLhs ( ) , pred , c ) and
113+ (
114+ succ = this and c .( BooleanCompletion ) .getValue ( ) = true
115+ or
116+ first ( super .getRhs ( ) , succ ) and c .( BooleanCompletion ) .getValue ( ) = false
117+ )
118+ or
119+ last ( super .getRhs ( ) , pred , c ) and succ = this
120+ }
121+ }
122+
123+ class LogicalAndBinaryOpExprTree extends PostOrderTree instanceof BinaryOpExpr {
124+ LogicalAndBinaryOpExprTree ( ) { super .getOp ( ) = "&&" }
125+
126+ final override predicate propagatesAbnormal ( AstNode child ) {
127+ child = [ super .getRhs ( ) , super .getLhs ( ) ]
128+ }
129+
130+ override predicate first ( AstNode node ) { first ( super .getLhs ( ) , node ) }
131+
132+ override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
133+ last ( super .getLhs ( ) , pred , c ) and
134+ (
135+ succ = this and c .( BooleanCompletion ) .getValue ( ) = false
136+ or
137+ first ( super .getRhs ( ) , succ ) and c .( BooleanCompletion ) .getValue ( ) = true
138+ )
139+ or
140+ last ( super .getRhs ( ) , pred , c ) and succ = this
141+ }
142+ }
143+
100144class IfExprTree extends PostOrderTree instanceof IfExpr {
101145 override predicate first ( AstNode node ) { first ( super .getCondition ( ) , node ) }
102146
0 commit comments