Skip to content

Commit a3a5829

Browse files
authored
Merge pull request #598 from jbj/AlwaysTrueUponEntryLoop-perf
C++: data flow AlwaysTrueUponEntryLoop perf fix
2 parents d933152 + d14cf34 commit a3a5829

File tree

1 file changed

+10
-4
lines changed
  • cpp/ql/src/semmle/code/cpp/dataflow/internal

1 file changed

+10
-4
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/FlowVar.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,23 @@ module FlowVar_internal {
292292
* Gets a variable that is assigned in this loop and read outside the loop.
293293
*/
294294
private Variable getARelevantVariable() {
295-
exists(BasicBlock bbAssign |
296-
assignmentLikeOperation(bbAssign.getANode(), result, _) and
297-
this.bbInLoop(bbAssign)
298-
) and
295+
result = this.getAVariableAssignedInLoop() and
299296
exists(VariableAccess va |
300297
va.getTarget() = result and
301298
readAccess(va) and
302299
bbNotInLoop(va.getBasicBlock())
303300
)
304301
}
305302

303+
/** Gets a variable that is assigned in this loop. */
304+
pragma[noinline]
305+
private Variable getAVariableAssignedInLoop() {
306+
exists(BasicBlock bbAssign |
307+
assignmentLikeOperation(bbAssign.getANode(), result, _) and
308+
this.bbInLoop(bbAssign)
309+
)
310+
}
311+
306312
private predicate bbInLoopCondition(BasicBlock bb) {
307313
getCFNParent*(bb.getANode()) = this.(Loop).getCondition()
308314
}

0 commit comments

Comments
 (0)