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

Skip to content

Commit 31f25c8

Browse files
author
Robert Marsh
committed
C++: primary instrs for constructor side effects
1 parent 86b5e97 commit 31f25c8

9 files changed

Lines changed: 6 additions & 490 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ class TranslatedSideEffects extends TranslatedElement, TTranslatedSideEffects {
352352
none()
353353
}
354354

355+
override Instruction getPrimaryInstructionForSideEffect(InstructionTag tag) {
356+
tag = OnlyInstructionTag() and
357+
result = getTranslatedExpr(expr).getInstruction(CallTag())
358+
}
359+
360+
355361
/**
356362
* Gets the `TranslatedFunction` containing this expression.
357363
*/

cpp/ql/test/library-tests/ir/ir/aliased_ssa_sanity.expected

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,6 @@ missingPhiOperand
99
missingOperandType
1010
duplicateChiOperand
1111
sideEffectWithoutPrimary
12-
| file://:0:0:0:0 | IndirectMayWriteSideEffect: call to PolymorphicBase | Side effect instruction missing primary instruction in function $@ | ir.cpp:849:6:849:16 | IR: DynamicCast | void DynamicCast() |
13-
| file://:0:0:0:0 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
14-
| file://:0:0:0:0 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
15-
| ir.cpp:616:12:616:13 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:615:6:615:18 | IR: DeclareObject | void DeclareObject() |
16-
| ir.cpp:617:15:617:22 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:615:6:615:18 | IR: DeclareObject | void DeclareObject() |
17-
| ir.cpp:619:16:619:30 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:615:6:615:18 | IR: DeclareObject | void DeclareObject() |
18-
| ir.cpp:662:9:662:19 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:658:5:658:5 | IR: C | void C::C() |
19-
| ir.cpp:663:5:663:5 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:658:5:658:5 | IR: C | void C::C() |
20-
| ir.cpp:736:5:736:19 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:724:6:724:13 | IR: TryCatch | void TryCatch(bool) |
21-
| ir.cpp:745:8:745:8 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:745:8:745:8 | IR: Base | void Base::Base(Base const&) |
22-
| ir.cpp:748:10:748:10 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:748:3:748:6 | IR: Base | void Base::Base() |
23-
| ir.cpp:757:12:757:12 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:757:3:757:8 | IR: Middle | void Middle::Middle() |
24-
| ir.cpp:757:12:757:12 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:757:3:757:8 | IR: Middle | void Middle::Middle() |
25-
| ir.cpp:766:13:766:13 | IndirectMayWriteSideEffect: call to Middle | Side effect instruction missing primary instruction in function $@ | ir.cpp:766:3:766:9 | IR: Derived | void Derived::Derived() |
26-
| ir.cpp:766:13:766:13 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:766:3:766:9 | IR: Derived | void Derived::Derived() |
27-
| ir.cpp:775:15:775:15 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:775:3:775:11 | IR: MiddleVB1 | void MiddleVB1::MiddleVB1() |
28-
| ir.cpp:775:15:775:15 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:775:3:775:11 | IR: MiddleVB1 | void MiddleVB1::MiddleVB1() |
29-
| ir.cpp:784:15:784:15 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:784:3:784:11 | IR: MiddleVB2 | void MiddleVB2::MiddleVB2() |
30-
| ir.cpp:784:15:784:15 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:784:3:784:11 | IR: MiddleVB2 | void MiddleVB2::MiddleVB2() |
31-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
32-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to MiddleVB1 | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
33-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to MiddleVB2 | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
34-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
35-
| ir.cpp:800:8:800:8 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
36-
| ir.cpp:801:10:801:10 | IndirectMayWriteSideEffect: call to Middle | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
37-
| ir.cpp:802:11:802:11 | IndirectMayWriteSideEffect: call to Derived | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
38-
| ir.cpp:809:7:809:13 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
39-
| ir.cpp:810:7:810:26 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
40-
| ir.cpp:823:7:823:13 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
41-
| ir.cpp:824:7:824:26 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
42-
| ir.cpp:846:8:846:8 | IndirectMayWriteSideEffect: call to PolymorphicBase | Side effect instruction missing primary instruction in function $@ | ir.cpp:846:8:846:8 | IR: PolymorphicDerived | void PolymorphicDerived::PolymorphicDerived() |
43-
| ir.cpp:851:22:851:22 | IndirectMayWriteSideEffect: call to PolymorphicDerived | Side effect instruction missing primary instruction in function $@ | ir.cpp:849:6:849:16 | IR: DynamicCast | void DynamicCast() |
44-
| ir.cpp:868:3:868:12 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:867:1:867:14 | IR: String | void String::String() |
45-
| ir.cpp:944:3:944:14 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:940:6:940:16 | IR: OperatorNew | void OperatorNew() |
46-
| ir.cpp:945:3:945:27 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:940:6:940:16 | IR: OperatorNew | void OperatorNew() |
47-
| ir.cpp:1036:20:1036:57 | IndirectMayWriteSideEffect: call to (constructor) | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
48-
| ir.cpp:1040:29:1040:66 | IndirectMayWriteSideEffect: call to (constructor) | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
49-
| ir.cpp:1040:30:1040:30 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1040:30:1040:30 | IR: (constructor) | void (void Lambda(int, String const&))::(lambda [] type at line 1040, col. 30)::(constructor)((void Lambda(int, String const&))::(lambda [] type at line 1040, col. 30)&&) |
50-
| ir.cpp:1145:5:1145:19 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1133:6:1133:23 | IR: TryCatchNoCatchAny | void TryCatchNoCatchAny(bool) |
51-
| perf-regression.cpp:10:14:10:20 | IndirectMayWriteSideEffect: call to Big | Side effect instruction missing primary instruction in function $@ | perf-regression.cpp:9:5:9:8 | IR: main | int main() |
5212
instructionWithoutSuccessor
5313
ambiguousSuccessors
5414
unexplainedLoop

