Skip to content

Commit 0c3ea6c

Browse files
committed
C++: Fix conflation issue.
1 parent 259bf27 commit 0c3ea6c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,16 @@ private newtype TDefOrUseImpl =
149149
private predicate isGlobalUse(
150150
GlobalLikeVariable v, IRFunction f, int indirection, int indirectionIndex
151151
) {
152-
exists(VariableAddressInstruction vai |
153-
vai.getEnclosingIRFunction() = f and
154-
vai.getAstVariable() = v and
155-
isDef(_, _, _, vai, indirection, indirectionIndex)
156-
)
152+
// Generate a "global use" at the end of the function body if there's a
153+
// direct definition somewhere in the body of the function
154+
indirection =
155+
min(int cand, VariableAddressInstruction vai |
156+
vai.getEnclosingIRFunction() = f and
157+
vai.getAstVariable() = v and
158+
isDef(_, _, _, vai, cand, indirectionIndex)
159+
|
160+
cand
161+
)
157162
}
158163

159164
private predicate isGlobalDefImpl(

0 commit comments

Comments
 (0)