@@ -7,14 +7,17 @@ module AstTest {
77 * S in `if (guarded(x)) S`.
88 */
99 // 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+ )
1821 }
1922
2023 /** Common data flow configuration to be used by tests. */
@@ -106,16 +109,16 @@ module IRTest {
106109 * S in `if (guarded(x)) S`.
107110 */
108111 // 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 ) )
113116 |
114- call .getTarget ( ) .hasName ( "guarded" ) and
115- isTrue = true
117+ call .getStaticCallTarget ( ) .hasName ( "guarded" ) and
118+ b = false
116119 or
117- call .getTarget ( ) .hasName ( "unsafe" ) and
118- isTrue = false
120+ call .getStaticCallTarget ( ) .hasName ( "unsafe" ) and
121+ b = true
119122 )
120123 }
121124
0 commit comments