Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47b9c49

Browse files
author
Robert Marsh
committed
C++: IR SSA tests for explicit constructor calls
1 parent 53f522c commit 47b9c49

3 files changed

Lines changed: 146 additions & 0 deletions

File tree

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,72 @@ ssa.cpp:
846846
# 207| v0_24(void) = ReturnValue : &:r0_23, m0_22
847847
# 207| v0_25(void) = UnmodeledUse : mu*
848848
# 207| v0_26(void) = ExitFunction :
849+
850+
# 215| void Constructible::Constructible(int)
851+
# 215| Block 0
852+
# 215| v0_0(void) = EnterFunction :
853+
# 215| m0_1(unknown) = AliasedDefinition :
854+
# 215| mu0_2(unknown) = UnmodeledDefinition :
855+
# 215| r0_3(glval<Constructible>) = InitializeThis :
856+
# 215| r0_4(glval<int>) = VariableAddress[x] :
857+
# 215| m0_5(int) = InitializeParameter[x] : &:r0_4
858+
# 215| v0_6(void) = NoOp :
859+
# 215| v0_7(void) = ReturnVoid :
860+
# 215| v0_8(void) = UnmodeledUse : mu*
861+
# 215| v0_9(void) = ExitFunction :
862+
863+
# 216| void Constructible::g()
864+
# 216| Block 0
865+
# 216| v0_0(void) = EnterFunction :
866+
# 216| m0_1(unknown) = AliasedDefinition :
867+
# 216| mu0_2(unknown) = UnmodeledDefinition :
868+
# 216| r0_3(glval<Constructible>) = InitializeThis :
869+
# 216| v0_4(void) = NoOp :
870+
# 216| v0_5(void) = ReturnVoid :
871+
# 216| v0_6(void) = UnmodeledUse : mu*
872+
# 216| v0_7(void) = ExitFunction :
873+
874+
# 219| void ExplicitConstructorCalls()
875+
# 219| Block 0
876+
# 219| v0_0(void) = EnterFunction :
877+
# 219| m0_1(unknown) = AliasedDefinition :
878+
# 219| mu0_2(unknown) = UnmodeledDefinition :
879+
# 220| r0_3(glval<Constructible>) = VariableAddress[c] :
880+
# 220| r0_4(glval<unknown>) = FunctionAddress[Constructible] :
881+
# 220| r0_5(int) = Constant[1] :
882+
# 220| v0_6(void) = Call : func:r0_4, this:r0_3, 0:r0_5
883+
# 220| m0_7(unknown) = ^CallSideEffect : ~m0_1
884+
# 220| m0_8(unknown) = Chi : total:m0_1, partial:m0_7
885+
# 220| m0_9(Constructible) = ^IndirectMayWriteSideEffect : &:r0_3
886+
# 221| r0_10(glval<Constructible>) = VariableAddress[c] :
887+
# 221| r0_11(glval<unknown>) = FunctionAddress[g] :
888+
# 221| v0_12(void) = Call : func:r0_11, this:r0_10
889+
# 221| m0_13(unknown) = ^CallSideEffect : ~m0_8
890+
# 221| m0_14(unknown) = Chi : total:m0_8, partial:m0_13
891+
# 221| v0_15(void) = ^IndirectReadSideEffect[-1] : &:r0_10, m0_9
892+
# 221| m0_16(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_10
893+
# 222| r0_17(glval<Constructible>) = VariableAddress[c] :
894+
# 222| r0_18(glval<unknown>) = FunctionAddress[g] :
895+
# 222| v0_19(void) = Call : func:r0_18, this:r0_17
896+
# 222| m0_20(unknown) = ^CallSideEffect : ~m0_14
897+
# 222| m0_21(unknown) = Chi : total:m0_14, partial:m0_20
898+
# 222| v0_22(void) = ^IndirectReadSideEffect[-1] : &:r0_17, m0_16
899+
# 222| m0_23(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_17
900+
# 223| r0_24(glval<Constructible>) = VariableAddress[c2] :
901+
# 223| r0_25(glval<unknown>) = FunctionAddress[Constructible] :
902+
# 223| r0_26(int) = Constant[2] :
903+
# 223| v0_27(void) = Call : func:r0_25, this:r0_24, 0:r0_26
904+
# 223| m0_28(unknown) = ^CallSideEffect : ~m0_21
905+
# 223| m0_29(unknown) = Chi : total:m0_21, partial:m0_28
906+
# 223| m0_30(Constructible) = ^IndirectMayWriteSideEffect : &:r0_24
907+
# 224| r0_31(glval<Constructible>) = VariableAddress[c2] :
908+
# 224| r0_32(glval<unknown>) = FunctionAddress[g] :
909+
# 224| v0_33(void) = Call : func:r0_32, this:r0_31
910+
# 224| m0_34(unknown) = ^CallSideEffect : ~m0_29
911+
# 224| m0_35(unknown) = Chi : total:m0_29, partial:m0_34
912+
# 224| v0_36(void) = ^IndirectReadSideEffect[-1] : &:r0_31, m0_30
913+
# 224| m0_37(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_31
914+
# 225| v0_38(void) = NoOp :
915+
# 219| v0_39(void) = ReturnVoid :
916+
# 219| v0_40(void) = UnmodeledUse : mu*
917+
# 219| v0_41(void) = ExitFunction :

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,16 @@ int ModeledCallTarget(int x) {
210210
return y;
211211
}
212212

