Skip to content

Commit 7013bc6

Browse files
author
Dave Bartolomeo
committed
C++: Update escape analysis tests to new API
1 parent bb9485d commit 7013bc6

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

cpp/ql/test/library-tests/ir/escape/escape.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ where
1616
exists(IRFunction irFunc |
1717
irFunc = var.getEnclosingIRFunction() and
1818
(
19-
shouldEscape(var) and variableAddressEscapes(var)
19+
shouldEscape(var) and allocationEscapes(var)
2020
or
21-
not shouldEscape(var) and not variableAddressEscapes(var)
21+
not shouldEscape(var) and not allocationEscapes(var)
2222
)
2323
)
2424
select var
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import default
22
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.AliasAnalysis
3+
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.AliasConfiguration
34
import semmle.code.cpp.ir.implementation.unaliased_ssa.IR
45
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis
56

6-
predicate shouldEscape(IRAutomaticUserVariable var) {
7-
exists(string name |
8-
name = var.getVariable().getName() and
9-
name.matches("no_%")
10-
)
7+
class InterestingAllocation extends VariableAllocation {
8+
IRUserVariable userVar;
9+
10+
InterestingAllocation() { userVar = this.getIRVariable() }
11+
12+
final predicate shouldEscape() { userVar.getVariable().getName().matches("no_%") }
1113
}
1214

13-
from IRAutomaticUserVariable var
15+
from InterestingAllocation var
1416
where
1517
exists(IRFunction irFunc |
1618
irFunc = var.getEnclosingIRFunction() and
1719
(
18-
shouldEscape(var) and variableAddressEscapes(var)
20+
var.shouldEscape() and allocationEscapes(var)
1921
or
20-
not shouldEscape(var) and not variableAddressEscapes(var)
22+
not var.shouldEscape() and not allocationEscapes(var)
2123
)
2224
)
2325
select var

0 commit comments

Comments
 (0)