cpp/ql/test/library-tests/ir/ir/raw_sanity.expected

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,6 @@ missingPhiOperand
99
missingOperandType
1010
duplicateChiOperand
1111
sideEffectWithoutPrimary
12-
| file://:0:0:0:0 | IndirectMayWriteSideEffect: call to PolymorphicBase | Side effect instruction missing primary instruction in function $@ | ir.cpp:849:6:849:16 | IR: DynamicCast | void DynamicCast() |
13-
| file://:0:0:0:0 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
14-
| file://:0:0:0:0 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
15-
| ir.cpp:616:12:616:13 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:615:6:615:18 | IR: DeclareObject | void DeclareObject() |
16-
| ir.cpp:617:15:617:22 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:615:6:615:18 | IR: DeclareObject | void DeclareObject() |
17-
| ir.cpp:619:16:619:30 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:615:6:615:18 | IR: DeclareObject | void DeclareObject() |
18-
| ir.cpp:662:9:662:19 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:658:5:658:5 | IR: C | void C::C() |
19-
| ir.cpp:663:5:663:5 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:658:5:658:5 | IR: C | void C::C() |
20-
| ir.cpp:731:19:731:47 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:724:6:724:13 | IR: TryCatch | void TryCatch(bool) |
21-
| ir.cpp:736:5:736:19 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:724:6:724:13 | IR: TryCatch | void TryCatch(bool) |
22-
| ir.cpp:745:8:745:8 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:745:8:745:8 | IR: Base | void Base::Base(Base const&) |
23-
| ir.cpp:748:10:748:10 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:748:3:748:6 | IR: Base | void Base::Base() |
24-
| ir.cpp:757:12:757:12 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:757:3:757:8 | IR: Middle | void Middle::Middle() |
25-
| ir.cpp:757:12:757:12 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:757:3:757:8 | IR: Middle | void Middle::Middle() |
26-
| ir.cpp:766:13:766:13 | IndirectMayWriteSideEffect: call to Middle | Side effect instruction missing primary instruction in function $@ | ir.cpp:766:3:766:9 | IR: Derived | void Derived::Derived() |
27-
| ir.cpp:766:13:766:13 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:766:3:766:9 | IR: Derived | void Derived::Derived() |
28-
| ir.cpp:775:15:775:15 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:775:3:775:11 | IR: MiddleVB1 | void MiddleVB1::MiddleVB1() |
29-
| ir.cpp:775:15:775:15 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:775:3:775:11 | IR: MiddleVB1 | void MiddleVB1::MiddleVB1() |
30-
| ir.cpp:784:15:784:15 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:784:3:784:11 | IR: MiddleVB2 | void MiddleVB2::MiddleVB2() |
31-
| ir.cpp:784:15:784:15 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:784:3:784:11 | IR: MiddleVB2 | void MiddleVB2::MiddleVB2() |
32-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
33-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to MiddleVB1 | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
34-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to MiddleVB2 | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
35-
| ir.cpp:793:15:793:15 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:793:3:793:11 | IR: DerivedVB | void DerivedVB::DerivedVB() |
36-
| ir.cpp:800:8:800:8 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
37-
| ir.cpp:801:10:801:10 | IndirectMayWriteSideEffect: call to Middle | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
38-
| ir.cpp:802:11:802:11 | IndirectMayWriteSideEffect: call to Derived | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
39-
| ir.cpp:809:7:809:13 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
40-
| ir.cpp:810:7:810:26 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
41-
| ir.cpp:823:7:823:13 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
42-
| ir.cpp:824:7:824:26 | IndirectMayWriteSideEffect: call to Base | Side effect instruction missing primary instruction in function $@ | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
43-
| ir.cpp:846:8:846:8 | IndirectMayWriteSideEffect: call to PolymorphicBase | Side effect instruction missing primary instruction in function $@ | ir.cpp:846:8:846:8 | IR: PolymorphicDerived | void PolymorphicDerived::PolymorphicDerived() |
44-
| ir.cpp:851:22:851:22 | IndirectMayWriteSideEffect: call to PolymorphicDerived | Side effect instruction missing primary instruction in function $@ | ir.cpp:849:6:849:16 | IR: DynamicCast | void DynamicCast() |
45-
| ir.cpp:868:3:868:12 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:867:1:867:14 | IR: String | void String::String() |
46-
| ir.cpp:944:3:944:14 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:940:6:940:16 | IR: OperatorNew | void OperatorNew() |
47-
| ir.cpp:945:3:945:27 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:940:6:940:16 | IR: OperatorNew | void OperatorNew() |
48-
| ir.cpp:1036:20:1036:57 | IndirectMayWriteSideEffect: call to (constructor) | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
49-
| ir.cpp:1040:29:1040:66 | IndirectMayWriteSideEffect: call to (constructor) | Side effect instruction missing primary instruction in function $@ | ir.cpp:1031:6:1031:11 | IR: Lambda | void Lambda(int, String const&) |
50-
| ir.cpp:1040:30:1040:30 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1040:30:1040:30 | IR: (constructor) | void (void Lambda(int, String const&))::(lambda [] type at line 1040, col. 30)::(constructor)((void Lambda(int, String const&))::(lambda [] type at line 1040, col. 30)&&) |
51-
| ir.cpp:1140:19:1140:47 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1133:6:1133:23 | IR: TryCatchNoCatchAny | void TryCatchNoCatchAny(bool) |
52-
| ir.cpp:1145:5:1145:19 | IndirectMayWriteSideEffect: call to String | Side effect instruction missing primary instruction in function $@ | ir.cpp:1133:6:1133:23 | IR: TryCatchNoCatchAny | void TryCatchNoCatchAny(bool) |
53-
| perf-regression.cpp:10:14:10:20 | IndirectMayWriteSideEffect: call to Big | Side effect instruction missing primary instruction in function $@ | perf-regression.cpp:9:5:9:8 | IR: main | int main() |
5412
instructionWithoutSuccessor
5513
ambiguousSuccessors
5614
unexplainedLoop

0 commit comments

Comments
 (0)