Skip to content

Commit 7ad45d5

Browse files
committed
C++: add test case from issue
1 parent 43520b8 commit 7ad45d5

File tree

5 files changed

+101
-1
lines changed

5 files changed

+101
-1
lines changed

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,3 +1478,27 @@ ssa.cpp:
14781478
# 301| v301_14(void) = ReturnValue : &:r301_13, m304_7
14791479
# 301| v301_15(void) = AliasedUse : ~m303_11
14801480
# 301| v301_16(void) = ExitFunction :
1481+
1482+
# 310| void ThisAliasTest::setX(int)
1483+
# 310| Block 0
1484+
# 310| v310_1(void) = EnterFunction :
1485+
# 310| m310_2(unknown) = AliasedDefinition :
1486+
# 310| m310_3(unknown) = InitializeNonLocal :
1487+
# 310| m310_4(unknown) = Chi : total:m310_2, partial:m310_3
1488+
# 310| r310_5(glval<unknown>) = VariableAddress[#this] :
1489+
# 310| m310_6(glval<ThisAliasTest>) = InitializeParameter[#this] : &:r310_5
1490+
# 310| r310_7(glval<ThisAliasTest>) = Load : &:r310_5, m310_6
1491+
# 310| m310_8(ThisAliasTest) = InitializeIndirection[#this] : &:r310_7
1492+
# 310| r310_9(glval<int>) = VariableAddress[arg] :
1493+
# 310| m310_10(int) = InitializeParameter[arg] : &:r310_9
1494+
# 311| r311_1(glval<int>) = VariableAddress[arg] :
1495+
# 311| r311_2(int) = Load : &:r311_1, m310_10
1496+
# 311| r311_3(glval<unknown>) = VariableAddress[#this] :
1497+
# 311| r311_4(ThisAliasTest *) = Load : &:r311_3, m310_6
1498+
# 311| r311_5(glval<int>) = FieldAddress[x] : r311_4
1499+
# 311| m311_6(int) = Store : &:r311_5, r311_2
1500+
# 311| m311_7(unknown) = Chi : total:m310_8, partial:m311_6
1501+
# 312| v312_1(void) = NoOp :
1502+
# 310| v310_11(void) = ReturnVoid :
1503+
# 310| v310_12(void) = AliasedUse : m310_3
1504+
# 310| v310_13(void) = ExitFunction :

cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir_unsound.expected

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,3 +1465,27 @@ ssa.cpp:
14651465
# 301| v301_13(void) = ReturnValue : &:r301_12, m304_7
14661466
# 301| v301_14(void) = AliasedUse : ~m303_8
14671467
# 301| v301_15(void) = ExitFunction :
1468+
1469+
# 310| void ThisAliasTest::setX(int)
1470+
# 310| Block 0
1471+
# 310| v310_1(void) = EnterFunction :
1472+
# 310| m310_2(unknown) = AliasedDefinition :
1473+
# 310| m310_3(unknown) = InitializeNonLocal :
1474+
# 310| m310_4(unknown) = Chi : total:m310_2, partial:m310_3
1475+
# 310| r310_5(glval<unknown>) = VariableAddress[#this] :
1476+
# 310| m310_6(glval<ThisAliasTest>) = InitializeParameter[#this] : &:r310_5
1477+
# 310| r310_7(glval<ThisAliasTest>) = Load : &:r310_5, m310_6
1478+
# 310| m310_8(ThisAliasTest) = InitializeIndirection[#this] : &:r310_7
1479+
# 310| r310_9(glval<int>) = VariableAddress[arg] :
1480+
# 310| m310_10(int) = InitializeParameter[arg] : &:r310_9
1481+
# 311| r311_1(glval<int>) = VariableAddress[arg] :
1482+
# 311| r311_2(int) = Load : &:r311_1, m310_10
1483+
# 311| r311_3(glval<unknown>) = VariableAddress[#this] :
1484+
# 311| r311_4(ThisAliasTest *) = Load : &:r311_3, m310_6
1485+
# 311| r311_5(glval<int>) = FieldAddress[x] : r311_4
1486+
# 311| m311_6(int) = Store : &:r311_5, r311_2
1487+
# 311| m311_7(unknown) = Chi : total:m310_8, partial:m311_6
1488+
# 312| v312_1(void) = NoOp :
1489+
# 310| v310_11(void) = ReturnVoid :
1490+
# 310| v310_12(void) = AliasedUse : m310_3
1491+
# 310| v310_13(void) = ExitFunction :

