C++: Fix for multiple for-loop variables with destructors

This commit is contained in:
Robert Marsh
2024-02-13 00:40:19 +00:00
parent 6663420d39
commit 7d8872bb99
9 changed files with 29 additions and 7 deletions

View File

@@ -1019,6 +1019,12 @@ class TranslatedForStmt extends TranslatedLoop {
or
child = this.getUpdate() and result = this.getFirstConditionInstruction(kind)
or
exists(int destructorId |
destructorId >= this.getFirstDestructorCallIndex() and
child = this.getChild(destructorId) and
result = this.getChild(destructorId + 1).getFirstInstruction(kind)
)
or
exists(int lastDestructorIndex |
lastDestructorIndex =
max(int n | exists(this.getChild(n)) and n >= this.getFirstDestructorCallIndex()) and

View File

@@ -13085,6 +13085,18 @@ ir.cpp:
# 2161| v2161_47(void) = ^IndirectReadSideEffect[-1] : &:r2161_42, m2161_22
# 2161| m2161_48(String) = ^IndirectMayWriteSideEffect[-1] : &:r2161_42
# 2161| m2161_49(String) = Chi : total:m2161_22, partial:m2161_48
# 2161| r2161_50(glval<String>) = VariableAddress[s] :
# 2161| r2161_51(glval<unknown>) = FunctionAddress[~String] :
# 2161| v2161_52(void) = Call[~String] : func:r2161_51, this:r2161_50
# 2161| m2161_53(unknown) = ^CallSideEffect : ~m2161_46
# 2161| m2161_54(unknown) = Chi : total:m2161_46, partial:m2161_53
# 2161| v2161_55(void) = ^IndirectReadSideEffect[-1] : &:r2161_50, m2161_23
# 2161| m2161_56(String) = ^IndirectMayWriteSideEffect[-1] : &:r2161_50
# 2161| m2161_57(String) = Chi : total:m2161_23, partial:m2161_56
# 2164| v2164_1(void) = NoOp :
# 2151| v2151_5(void) = ReturnVoid :
# 2151| v2151_6(void) = AliasedUse : ~m2161_54
# 2151| v2151_7(void) = ExitFunction :
# 2166| void IfDestructors2(bool)
# 2166| Block 0

View File

@@ -6,7 +6,6 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2161:28:2161:29 | Chi: s2 | Instruction 'Chi: s2' has no successors in function '$@'. | ir.cpp:2151:6:2151:19 | void ForDestructors() | void ForDestructors() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -6,7 +6,6 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2161:28:2161:29 | Chi: s2 | Instruction 'Chi: s2' has no successors in function '$@'. | ir.cpp:2151:6:2151:19 | void ForDestructors() | void ForDestructors() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -10464,6 +10464,7 @@
| ir.cpp:2149:1:2149:1 | SideEffect | ~m2149_6 |
| ir.cpp:2151:6:2151:19 | ChiPartial | partial:m2151_3 |
| ir.cpp:2151:6:2151:19 | ChiTotal | total:m2151_2 |
| ir.cpp:2151:6:2151:19 | SideEffect | ~m2161_54 |
| ir.cpp:2152:10:2152:10 | Address | &:r2152_1 |
| ir.cpp:2152:13:2152:16 | StoreValue | r2152_2 |
| ir.cpp:2153:16:2153:16 | Address | &:r2153_1 |
@@ -10647,7 +10648,17 @@
| ir.cpp:2159:5:2159:5 | SideEffect | ~m2158_6 |
| ir.cpp:2161:16:2161:16 | Address | &:r2161_1 |
| ir.cpp:2161:16:2161:16 | Address | &:r2161_1 |
| ir.cpp:2161:16:2161:16 | Address | &:r2161_50 |
| ir.cpp:2161:16:2161:16 | Address | &:r2161_50 |
| ir.cpp:2161:16:2161:16 | Arg(this) | this:r2161_1 |
| ir.cpp:2161:16:2161:16 | Arg(this) | this:r2161_50 |
| ir.cpp:2161:16:2161:16 | CallTarget | func:r2161_51 |
| ir.cpp:2161:16:2161:16 | ChiPartial | partial:m2161_53 |
| ir.cpp:2161:16:2161:16 | ChiPartial | partial:m2161_56 |
| ir.cpp:2161:16:2161:16 | ChiTotal | total:m2161_23 |
| ir.cpp:2161:16:2161:16 | ChiTotal | total:m2161_46 |
| ir.cpp:2161:16:2161:16 | SideEffect | m2161_23 |
| ir.cpp:2161:16:2161:16 | SideEffect | ~m2161_46 |
| ir.cpp:2161:18:2161:24 | Address | &:r2161_5 |
| ir.cpp:2161:18:2161:24 | Arg(0) | 0:r2161_5 |
| ir.cpp:2161:18:2161:24 | SideEffect | ~m2151_3 |

View File

@@ -6,7 +6,6 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2161:28:2161:29 | IndirectMayWriteSideEffect: s2 | Instruction 'IndirectMayWriteSideEffect: s2' has no successors in function '$@'. | ir.cpp:2151:6:2151:19 | void ForDestructors() | void ForDestructors() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -12182,8 +12182,6 @@ ir.cpp:
# 2161| mu2161_36(unknown) = ^CallSideEffect : ~m?
# 2161| v2161_37(void) = ^IndirectReadSideEffect[-1] : &:r2161_33, ~m?
# 2161| mu2161_38(String) = ^IndirectMayWriteSideEffect[-1] : &:r2161_33
# 2161| Block 10
# 2161| r2161_39(glval<String>) = VariableAddress[s] :
# 2161| r2161_40(glval<unknown>) = FunctionAddress[~String] :
# 2161| v2161_41(void) = Call[~String] : func:r2161_40, this:r2161_39

View File

@@ -6,7 +6,6 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2161:28:2161:29 | IndirectMayWriteSideEffect: s2 | Instruction 'IndirectMayWriteSideEffect: s2' has no successors in function '$@'. | ir.cpp:2151:6:2151:19 | void ForDestructors() | void ForDestructors() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction

View File

@@ -6,7 +6,6 @@ missingOperandType
duplicateChiOperand
sideEffectWithoutPrimary
instructionWithoutSuccessor
| ir.cpp:2161:28:2161:29 | IndirectMayWriteSideEffect: s2 | Instruction 'IndirectMayWriteSideEffect: s2' has no successors in function '$@'. | ir.cpp:2151:6:2151:19 | void ForDestructors() | void ForDestructors() |
ambiguousSuccessors
unexplainedLoop
unnecessaryPhiInstruction