@@ -90,13 +90,57 @@ class CallExprTree extends StandardPostOrderTree instanceof CallExpr {
90
90
}
91
91
92
92
class BinaryOpExprTree extends StandardPostOrderTree instanceof BinaryOpExpr {
93
+ BinaryOpExprTree ( ) { super .getOp ( ) != "&&" and super .getOp ( ) != "||" }
94
+
93
95
override ControlFlowTree getChildNode ( int i ) {
94
96
i = 0 and result = super .getLhs ( )
95
97
or
96
98
i = 1 and result = super .getRhs ( )
97
99
}
98
100
}
99
101
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
+
100
144
class IfExprTree extends PostOrderTree instanceof IfExpr {
101
145
override predicate first ( AstNode node ) { first ( super .getCondition ( ) , node ) }
102
146
0 commit comments