Skip to content

Commit fd26ae1

Browse files
committed
C++: Obtain the SSA variable of a 'GlobalUse' using the indirection instead of the index (like we do for non-global uses as well).
1 parent bb5a78d commit fd26ae1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,9 @@ class GlobalUse extends UseImpl, TGlobalUse {
472472
)
473473
}
474474

475-
override SourceVariable getSourceVariable() { sourceVariableIsGlobal(result, global, f, ind) }
475+
override SourceVariable getSourceVariable() {
476+
sourceVariableIsGlobal(result, global, f, this.getIndirection())
477+
}
476478

477479
final override Cpp::Location getLocation() { result = f.getLocation() }
478480

@@ -513,9 +515,11 @@ class GlobalDefImpl extends DefOrUseImpl, TGlobalDefImpl {
513515

514516
/** Gets the global variable associated with this definition. */
515517
override SourceVariable getSourceVariable() {
516-
sourceVariableIsGlobal(result, global, f, indirectionIndex)
518+
sourceVariableIsGlobal(result, global, f, this.getIndirection())
517519
}
518520

521+
int getIndirection() { result = indirectionIndex }
522+
519523
/**
520524
* Gets the type of this use after specifiers have been deeply stripped
521525
* and typedefs have been resolved.

0 commit comments

Comments
 (0)