Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ private newtype TDefOrUseImpl =
TGlobalUse(GlobalLikeVariable v, IRFunction f, int indirectionIndex) {
// Represents a final "use" of a global variable to ensure that
// the assignment to a global variable isn't ruled out as dead.
exists(VariableAddressInstruction vai, int defIndex |
exists(VariableAddressInstruction vai, int i |
vai.getEnclosingIRFunction() = f and
vai.getAstVariable() = v and
isDef(_, _, _, vai, _, defIndex) and
indirectionIndex = [0 .. defIndex] + 1
indirectionIndex = [0 .. i] + 1
|
isDef(_, _, _, vai, indirectionIndex, i) or
isUse(_, _, vai, indirectionIndex, i)
)
} or
TGlobalDefImpl(GlobalLikeVariable v, IRFunction f, int indirectionIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ postWithInFlow
| example.c:28:23:28:25 | pos [inner post update] | PostUpdateNode should not be the target of local flow. |
| globals.cpp:13:5:13:19 | flowTestGlobal1 [post update] | PostUpdateNode should not be the target of local flow. |
| globals.cpp:23:5:23:19 | flowTestGlobal2 [post update] | PostUpdateNode should not be the target of local flow. |
| globals.cpp:34:18:34:18 | x [post update] | PostUpdateNode should not be the target of local flow. |
| lambdas.cpp:23:3:23:14 | v [post update] | PostUpdateNode should not be the target of local flow. |
| lambdas.cpp:43:3:43:3 | c [post update] | PostUpdateNode should not be the target of local flow. |
| ref.cpp:11:5:11:7 | lhs [post update] | PostUpdateNode should not be the target of local flow. |
Expand Down
17 changes: 17 additions & 0 deletions cpp/ql/test/library-tests/dataflow/dataflow-tests/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,20 @@ void readGlobal2() {
void writeGlobal2() {
flowTestGlobal2 = source();
}

namespace MyNamespace {
struct A {
int x;
};

A global_a;

void set_without_ssa_def() {
global_a.x = source();
}

void call_set_without_ssa_def() {
set_without_ssa_def();
sink(global_a.x); // $ ir MISSING: ast
}
}