From 5f8a3054d126e4c9b04eb72ec43d71bdb0b79079 Mon Sep 17 00:00:00 2001 From: Robert Marsh Date: Fri, 4 Oct 2019 11:25:54 -0700 Subject: [PATCH] C++: add UninitializedInstructions for direct init --- .../internal/TranslatedDeclarationEntry.qll | 3 +- .../ir/ssa/aliased_ssa_ir.expected | 78 ++++++++++--------- .../ir/ssa/unaliased_ssa_ir.expected | 68 ++++++++-------- 3 files changed, 77 insertions(+), 72 deletions(-) diff --git a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll index 1efe8cf9f78..d42c1962660 100644 --- a/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll +++ b/cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedDeclarationEntry.qll @@ -123,7 +123,8 @@ abstract class TranslatedVariableDeclaration extends TranslatedElement, Initiali private predicate hasUninitializedInstruction() { not exists(getInitialization()) or - getInitialization() instanceof TranslatedListInitialization + getInitialization() instanceof TranslatedListInitialization or + getInitialization() instanceof TranslatedConstructorInitialization } } diff --git a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected index be58a43a415..813d7a9bdcd 100644 --- a/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected +++ b/cpp/ql/test/library-tests/ir/ssa/aliased_ssa_ir.expected @@ -877,41 +877,43 @@ ssa.cpp: # 219| m0_1(unknown) = AliasedDefinition : # 219| mu0_2(unknown) = UnmodeledDefinition : # 220| r0_3(glval) = VariableAddress[c] : -# 220| r0_4(glval) = FunctionAddress[Constructible] : -# 220| r0_5(int) = Constant[1] : -# 220| v0_6(void) = Call : func:r0_4, this:r0_3, 0:r0_5 -# 220| m0_7(unknown) = ^CallSideEffect : ~m0_1 -# 220| m0_8(unknown) = Chi : total:m0_1, partial:m0_7 -# 220| m0_9(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_3 -# 221| r0_10(glval) = VariableAddress[c] : -# 221| r0_11(glval) = FunctionAddress[g] : -# 221| v0_12(void) = Call : func:r0_11, this:r0_10 -# 221| m0_13(unknown) = ^CallSideEffect : ~m0_8 -# 221| m0_14(unknown) = Chi : total:m0_8, partial:m0_13 -# 221| v0_15(void) = ^IndirectReadSideEffect[-1] : &:r0_10, m0_9 -# 221| m0_16(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_10 -# 222| r0_17(glval) = VariableAddress[c] : -# 222| r0_18(glval) = FunctionAddress[g] : -# 222| v0_19(void) = Call : func:r0_18, this:r0_17 -# 222| m0_20(unknown) = ^CallSideEffect : ~m0_14 -# 222| m0_21(unknown) = Chi : total:m0_14, partial:m0_20 -# 222| v0_22(void) = ^IndirectReadSideEffect[-1] : &:r0_17, m0_16 -# 222| m0_23(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_17 -# 223| r0_24(glval) = VariableAddress[c2] : -# 223| r0_25(glval) = FunctionAddress[Constructible] : -# 223| r0_26(int) = Constant[2] : -# 223| v0_27(void) = Call : func:r0_25, this:r0_24, 0:r0_26 -# 223| m0_28(unknown) = ^CallSideEffect : ~m0_21 -# 223| m0_29(unknown) = Chi : total:m0_21, partial:m0_28 -# 223| m0_30(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_24 -# 224| r0_31(glval) = VariableAddress[c2] : -# 224| r0_32(glval) = FunctionAddress[g] : -# 224| v0_33(void) = Call : func:r0_32, this:r0_31 -# 224| m0_34(unknown) = ^CallSideEffect : ~m0_29 -# 224| m0_35(unknown) = Chi : total:m0_29, partial:m0_34 -# 224| v0_36(void) = ^IndirectReadSideEffect[-1] : &:r0_31, m0_30 -# 224| m0_37(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_31 -# 225| v0_38(void) = NoOp : -# 219| v0_39(void) = ReturnVoid : -# 219| v0_40(void) = UnmodeledUse : mu* -# 219| v0_41(void) = ExitFunction : +# 220| m0_4(Constructible) = Uninitialized[c] : &:r0_3 +# 220| r0_5(glval) = FunctionAddress[Constructible] : +# 220| r0_6(int) = Constant[1] : +# 220| v0_7(void) = Call : func:r0_5, this:r0_3, 0:r0_6 +# 220| m0_8(unknown) = ^CallSideEffect : ~m0_1 +# 220| m0_9(unknown) = Chi : total:m0_1, partial:m0_8 +# 220| m0_10(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_3 +# 221| r0_11(glval) = VariableAddress[c] : +# 221| r0_12(glval) = FunctionAddress[g] : +# 221| v0_13(void) = Call : func:r0_12, this:r0_11 +# 221| m0_14(unknown) = ^CallSideEffect : ~m0_9 +# 221| m0_15(unknown) = Chi : total:m0_9, partial:m0_14 +# 221| v0_16(void) = ^IndirectReadSideEffect[-1] : &:r0_11, m0_10 +# 221| m0_17(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_11 +# 222| r0_18(glval) = VariableAddress[c] : +# 222| r0_19(glval) = FunctionAddress[g] : +# 222| v0_20(void) = Call : func:r0_19, this:r0_18 +# 222| m0_21(unknown) = ^CallSideEffect : ~m0_15 +# 222| m0_22(unknown) = Chi : total:m0_15, partial:m0_21 +# 222| v0_23(void) = ^IndirectReadSideEffect[-1] : &:r0_18, m0_17 +# 222| m0_24(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_18 +# 223| r0_25(glval) = VariableAddress[c2] : +# 223| m0_26(Constructible) = Uninitialized[c2] : &:r0_25 +# 223| r0_27(glval) = FunctionAddress[Constructible] : +# 223| r0_28(int) = Constant[2] : +# 223| v0_29(void) = Call : func:r0_27, this:r0_25, 0:r0_28 +# 223| m0_30(unknown) = ^CallSideEffect : ~m0_22 +# 223| m0_31(unknown) = Chi : total:m0_22, partial:m0_30 +# 223| m0_32(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_25 +# 224| r0_33(glval) = VariableAddress[c2] : +# 224| r0_34(glval) = FunctionAddress[g] : +# 224| v0_35(void) = Call : func:r0_34, this:r0_33 +# 224| m0_36(unknown) = ^CallSideEffect : ~m0_31 +# 224| m0_37(unknown) = Chi : total:m0_31, partial:m0_36 +# 224| v0_38(void) = ^IndirectReadSideEffect[-1] : &:r0_33, m0_32 +# 224| m0_39(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_33 +# 225| v0_40(void) = NoOp : +# 219| v0_41(void) = ReturnVoid : +# 219| v0_42(void) = UnmodeledUse : mu* +# 219| v0_43(void) = ExitFunction : diff --git a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected index 6006ee38036..029c552f5d5 100644 --- a/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected +++ b/cpp/ql/test/library-tests/ir/ssa/unaliased_ssa_ir.expected @@ -837,36 +837,38 @@ ssa.cpp: # 219| mu0_1(unknown) = AliasedDefinition : # 219| mu0_2(unknown) = UnmodeledDefinition : # 220| r0_3(glval) = VariableAddress[c] : -# 220| r0_4(glval) = FunctionAddress[Constructible] : -# 220| r0_5(int) = Constant[1] : -# 220| v0_6(void) = Call : func:r0_4, this:r0_3, 0:r0_5 -# 220| mu0_7(unknown) = ^CallSideEffect : ~mu0_2 -# 220| m0_8(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_3 -# 221| r0_9(glval) = VariableAddress[c] : -# 221| r0_10(glval) = FunctionAddress[g] : -# 221| v0_11(void) = Call : func:r0_10, this:r0_9 -# 221| mu0_12(unknown) = ^CallSideEffect : ~mu0_2 -# 221| v0_13(void) = ^IndirectReadSideEffect[-1] : &:r0_9, m0_8 -# 221| m0_14(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_9 -# 222| r0_15(glval) = VariableAddress[c] : -# 222| r0_16(glval) = FunctionAddress[g] : -# 222| v0_17(void) = Call : func:r0_16, this:r0_15 -# 222| mu0_18(unknown) = ^CallSideEffect : ~mu0_2 -# 222| v0_19(void) = ^IndirectReadSideEffect[-1] : &:r0_15, m0_14 -# 222| m0_20(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_15 -# 223| r0_21(glval) = VariableAddress[c2] : -# 223| r0_22(glval) = FunctionAddress[Constructible] : -# 223| r0_23(int) = Constant[2] : -# 223| v0_24(void) = Call : func:r0_22, this:r0_21, 0:r0_23 -# 223| mu0_25(unknown) = ^CallSideEffect : ~mu0_2 -# 223| m0_26(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_21 -# 224| r0_27(glval) = VariableAddress[c2] : -# 224| r0_28(glval) = FunctionAddress[g] : -# 224| v0_29(void) = Call : func:r0_28, this:r0_27 -# 224| mu0_30(unknown) = ^CallSideEffect : ~mu0_2 -# 224| v0_31(void) = ^IndirectReadSideEffect[-1] : &:r0_27, m0_26 -# 224| m0_32(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_27 -# 225| v0_33(void) = NoOp : -# 219| v0_34(void) = ReturnVoid : -# 219| v0_35(void) = UnmodeledUse : mu* -# 219| v0_36(void) = ExitFunction : +# 220| m0_4(Constructible) = Uninitialized[c] : &:r0_3 +# 220| r0_5(glval) = FunctionAddress[Constructible] : +# 220| r0_6(int) = Constant[1] : +# 220| v0_7(void) = Call : func:r0_5, this:r0_3, 0:r0_6 +# 220| mu0_8(unknown) = ^CallSideEffect : ~mu0_2 +# 220| m0_9(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_3 +# 221| r0_10(glval) = VariableAddress[c] : +# 221| r0_11(glval) = FunctionAddress[g] : +# 221| v0_12(void) = Call : func:r0_11, this:r0_10 +# 221| mu0_13(unknown) = ^CallSideEffect : ~mu0_2 +# 221| v0_14(void) = ^IndirectReadSideEffect[-1] : &:r0_10, m0_9 +# 221| m0_15(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_10 +# 222| r0_16(glval) = VariableAddress[c] : +# 222| r0_17(glval) = FunctionAddress[g] : +# 222| v0_18(void) = Call : func:r0_17, this:r0_16 +# 222| mu0_19(unknown) = ^CallSideEffect : ~mu0_2 +# 222| v0_20(void) = ^IndirectReadSideEffect[-1] : &:r0_16, m0_15 +# 222| m0_21(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_16 +# 223| r0_22(glval) = VariableAddress[c2] : +# 223| m0_23(Constructible) = Uninitialized[c2] : &:r0_22 +# 223| r0_24(glval) = FunctionAddress[Constructible] : +# 223| r0_25(int) = Constant[2] : +# 223| v0_26(void) = Call : func:r0_24, this:r0_22, 0:r0_25 +# 223| mu0_27(unknown) = ^CallSideEffect : ~mu0_2 +# 223| m0_28(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_22 +# 224| r0_29(glval) = VariableAddress[c2] : +# 224| r0_30(glval) = FunctionAddress[g] : +# 224| v0_31(void) = Call : func:r0_30, this:r0_29 +# 224| mu0_32(unknown) = ^CallSideEffect : ~mu0_2 +# 224| v0_33(void) = ^IndirectReadSideEffect[-1] : &:r0_29, m0_28 +# 224| m0_34(Constructible) = ^IndirectMayWriteSideEffect[-1] : &:r0_29 +# 225| v0_35(void) = NoOp : +# 219| v0_36(void) = ReturnVoid : +# 219| v0_37(void) = UnmodeledUse : mu* +# 219| v0_38(void) = ExitFunction :