cpp/ql/test/library-tests/ir/ssa/ssa.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,12 @@ int main(int argc, char **argv) {
302302
unknownFunction(argc, argv);
303303
unknownFunction(argc, argv);
304304
return **argv; // Chi chain goes through side effects from unknownFunction
305-
}
305+
}
306+
307+
class ThisAliasTest {
308+
int x, y;
309+
310+
void setX(int arg) {
311+
this->x = arg;
312+
}
313+
};

cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,25 @@ ssa.cpp:
13481348
# 301| v301_12(void) = ReturnValue : &:r301_11, m304_7
13491349
# 301| v301_13(void) = AliasedUse : ~m?
13501350
# 301| v301_14(void) = ExitFunction :
1351+
1352+
# 310| void ThisAliasTest::setX(int)
1353+
# 310| Block 0
1354+
# 310| v310_1(void) = EnterFunction :
1355+
# 310| mu310_2(unknown) = AliasedDefinition :
1356+
# 310| mu310_3(unknown) = InitializeNonLocal :
1357+
# 310| r310_4(glval<unknown>) = VariableAddress[#this] :
1358+
# 310| m310_5(glval<ThisAliasTest>) = InitializeParameter[#this] : &:r310_4
1359+
# 310| r310_6(glval<ThisAliasTest>) = Load : &:r310_4, m310_5
1360+
# 310| mu310_7(ThisAliasTest) = InitializeIndirection[#this] : &:r310_6
1361+
# 310| r310_8(glval<int>) = VariableAddress[arg] :
1362+
# 310| m310_9(int) = InitializeParameter[arg] : &:r310_8
1363+
# 311| r311_1(glval<int>) = VariableAddress[arg] :
1364+
# 311| r311_2(int) = Load : &:r311_1, m310_9
1365+
# 311| r311_3(glval<unknown>) = VariableAddress[#this] :
1366+
# 311| r311_4(ThisAliasTest *) = Load : &:r311_3, m310_5
1367+
# 311| r311_5(glval<int>) = FieldAddress[x] : r311_4
1368+
# 311| mu311_6(int) = Store : &:r311_5, r311_2
1369+
# 312| v312_1(void) = NoOp :
1370+
# 310| v310_10(void) = ReturnVoid :
1371+
# 310| v310_11(void) = AliasedUse : ~m?
1372+
# 310| v310_12(void) = ExitFunction :

cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir_unsound.expected

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,25 @@ ssa.cpp:
13481348
# 301| v301_12(void) = ReturnValue : &:r301_11, m304_7
13491349
# 301| v301_13(void) = AliasedUse : ~m?
13501350
# 301| v301_14(void) = ExitFunction :
1351+
1352+
# 310| void ThisAliasTest::setX(int)
1353+
# 310| Block 0
1354+
# 310| v310_1(void) = EnterFunction :
1355+
# 310| mu310_2(unknown) = AliasedDefinition :
1356+
# 310| mu310_3(unknown) = InitializeNonLocal :
1357+
# 310| r310_4(glval<unknown>) = VariableAddress[#this] :
1358+
# 310| m310_5(glval<ThisAliasTest>) = InitializeParameter[#this] : &:r310_4
1359+
# 310| r310_6(glval<ThisAliasTest>) = Load : &:r310_4, m310_5
1360+
# 310| mu310_7(ThisAliasTest) = InitializeIndirection[#this] : &:r310_6
1361+
# 310| r310_8(glval<int>) = VariableAddress[arg] :
1362+
# 310| m310_9(int) = InitializeParameter[arg] : &:r310_8
1363+
# 311| r311_1(glval<int>) = VariableAddress[arg] :
1364+
# 311| r311_2(int) = Load : &:r311_1, m310_9
1365+
# 311| r311_3(glval<unknown>) = VariableAddress[#this] :
1366+
# 311| r311_4(ThisAliasTest *) = Load : &:r311_3, m310_5
1367+
# 311| r311_5(glval<int>) = FieldAddress[x] : r311_4
1368+
# 311| mu311_6(int) = Store : &:r311_5, r311_2
1369+
# 312| v312_1(void) = NoOp :
1370+
# 310| v310_10(void) = ReturnVoid :
1371+
# 310| v310_11(void) = AliasedUse : ~m?
1372+
# 310| v310_12(void) = ExitFunction :

0 commit comments

Comments
 (0)