mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge pull request #403 from jbj/FlowVar-getAnAccess-perf
C++: Performance fix for FlowVar.getAnAccess
This commit is contained in:
@@ -221,9 +221,7 @@ module FlowVar_internal {
|
||||
BlockVar() { this = TBlockVar(sbb, v) }
|
||||
|
||||
override VariableAccess getAnAccess() {
|
||||
result.getTarget() = v and
|
||||
result = getAReachedBlockVarSBB(this).getANode() and
|
||||
not overwrite(result, _)
|
||||
variableAccessInSBB(v, getAReachedBlockVarSBB(this), result)
|
||||
}
|
||||
|
||||
override predicate definedByInitialValue(LocalScopeVariable lsv) {
|
||||
@@ -373,6 +371,15 @@ module FlowVar_internal {
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `va` is a read access to `v` in `sbb`, where `v` is modeled by `BlockVar`. */
|
||||
pragma[noinline]
|
||||
private predicate variableAccessInSBB(Variable v, SubBasicBlock sbb, VariableAccess va) {
|
||||
exists(TBlockVar(_, v)) and
|
||||
va.getTarget() = v and
|
||||
va = sbb.getANode() and
|
||||
not overwrite(va, _)
|
||||
}
|
||||
|
||||
/**
|
||||
* A local variable that is uninitialized immediately after its declaration.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user