@@ -7,14 +7,17 @@ module AstTest {
7
7
* S in `if (guarded(x)) S`.
8
8
*/
9
9
// This is tested in `BarrierGuard.cpp`.
10
- predicate testBarrierGuard ( GuardCondition g , Expr checked , boolean isTrue ) {
11
- g .( FunctionCall ) .getTarget ( ) .getName ( ) = "guarded" and
12
- checked = g .( FunctionCall ) .getArgument ( 0 ) and
13
- isTrue = true
14
- or
15
- g .( FunctionCall ) .getTarget ( ) .getName ( ) = "unsafe" and
16
- checked = g .( FunctionCall ) .getArgument ( 0 ) and
17
- isTrue = false
10
+ predicate testBarrierGuard ( GuardCondition g , Expr checked , boolean branch ) {
11
+ exists ( Call call , boolean b |
12
+ checked = call .getArgument ( 0 ) and
13
+ g .comparesEq ( call , 0 , b , any ( BooleanValue bv | bv .getValue ( ) = branch ) )
14
+ |
15
+ call .getTarget ( ) .hasName ( "guarded" ) and
16
+ b = false
17
+ or
18
+ call .getTarget ( ) .hasName ( "unsafe" ) and
19
+ b = true
20
+ )
18
21
}
19
22
20
23
/** Common data flow configuration to be used by tests. */
@@ -106,16 +109,16 @@ module IRTest {
106
109
* S in `if (guarded(x)) S`.
107
110
*/
108
111
// This is tested in `BarrierGuard.cpp`.
109
- predicate testBarrierGuard ( IRGuardCondition g , Expr checked , boolean isTrue ) {
110
- exists ( Call call |
111
- call = g .getUnconvertedResultExpression ( ) and
112
- checked = call .getArgument ( 0 )
112
+ predicate testBarrierGuard ( IRGuardCondition g , Expr checked , boolean branch ) {
113
+ exists ( CallInstruction call , boolean b |
114
+ checked = call . getArgument ( 0 ) .getUnconvertedResultExpression ( ) and
115
+ g . comparesEq ( call .getAUse ( ) , 0 , b , any ( BooleanValue bv | bv . getValue ( ) = branch ) )
113
116
|
114
- call .getTarget ( ) .hasName ( "guarded" ) and
115
- isTrue = true
117
+ call .getStaticCallTarget ( ) .hasName ( "guarded" ) and
118
+ b = false
116
119
or
117
- call .getTarget ( ) .hasName ( "unsafe" ) and
118
- isTrue = false
120
+ call .getStaticCallTarget ( ) .hasName ( "unsafe" ) and
121
+ b = true
119
122
)
120
123
}
121
124
0 commit comments