Skip to content

Commit

Permalink
C++: Fix ODR violations in dataflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jketema committed Oct 8, 2024
1 parent f1e2268 commit c90d0fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cpp/ql/test/library-tests/dataflow/dataflow-tests/flowOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int* deref(int** p) { // $ ast-def=p ir-def=*p ir-def=**p
return q;
}

void test1() {
void flowout_test1() {
int x = 0;
int* p = &x;
deref(&p)[0] = source();
Expand All @@ -95,7 +95,7 @@ void addtaint2(int** p) { // $ ast-def=p ir-def=*p ir-def=**p
addtaint1(q);
}

void test2() {
void flowout_test2() {
int x = 0;
int* p = &x;
addtaint2(&p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ template<> struct std::iterator_traits<unsigned long>
};


int test() {
int iterator_test() {
unsigned long x = source();
sink(x); // $ ast ir
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ int source();
void sink(...);
bool random();

void test1() {
void on_entry_test1() {
int x = source();
for (int i = 0; i < 10; i++) {
x = 0;
}
sink(x); // $ SPURIOUS: ir
}

void test2(int iterations) {
void on_entry_test2(int iterations) {
int x = source();
for (int i = 0; i < iterations; i++) {
x = 0;
}
sink(x); // $ ast,ir
}

void test3() {
void on_entry_test3() {
int x = 0;
for (int i = 0; i < 10; i++) {
x = source();
}
sink(x); // $ ast,ir
}

void test4() {
void on_entry_test4() {
int x = source();
for (int i = 0; i < 10; i++) {
if (random())
Expand All @@ -39,7 +39,7 @@ void test4() {
sink(x); // $ ast,ir
}

void test5() {
void on_entry_test5() {
int x = source();
for (int i = 0; i < 10; i++) {
if (random())
Expand All @@ -49,15 +49,15 @@ void test5() {
sink(x); // $ ast,ir
}

void test6() {
void on_entry_test6() {
int y;
int x = source();
for (int i = 0; i < 10 && (y = 1); i++) {
}
sink(x); // $ ast,ir
}

void test7() {
void on_entry_test7() {
int y;
int x = source();
for (int i = 0; i < 10 && (y = 1); i++) {
Expand All @@ -66,7 +66,7 @@ void test7() {
sink(x); // $ SPURIOUS: ir
}

void test8() {
void on_entry_test8() {
int x = source();
// It appears to the analysis that the condition can exit after `i < 10`
// without having assigned to `x`. That is an effect of how the
Expand All @@ -78,22 +78,22 @@ void test8() {
sink(x); // $ SPURIOUS: ast,ir
}

void test9() {
void on_entry_test9() {
int y;
int x = source();
for (int i = 0; (y = 1) && i < 10; i++) {
}
sink(x); // $ ast,ir
}

void test10() {
void on_entry_test10() {
int x = source();
for (int i = 0; (x = 1) && i < 10; i++) {
}
sink(x); // no flow
}

void test10(int b, int d) {
void on_entry_test10(int b, int d) {
int i = 0;
int x = source();
if (b)
Expand Down

0 comments on commit c90d0fa

Please sign in to comment.