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

Skip to content

Commit 5f8a305

Browse files
author
Robert Marsh
committed
C++: add UninitializedInstructions for direct init
1 parent bc97397 commit 5f8a305

3 files changed

Lines changed: 77 additions & 72 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ abstract class TranslatedVariableDeclaration extends TranslatedElement, Initiali
123123

124124
private predicate hasUninitializedInstruction() {
125125
not exists(getInitialization()) or
126-
getInitialization() instanceof TranslatedListInitialization
126+
getInitialization() instanceof TranslatedListInitialization or
127+
getInitialization() instanceof TranslatedConstructorInitialization
127128
}
128129
}
129130

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

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -877,41 +877,43 @@ ssa.cpp:
877877
# 219| m0_1(unknown) = AliasedDefinition :
878878
# 219| mu0_2(unknown) = UnmodeledDefinition :
879879
# 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[-1] : &: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[-1] : &: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 :
880+
# 220| m0_4(Constructible) = Uninitialized[c] : &:r0_3
881+
# 220| r0_5(glval<unknown>) = FunctionAddress[Constructible] :
882+
# 220| r0_6(int) = Constant[1] :
883+
# 220| v0_7(void) = Call : func:r0_5, this:r0_3, 0:r0_6
884+
# 220| m0_8(unknown) = ^CallSideEffect : ~m0_1
885+
# 220| m0_9(unknown) = Chi : total:m0_1, partial:m0_8
886+
# 220| m0_10(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_3
887+
# 221| r0_11(glval<Constructible>) = VariableAddress[c] :
888+
# 221| r0_12(glval<unknown>) = FunctionAddress[g] :
889+
# 221| v0_13(void) = Call : func:r0_12, this:r0_11
890+
# 221| m0_14(unknown) = ^CallSideEffect : ~m0_9
891+
# 221| m0_15(unknown) = Chi : total:m0_9, partial:m0_14
892+
# 221| v0_16(void) = ^IndirectReadSideEffect[-1] : &:r0_11, m0_10
893+
# 221| m0_17(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_11
894+
# 222| r0_18(glval<Constructible>) = VariableAddress[c] :
895+
# 222| r0_19(glval<unknown>) = FunctionAddress[g] :
896+
# 222| v0_20(void) = Call : func:r0_19, this:r0_18
897+
# 222| m0_21(unknown) = ^CallSideEffect : ~m0_15
898+
# 222| m0_22(unknown) = Chi : total:m0_15, partial:m0_21
899+
# 222| v0_23(void) = ^IndirectReadSideEffect[-1] : &:r0_18, m0_17
900+
# 222| m0_24(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_18
901+
# 223| r0_25(glval<Constructible>) = VariableAddress[c2] :
902+
# 223| m0_26(Constructible) = Uninitialized[c2] : &:r0_25
903+
# 223| r0_27(glval<unknown>) = FunctionAddress[Constructible] :
904+
# 223| r0_28(int) = Constant[2] :
905+
# 223| v0_29(void) = Call : func:r0_27, this:r0_25, 0:r0_28
906+
# 223| m0_30(unknown) = ^CallSideEffect : ~m0_22
907+
# 223| m0_31(unknown) = Chi : total:m0_22, partial:m0_30
908+
# 223| m0_32(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_25
909+
# 224| r0_33(glval<Constructible>) = VariableAddress[c2] :
910+
# 224| r0_34(glval<unknown>) = FunctionAddress[g] :
911+
# 224| v0_35(void) = Call : func:r0_34, this:r0_33
912+
# 224| m0_36(unknown) = ^CallSideEffect : ~m0_31
913+
# 224| m0_37(unknown) = Chi : total:m0_31, partial:m0_36
914+
# 224| v0_38(void) = ^IndirectReadSideEffect[-1] : &:r0_33, m0_32
915+
# 224| m0_39(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_33
916+
# 225| v0_40(void) = NoOp :
917+
# 219| v0_41(void) = ReturnVoid :
918+
# 219| v0_42(void) = UnmodeledUse : mu*
919+
# 219| v0_43(void) = ExitFunction :

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

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -837,36 +837,38 @@ ssa.cpp:
837837
# 219| mu0_1(unknown) = AliasedDefinition :
838838
# 219| mu0_2(unknown) = UnmodeledDefinition :
839839
# 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[-1] : &: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[-1] : &: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 :
840+
# 220| m0_4(Constructible) = Uninitialized[c] : &:r0_3
841+
# 220| r0_5(glval<unknown>) = FunctionAddress[Constructible] :
842+
# 220| r0_6(int) = Constant[1] :
843+
# 220| v0_7(void) = Call : func:r0_5, this:r0_3, 0:r0_6
844+
# 220| mu0_8(unknown) = ^CallSideEffect : ~mu0_2
845+
# 220| m0_9(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_3
846+
# 221| r0_10(glval<Constructible>) = VariableAddress[c] :
847+
# 221| r0_11(glval<unknown>) = FunctionAddress[g] :
848+
# 221| v0_12(void) = Call : func:r0_11, this:r0_10
849+
# 221| mu0_13(unknown) = ^CallSideEffect : ~mu0_2
850+
# 221| v0_14(void) = ^IndirectReadSideEffect[-1] : &:r0_10, m0_9
851+
# 221| m0_15(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_10
852+
# 222| r0_16(glval<Constructible>) = VariableAddress[c] :
853+
# 222| r0_17(glval<unknown>) = FunctionAddress[g] :
854+
# 222| v0_18(void) = Call : func:r0_17, this:r0_16
855+
# 222| mu0_19(unknown) = ^CallSideEffect : ~mu0_2
856+
# 222| v0_20(void) = ^IndirectReadSideEffect[-1] : &:r0_16, m0_15
857+
# 222| m0_21(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_16
858+
# 223| r0_22(glval<Constructible>) = VariableAddress[c2] :
859+
# 223| m0_23(Constructible) = Uninitialized[c2] : &:r0_22
860+
# 223| r0_24(glval<unknown>) = FunctionAddress[Constructible] :
861+
# 223| r0_25(int) = Constant[2] :
862+
# 223| v0_26(void) = Call : func:r0_24, this:r0_22, 0:r0_25
863+
# 223| mu0_27(unknown) = ^CallSideEffect : ~mu0_2
864+
# 223| m0_28(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_22
865+
# 224| r0_29(glval<Constructible>) = VariableAddress[c2] :
866+
# 224| r0_30(glval<unknown>) = FunctionAddress[g] :
867+
# 224| v0_31(void) = Call : func:r0_30, this:r0_29
868+
# 224| mu0_32(unknown) = ^CallSideEffect : ~mu0_2
869+
# 224| v0_33(void) = ^IndirectReadSideEffect[-1] : &:r0_29, m0_28
870+
# 224| m0_34(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_29
871+
# 225| v0_35(void) = NoOp :
872+
# 219| v0_36(void) = ReturnVoid :
873+
# 219| v0_37(void) = UnmodeledUse : mu*
874+
# 219| v0_38(void) = ExitFunction :

0 commit comments

Comments
 (0)