mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
C++: Update escape analysis tests to new API
This commit is contained in:
@@ -16,9 +16,9 @@ where
|
||||
exists(IRFunction irFunc |
|
||||
irFunc = var.getEnclosingIRFunction() and
|
||||
(
|
||||
shouldEscape(var) and variableAddressEscapes(var)
|
||||
shouldEscape(var) and allocationEscapes(var)
|
||||
or
|
||||
not shouldEscape(var) and not variableAddressEscapes(var)
|
||||
not shouldEscape(var) and not allocationEscapes(var)
|
||||
)
|
||||
)
|
||||
select var
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
import default
|
||||
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.AliasAnalysis
|
||||
import semmle.code.cpp.ir.implementation.aliased_ssa.internal.AliasConfiguration
|
||||
import semmle.code.cpp.ir.implementation.unaliased_ssa.IR
|
||||
import semmle.code.cpp.ir.implementation.UseSoundEscapeAnalysis
|
||||
|
||||
predicate shouldEscape(IRAutomaticUserVariable var) {
|
||||
exists(string name |
|
||||
name = var.getVariable().getName() and
|
||||
name.matches("no_%")
|
||||
)
|
||||
class InterestingAllocation extends VariableAllocation {
|
||||
IRUserVariable userVar;
|
||||
|
||||
InterestingAllocation() { userVar = this.getIRVariable() }
|
||||
|
||||
final predicate shouldEscape() { userVar.getVariable().getName().matches("no_%") }
|
||||
}
|
||||
|
||||
from IRAutomaticUserVariable var
|
||||
from InterestingAllocation var
|
||||
where
|
||||
exists(IRFunction irFunc |
|
||||
irFunc = var.getEnclosingIRFunction() and
|
||||
(
|
||||
shouldEscape(var) and variableAddressEscapes(var)
|
||||
var.shouldEscape() and allocationEscapes(var)
|
||||
or
|
||||
not shouldEscape(var) and not variableAddressEscapes(var)
|
||||
not var.shouldEscape() and not allocationEscapes(var)
|
||||
)
|
||||
)
|
||||
select var
|
||||
|
||||
Reference in New Issue
Block a user