Skip to content

Commit

Permalink
Merge pull request github#16337 from MathiasVP/cache-second-level-scope
Browse files Browse the repository at this point in the history
DataFlow: Cache `getSecondLevelScope`
  • Loading branch information
MathiasVP authored Apr 26, 2024
2 parents a707e14 + 2482519 commit 6147a38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1119,9 +1119,10 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {

pragma[nomagic]
private SndLevelScopeOption getScope(RetNodeEx ret) {
result = SndLevelScopeOption::some(getSecondLevelScope(ret.asNode()))
result = SndLevelScopeOption::some(getSecondLevelScopeCached(ret.asNode()))
or
result instanceof SndLevelScopeOption::None and not exists(getSecondLevelScope(ret.asNode()))
result instanceof SndLevelScopeOption::None and
not exists(getSecondLevelScopeCached(ret.asNode()))
}

pragma[nomagic]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,9 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
cached
predicate forceCachingInSameStage() { any() }

cached
DataFlowSecondLevelScope getSecondLevelScopeCached(Node n) { result = getSecondLevelScope(n) }

cached
predicate nodeEnclosingCallable(Node n, DataFlowCallable c) { c = nodeGetEnclosingCallable(n) }

Expand Down

0 comments on commit 6147a38

Please sign in to comment.