Skip to content

Commit adfa5a5

Browse files
committed
C++: Fix an issue where we didn't create 'GlobalUse' dataflow nodes when there wasn't an SSA definition in the function.
1 parent dbfea8e commit adfa5a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ private newtype TDefOrUseImpl =
155155
TGlobalUse(GlobalLikeVariable v, IRFunction f, int indirectionIndex) {
156156
// Represents a final "use" of a global variable to ensure that
157157
// the assignment to a global variable isn't ruled out as dead.
158-
exists(VariableAddressInstruction vai, int defIndex |
158+
exists(VariableAddressInstruction vai, int i |
159159
vai.getEnclosingIRFunction() = f and
160160
vai.getAstVariable() = v and
161-
isDef(_, _, _, vai, _, defIndex) and
162-
indirectionIndex = [0 .. defIndex] + 1
161+
indirectionIndex = [0 .. i] + 1
162+
|
163+
isDef(_, _, _, vai, indirectionIndex, i) or
164+
isUse(_, _, vai, indirectionIndex, i)
163165
)
164166
} or
165167
TGlobalDefImpl(GlobalLikeVariable v, IRFunction f, int indirectionIndex) {

0 commit comments

Comments
 (0)