213+
class Constructible {
214+
public:
215+
Constructible(int x) {};
216+
void g() {}
217+
};
218+
219+
void ExplicitConstructorCalls() {
220+
Constructible c(1);
221+
c.g();
222+
c.g();
223+
Constructible c2 = Constructible(2);
224+
c2.g();
225+
}

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,3 +806,67 @@ ssa.cpp:
806806
# 207| v0_21(void) = ReturnValue : &:r0_20, m0_19
807807
# 207| v0_22(void) = UnmodeledUse : mu*
808808
# 207| v0_23(void) = ExitFunction :
809+
810+
# 215| void Constructible::Constructible(int)
811+
# 215| Block 0
812+
# 215| v0_0(void) = EnterFunction :
813+
# 215| mu0_1(unknown) = AliasedDefinition :
814+
# 215| mu0_2(unknown) = UnmodeledDefinition :
815+
# 215| r0_3(glval<Constructible>) = InitializeThis :
816+
# 215| r0_4(glval<int>) = VariableAddress[x] :
817+
# 215| m0_5(int) = InitializeParameter[x] : &:r0_4
818+
# 215| v0_6(void) = NoOp :
819+
# 215| v0_7(void) = ReturnVoid :
820+
# 215| v0_8(void) = UnmodeledUse : mu*
821+
# 215| v0_9(void) = ExitFunction :
822+
823+
# 216| void Constructible::g()
824+
# 216| Block 0
825+
# 216| v0_0(void) = EnterFunction :
826+
# 216| mu0_1(unknown) = AliasedDefinition :
827+
# 216| mu0_2(unknown) = UnmodeledDefinition :
828+
# 216| r0_3(glval<Constructible>) = InitializeThis :
829+
# 216| v0_4(void) = NoOp :
830+
# 216| v0_5(void) = ReturnVoid :
831+
# 216| v0_6(void) = UnmodeledUse : mu*
832+
# 216| v0_7(void) = ExitFunction :
833+
834+
# 219| void ExplicitConstructorCalls()
835+
# 219| Block 0
836+
# 219| v0_0(void) = EnterFunction :
837+
# 219| mu0_1(unknown) = AliasedDefinition :
838+
# 219| mu0_2(unknown) = UnmodeledDefinition :
839+
# 220| r0_3(glval<Constructible>) = VariableAddress[c] :
840+
# 220| r0_4(glval<unknown>) = FunctionAddress[Constructible] :
841+
# 220| r0_5(int) = Constant[1] :
842+
# 220| v0_6(void) = Call : func:r0_4, this:r0_3, 0:r0_5
843+
# 220| mu0_7(unknown) = ^CallSideEffect : ~mu0_2
844+
# 220| m0_8(Constructible) = ^IndirectMayWriteSideEffect : &:r0_3
845+
# 221| r0_9(glval<Constructible>) = VariableAddress[c] :
846+
# 221| r0_10(glval<unknown>) = FunctionAddress[g] :
847+
# 221| v0_11(void) = Call : func:r0_10, this:r0_9
848+
# 221| mu0_12(unknown) = ^CallSideEffect : ~mu0_2
849+
# 221| v0_13(void) = ^IndirectReadSideEffect[-1] : &:r0_9, m0_8
850+
# 221| m0_14(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_9
851+
# 222| r0_15(glval<Constructible>) = VariableAddress[c] :
852+
# 222| r0_16(glval<unknown>) = FunctionAddress[g] :
853+
# 222| v0_17(void) = Call : func:r0_16, this:r0_15
854+
# 222| mu0_18(unknown) = ^CallSideEffect : ~mu0_2
855+
# 222| v0_19(void) = ^IndirectReadSideEffect[-1] : &:r0_15, m0_14
856+
# 222| m0_20(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_15
857+
# 223| r0_21(glval<Constructible>) = VariableAddress[c2] :
858+
# 223| r0_22(glval<unknown>) = FunctionAddress[Constructible] :
859+
# 223| r0_23(int) = Constant[2] :
860+
# 223| v0_24(void) = Call : func:r0_22, this:r0_21, 0:r0_23
861+
# 223| mu0_25(unknown) = ^CallSideEffect : ~mu0_2
862+
# 223| m0_26(Constructible) = ^IndirectMayWriteSideEffect : &:r0_21
863+
# 224| r0_27(glval<Constructible>) = VariableAddress[c2] :
864+
# 224| r0_28(glval<unknown>) = FunctionAddress[g] :
865+
# 224| v0_29(void) = Call : func:r0_28, this:r0_27
866+
# 224| mu0_30(unknown) = ^CallSideEffect : ~mu0_2
867+
# 224| v0_31(void) = ^IndirectReadSideEffect[-1] : &:r0_27, m0_26
868+
# 224| m0_32(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_27
869+
# 225| v0_33(void) = NoOp :
870+
# 219| v0_34(void) = ReturnVoid :
871+
# 219| v0_35(void) = UnmodeledUse : mu*
872+
# 219| v0_36(void) = ExitFunction :

0 commit comments

Comments
 (0)