C++: Make swap member functions data-flow functions

This commit is contained in:
Simon Friis Vindum
2024-09-03 09:46:58 +02:00
parent 04f4039adc
commit f066f21751
16 changed files with 97 additions and 107 deletions

View File

@@ -1054,6 +1054,34 @@ void test_realloc() {
sink(*dest); // $ ir, MISSING: ast
}
struct MyInt {
int i;
MyInt();
void swap(MyInt &j);
};
void test_member_swap() {
MyInt s1;
MyInt s2;
s2.i = source();
MyInt s3;
MyInt s4;
s4.i = source();
sink(s1.i);
sink(s2.i); // $ ast,ir
sink(s3.i);
sink(s4.i); // $ ast,ir
s1.swap(s2);
s4.swap(s3);
sink(s1.i); // $ ir
sink(s2.i); // $ SPURIOUS: ast
sink(s3.i); // $ ir
sink(s4.i); // $ SPURIOUS: ast
}
void flow_out_of_address_with_local_flow() {
MyStruct a;
a.content = nullptr;