diff --git a/cpp/ql/lib/semmle/code/cpp/PrintAST.qll b/cpp/ql/lib/semmle/code/cpp/PrintAST.qll index 88dce1ce0b4d..cfb2632bb8ac 100644 --- a/cpp/ql/lib/semmle/code/cpp/PrintAST.qll +++ b/cpp/ql/lib/semmle/code/cpp/PrintAST.qll @@ -862,7 +862,7 @@ private predicate namedExprChildPredicates(Expr expr, Element ele, string pred) or expr.(DeleteOrDeleteArrayExpr).getDestructorCall() = ele and pred = "getDestructorCall()" or - expr.(DeleteOrDeleteArrayExpr).getExpr() = ele and pred = "getExpr()" + expr.(DeleteOrDeleteArrayExpr).getExprWithReuse() = ele and pred = "getExprWithReuse()" or expr.(DestructorFieldDestruction).getExpr() = ele and pred = "getExpr()" or diff --git a/cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll b/cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll index a41a0b35fc81..9e12f853ba57 100644 --- a/cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll +++ b/cpp/ql/lib/semmle/code/cpp/exprs/Expr.qll @@ -1015,8 +1015,33 @@ class DeleteOrDeleteArrayExpr extends Expr, TDeleteOrDeleteArrayExpr { Expr getExpr() { // If there is a destructor call, the object being deleted is the qualifier // otherwise it is the third child. - result = this.getChild(3) or result = this.getDestructorCall().getQualifier() + exists(Expr exprWithReuse | exprWithReuse = this.getExprWithReuse() | + if not exprWithReuse instanceof ReuseExpr + then result = exprWithReuse + else result = this.getDestructorCall().getQualifier() + ) } + + /** + * Gets the object or array being deleted, and gets a `ReuseExpr` when there + * is a destructor call and the object is also the qualifier of the call. + * + * For example, given: + * ``` + * struct HasDestructor { ~HasDestructor(); }; + * struct PlainOldData { int x, char y; }; + * + * void f(HasDestructor* hasDestructor, PlainOldData* pod) { + * delete hasDestructor; + * delete pod; + * } + * ``` + * This predicate yields a `ReuseExpr` for `delete hasDestructor`, as the + * the deleted expression has a destructor, and that expression is also + * the qualifier of the destructor call. In the case of `delete pod` the + * predicate does not yield a `ReuseExpr`, as there is no destructor call. + */ + Expr getExprWithReuse() { result = this.getChild(3) } } /** @@ -1340,7 +1365,17 @@ class ReuseExpr extends Expr, @reuseexpr { /** * Gets the expression that is being re-used. */ - Expr getReusedExpr() { expr_reuse(underlyingElement(this), unresolveElement(result), _) } + Expr getReusedExpr() { + // In the case of a prvalue, the extractor outputs the expression + // before conversion, but the converted expression is intended. + if this.isPRValueCategory() + then result = this.getBaseReusedExpr().getFullyConverted() + else result = this.getBaseReusedExpr() + } + + private Expr getBaseReusedExpr() { + expr_reuse(underlyingElement(this), unresolveElement(result), _) + } override Type getType() { result = this.getReusedExpr().getType() } diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll index 134b7802fc85..d6ad6b8fde49 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll @@ -150,11 +150,6 @@ private predicate ignoreExprOnly(Expr expr) { or not translateFunction(getEnclosingFunction(expr)) and not Raw::varHasIRFunc(getEnclosingVariable(expr)) - or - exists(DeleteOrDeleteArrayExpr deleteExpr | - // Ignore the destructor call, because the duplicated qualifier breaks control flow. - deleteExpr.getDestructorCall() = expr - ) } /** diff --git a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll index 8684f4e56069..1a668ad6c23a 100644 --- a/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll +++ b/cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll @@ -2245,7 +2245,11 @@ class TranslatedDeleteOrDeleteArrayExpr extends TranslatedNonConstantExpr, Trans final override Type getCallResultType() { result = expr.getType() } - final override TranslatedExpr getQualifier() { none() } + final override TranslatedExpr getQualifier() { + result = getTranslatedExpr(expr.getDestructorCall()) + } + + final override Instruction getQualifierResult() { none() } final override predicate hasArguments() { // All deallocator calls have at least one argument. @@ -2260,7 +2264,7 @@ class TranslatedDeleteOrDeleteArrayExpr extends TranslatedNonConstantExpr, Trans final override TranslatedExpr getArgument(int index) { // The only argument we define is the pointer to be deallocated. index = 0 and - result = getTranslatedExpr(expr.getExpr().getFullyConverted()) + result = getTranslatedExpr(expr.getExprWithReuse().getFullyConverted()) } final override predicate mayThrowException() { diff --git a/cpp/ql/test/examples/expressions/PrintAST.expected b/cpp/ql/test/examples/expressions/PrintAST.expected index 4aefbff5c554..7de95cb8b4a4 100644 --- a/cpp/ql/test/examples/expressions/PrintAST.expected +++ b/cpp/ql/test/examples/expressions/PrintAST.expected @@ -426,11 +426,14 @@ DestructorCall.cpp: # 12| getQualifier(): [VariableAccess] c # 12| Type = [PointerType] C * # 12| ValueCategory = prvalue(load) +# 12| getExprWithReuse(): [ReuseExpr] reuse of c +# 12| Type = [PointerType] C * +# 12| ValueCategory = prvalue # 13| getStmt(1): [ExprStmt] ExprStmt # 13| getExpr(): [DeleteExpr] delete # 13| Type = [VoidType] void # 13| ValueCategory = prvalue -# 13| getExpr(): [VariableAccess] d +# 13| getExprWithReuse(): [VariableAccess] d # 13| Type = [PointerType] D * # 13| ValueCategory = prvalue(load) # 14| getStmt(2): [ReturnStmt] return ... diff --git a/cpp/ql/test/library-tests/compiler_generated/compilerGenerated.expected b/cpp/ql/test/library-tests/compiler_generated/compilerGenerated.expected index f7c1dd25dc5a..b61085ff7c69 100644 --- a/cpp/ql/test/library-tests/compiler_generated/compilerGenerated.expected +++ b/cpp/ql/test/library-tests/compiler_generated/compilerGenerated.expected @@ -14,6 +14,7 @@ | cpp.cpp:10:7:10:7 | operator= | Function | | cpp.cpp:10:7:10:7 | ~MyClass | Function | | cpp.cpp:15:5:15:12 | call to ~MyClass | Expr | +| cpp.cpp:15:12:15:12 | reuse of m | Expr | | cpp.cpp:16:1:16:1 | return ... | Stmt | | file://:0:0:0:0 | operator delete | Function | | file://:0:0:0:0 | operator new | Function | diff --git a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected index 7f667cd61cf5..ea9f82fbf400 100644 --- a/cpp/ql/test/library-tests/ir/ir/PrintAST.expected +++ b/cpp/ql/test/library-tests/ir/ir/PrintAST.expected @@ -9068,11 +9068,11 @@ ir.cpp: # 1016| getExpr(): [DeleteExpr] delete # 1016| Type = [VoidType] void # 1016| ValueCategory = prvalue -# 1016| getExpr(): [Literal] 0 +# 1016| getExprWithReuse(): [Literal] 0 # 1016| Type = [NullPointerType] decltype(nullptr) # 1016| Value = [Literal] 0 # 1016| ValueCategory = prvalue -# 1016| getExpr().getFullyConverted(): [StaticCast] static_cast... +# 1016| getExprWithReuse().getFullyConverted(): [StaticCast] static_cast... # 1016| Conversion = [PointerConversion] pointer conversion # 1016| Type = [IntPointerType] int * # 1016| Value = [StaticCast] 0 @@ -9093,6 +9093,9 @@ ir.cpp: # 1017| Type = [PointerType] String * # 1017| Value = [StaticCast] 0 # 1017| ValueCategory = prvalue +# 1017| getExprWithReuse(): [ReuseExpr] reuse of static_cast... +# 1017| Type = [PointerType] String * +# 1017| ValueCategory = prvalue # 1018| getStmt(2): [ExprStmt] ExprStmt # 1018| getExpr(): [DeleteExpr] delete # 1018| Type = [VoidType] void @@ -9100,11 +9103,11 @@ ir.cpp: # 1018| getDeallocatorCall(): [FunctionCall] call to operator delete # 1018| Type = [VoidType] void # 1018| ValueCategory = prvalue -# 1018| getExpr(): [Literal] 0 +# 1018| getExprWithReuse(): [Literal] 0 # 1018| Type = [NullPointerType] decltype(nullptr) # 1018| Value = [Literal] 0 # 1018| ValueCategory = prvalue -# 1018| getExpr().getFullyConverted(): [StaticCast] static_cast... +# 1018| getExprWithReuse().getFullyConverted(): [StaticCast] static_cast... # 1018| Conversion = [PointerConversion] pointer conversion # 1018| Type = [PointerType] SizedDealloc * # 1018| Value = [StaticCast] 0 @@ -9113,11 +9116,11 @@ ir.cpp: # 1019| getExpr(): [DeleteExpr] delete # 1019| Type = [VoidType] void # 1019| ValueCategory = prvalue -# 1019| getExpr(): [Literal] 0 +# 1019| getExprWithReuse(): [Literal] 0 # 1019| Type = [NullPointerType] decltype(nullptr) # 1019| Value = [Literal] 0 # 1019| ValueCategory = prvalue -# 1019| getExpr().getFullyConverted(): [StaticCast] static_cast... +# 1019| getExprWithReuse().getFullyConverted(): [StaticCast] static_cast... # 1019| Conversion = [PointerConversion] pointer conversion # 1019| Type = [PointerType] Overaligned * # 1019| Value = [StaticCast] 0 @@ -9138,6 +9141,9 @@ ir.cpp: # 1020| Type = [PointerType] PolymorphicBase * # 1020| Value = [StaticCast] 0 # 1020| ValueCategory = prvalue +# 1020| getExprWithReuse(): [ReuseExpr] reuse of static_cast... +# 1020| Type = [PointerType] PolymorphicBase * +# 1020| ValueCategory = prvalue # 1021| getStmt(5): [ReturnStmt] return ... # 1024| [TopLevelFunction] void OperatorDeleteArray() # 1024| : @@ -9146,11 +9152,11 @@ ir.cpp: # 1025| getExpr(): [DeleteArrayExpr] delete[] # 1025| Type = [VoidType] void # 1025| ValueCategory = prvalue -# 1025| getExpr(): [Literal] 0 +# 1025| getExprWithReuse(): [Literal] 0 # 1025| Type = [NullPointerType] decltype(nullptr) # 1025| Value = [Literal] 0 # 1025| ValueCategory = prvalue -# 1025| getExpr().getFullyConverted(): [StaticCast] static_cast... +# 1025| getExprWithReuse().getFullyConverted(): [StaticCast] static_cast... # 1025| Conversion = [PointerConversion] pointer conversion # 1025| Type = [IntPointerType] int * # 1025| Value = [StaticCast] 0 @@ -9171,6 +9177,9 @@ ir.cpp: # 1026| Type = [PointerType] String * # 1026| Value = [StaticCast] 0 # 1026| ValueCategory = prvalue +# 1026| getExprWithReuse(): [ReuseExpr] reuse of static_cast... +# 1026| Type = [PointerType] String * +# 1026| ValueCategory = prvalue # 1027| getStmt(2): [ExprStmt] ExprStmt # 1027| getExpr(): [DeleteArrayExpr] delete[] # 1027| Type = [VoidType] void @@ -9178,11 +9187,11 @@ ir.cpp: # 1027| getDeallocatorCall(): [FunctionCall] call to operator delete[] # 1027| Type = [VoidType] void # 1027| ValueCategory = prvalue -# 1027| getExpr(): [Literal] 0 +# 1027| getExprWithReuse(): [Literal] 0 # 1027| Type = [NullPointerType] decltype(nullptr) # 1027| Value = [Literal] 0 # 1027| ValueCategory = prvalue -# 1027| getExpr().getFullyConverted(): [StaticCast] static_cast... +# 1027| getExprWithReuse().getFullyConverted(): [StaticCast] static_cast... # 1027| Conversion = [PointerConversion] pointer conversion # 1027| Type = [PointerType] SizedDealloc * # 1027| Value = [StaticCast] 0 @@ -9191,11 +9200,11 @@ ir.cpp: # 1028| getExpr(): [DeleteArrayExpr] delete[] # 1028| Type = [VoidType] void # 1028| ValueCategory = prvalue -# 1028| getExpr(): [Literal] 0 +# 1028| getExprWithReuse(): [Literal] 0 # 1028| Type = [NullPointerType] decltype(nullptr) # 1028| Value = [Literal] 0 # 1028| ValueCategory = prvalue -# 1028| getExpr().getFullyConverted(): [StaticCast] static_cast... +# 1028| getExprWithReuse().getFullyConverted(): [StaticCast] static_cast... # 1028| Conversion = [PointerConversion] pointer conversion # 1028| Type = [PointerType] Overaligned * # 1028| Value = [StaticCast] 0 @@ -9216,6 +9225,9 @@ ir.cpp: # 1029| Type = [PointerType] PolymorphicBase * # 1029| Value = [StaticCast] 0 # 1029| ValueCategory = prvalue +# 1029| getExprWithReuse(): [ReuseExpr] reuse of static_cast... +# 1029| Type = [PointerType] PolymorphicBase * +# 1029| ValueCategory = prvalue # 1030| getStmt(5): [ReturnStmt] return ... # 1032| [CopyAssignmentOperator] EmptyStruct& EmptyStruct::operator=(EmptyStruct const&) # 1032| : @@ -16699,7 +16711,7 @@ ir.cpp: # 2085| getExpr(): [DeleteExpr] delete # 2085| Type = [VoidType] void # 2085| ValueCategory = prvalue -# 2085| getExpr(): [VariableAccess] x +# 2085| getExprWithReuse(): [VariableAccess] x # 2085| Type = [IntPointerType] int * # 2085| ValueCategory = prvalue(load) # 2086| getStmt(3): [ReturnStmt] return ... @@ -16783,6 +16795,9 @@ ir.cpp: # 2108| getQualifier(): [VariableAccess] b1 # 2108| Type = [PointerType] Base2 * # 2108| ValueCategory = prvalue(load) +# 2108| getExprWithReuse(): [ReuseExpr] reuse of b1 +# 2108| Type = [PointerType] Base2 * +# 2108| ValueCategory = prvalue # 2110| getStmt(2): [DeclStmt] declaration # 2110| getDeclarationEntry(0): [VariableDeclarationEntry] definition of b2 # 2110| Type = [PointerType] Base2 * @@ -16810,6 +16825,9 @@ ir.cpp: # 2111| getQualifier(): [VariableAccess] b2 # 2111| Type = [PointerType] Base2 * # 2111| ValueCategory = prvalue(load) +# 2111| getExprWithReuse(): [ReuseExpr] reuse of b2 +# 2111| Type = [PointerType] Base2 * +# 2111| ValueCategory = prvalue # 2113| getStmt(4): [DeclStmt] declaration # 2113| getDeclarationEntry(0): [VariableDeclarationEntry] definition of d # 2113| Type = [PointerType] Derived2 * @@ -16833,6 +16851,9 @@ ir.cpp: # 2114| getQualifier(): [VariableAccess] d # 2114| Type = [PointerType] Derived2 * # 2114| ValueCategory = prvalue(load) +# 2114| getExprWithReuse(): [ReuseExpr] reuse of d +# 2114| Type = [PointerType] Derived2 * +# 2114| ValueCategory = prvalue # 2115| getStmt(6): [ReturnStmt] return ... # 2117| [TopLevelFunction] void test_constant_folding_use(int) # 2117| : @@ -17168,7 +17189,7 @@ ir.cpp: # 2176| getExpr(): [DeleteExpr] delete # 2176| Type = [VoidType] void # 2176| ValueCategory = prvalue -# 2176| getExpr(): [ImplicitThisFieldAccess,PointerFieldAccess] x +# 2176| getExprWithReuse(): [ImplicitThisFieldAccess,PointerFieldAccess] x # 2176| Type = [CharPointerType] char * # 2176| ValueCategory = prvalue(load) # 2176| getQualifier(): [ThisExpr] this diff --git a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected index a1e49dce3b15..cb7eb8386d06 100644 --- a/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/aliased_ir.expected @@ -6613,75 +6613,107 @@ ir.cpp: # 1015| void OperatorDelete() # 1015| Block 0 -# 1015| v1015_1(void) = EnterFunction : -# 1015| m1015_2(unknown) = AliasedDefinition : -# 1015| m1015_3(unknown) = InitializeNonLocal : -# 1015| m1015_4(unknown) = Chi : total:m1015_2, partial:m1015_3 -# 1016| r1016_1(glval) = FunctionAddress[operator delete] : -# 1016| r1016_2(int *) = Constant[0] : -# 1016| v1016_3(void) = Call[operator delete] : func:r1016_1, 0:r1016_2 -# 1016| m1016_4(unknown) = ^CallSideEffect : ~m1015_4 -# 1016| m1016_5(unknown) = Chi : total:m1015_4, partial:m1016_4 -# 1017| r1017_1(glval) = FunctionAddress[operator delete] : -# 1017| r1017_2(String *) = Constant[0] : -# 1017| v1017_3(void) = Call[operator delete] : func:r1017_1, 0:r1017_2 -# 1017| m1017_4(unknown) = ^CallSideEffect : ~m1016_5 -# 1017| m1017_5(unknown) = Chi : total:m1016_5, partial:m1017_4 -# 1018| r1018_1(glval) = FunctionAddress[operator delete] : -# 1018| r1018_2(SizedDealloc *) = Constant[0] : -# 1018| v1018_3(void) = Call[operator delete] : func:r1018_1, 0:r1018_2 -# 1018| m1018_4(unknown) = ^CallSideEffect : ~m1017_5 -# 1018| m1018_5(unknown) = Chi : total:m1017_5, partial:m1018_4 -# 1019| r1019_1(glval) = FunctionAddress[operator delete] : -# 1019| r1019_2(Overaligned *) = Constant[0] : -# 1019| v1019_3(void) = Call[operator delete] : func:r1019_1, 0:r1019_2 -# 1019| m1019_4(unknown) = ^CallSideEffect : ~m1018_5 -# 1019| m1019_5(unknown) = Chi : total:m1018_5, partial:m1019_4 -# 1020| r1020_1(glval) = VirtualDeleteFunctionAddress : -# 1020| r1020_2(PolymorphicBase *) = Constant[0] : -# 1020| v1020_3(void) = Call[?] : func:r1020_1, 0:r1020_2 -# 1020| m1020_4(unknown) = ^CallSideEffect : ~m1019_5 -# 1020| m1020_5(unknown) = Chi : total:m1019_5, partial:m1020_4 -# 1021| v1021_1(void) = NoOp : -# 1015| v1015_5(void) = ReturnVoid : -# 1015| v1015_6(void) = AliasedUse : ~m1020_5 -# 1015| v1015_7(void) = ExitFunction : +# 1015| v1015_1(void) = EnterFunction : +# 1015| m1015_2(unknown) = AliasedDefinition : +# 1015| m1015_3(unknown) = InitializeNonLocal : +# 1015| m1015_4(unknown) = Chi : total:m1015_2, partial:m1015_3 +# 1016| r1016_1(glval) = FunctionAddress[operator delete] : +# 1016| r1016_2(int *) = Constant[0] : +# 1016| v1016_3(void) = Call[operator delete] : func:r1016_1, 0:r1016_2 +# 1016| m1016_4(unknown) = ^CallSideEffect : ~m1015_4 +# 1016| m1016_5(unknown) = Chi : total:m1015_4, partial:m1016_4 +# 1017| r1017_1(String *) = Constant[0] : +# 1017| r1017_2(glval) = FunctionAddress[~String] : +# 1017| v1017_3(void) = Call[~String] : func:r1017_2 +# 1017| m1017_4(unknown) = ^CallSideEffect : ~m1016_5 +# 1017| m1017_5(unknown) = Chi : total:m1016_5, partial:m1017_4 +# 1017| v1017_6(void) = ^IndirectReadSideEffect[-1] : &:r1017_1, ~m1017_5 +# 1017| m1017_7(String) = ^IndirectMayWriteSideEffect[-1] : &:r1017_1 +# 1017| m1017_8(unknown) = Chi : total:m1017_5, partial:m1017_7 +# 1017| r1017_9(glval) = FunctionAddress[operator delete] : +# 1017| r1017_10(String *) = CopyValue : r1017_1 +# 1017| v1017_11(void) = Call[operator delete] : func:r1017_9, 0:r1017_10 +# 1017| m1017_12(unknown) = ^CallSideEffect : ~m1017_8 +# 1017| m1017_13(unknown) = Chi : total:m1017_8, partial:m1017_12 +# 1018| r1018_1(glval) = FunctionAddress[operator delete] : +# 1018| r1018_2(SizedDealloc *) = Constant[0] : +# 1018| v1018_3(void) = Call[operator delete] : func:r1018_1, 0:r1018_2 +# 1018| m1018_4(unknown) = ^CallSideEffect : ~m1017_13 +# 1018| m1018_5(unknown) = Chi : total:m1017_13, partial:m1018_4 +# 1019| r1019_1(glval) = FunctionAddress[operator delete] : +# 1019| r1019_2(Overaligned *) = Constant[0] : +# 1019| v1019_3(void) = Call[operator delete] : func:r1019_1, 0:r1019_2 +# 1019| m1019_4(unknown) = ^CallSideEffect : ~m1018_5 +# 1019| m1019_5(unknown) = Chi : total:m1018_5, partial:m1019_4 +# 1020| r1020_1(PolymorphicBase *) = Constant[0] : +# 1020| r1020_2(glval) = FunctionAddress[~PolymorphicBase] : +# 1020| v1020_3(void) = Call[~PolymorphicBase] : func:r1020_2 +# 1020| m1020_4(unknown) = ^CallSideEffect : ~m1019_5 +# 1020| m1020_5(unknown) = Chi : total:m1019_5, partial:m1020_4 +# 1020| v1020_6(void) = ^IndirectReadSideEffect[-1] : &:r1020_1, ~m1020_5 +# 1020| m1020_7(PolymorphicBase) = ^IndirectMayWriteSideEffect[-1] : &:r1020_1 +# 1020| m1020_8(unknown) = Chi : total:m1020_5, partial:m1020_7 +# 1020| r1020_9(glval) = VirtualDeleteFunctionAddress : +# 1020| r1020_10(PolymorphicBase *) = CopyValue : r1020_1 +# 1020| v1020_11(void) = Call[?] : func:r1020_9, 0:r1020_10 +# 1020| m1020_12(unknown) = ^CallSideEffect : ~m1020_8 +# 1020| m1020_13(unknown) = Chi : total:m1020_8, partial:m1020_12 +# 1021| v1021_1(void) = NoOp : +# 1015| v1015_5(void) = ReturnVoid : +# 1015| v1015_6(void) = AliasedUse : ~m1020_13 +# 1015| v1015_7(void) = ExitFunction : # 1024| void OperatorDeleteArray() # 1024| Block 0 -# 1024| v1024_1(void) = EnterFunction : -# 1024| m1024_2(unknown) = AliasedDefinition : -# 1024| m1024_3(unknown) = InitializeNonLocal : -# 1024| m1024_4(unknown) = Chi : total:m1024_2, partial:m1024_3 -# 1025| r1025_1(glval) = FunctionAddress[operator delete[]] : -# 1025| r1025_2(int *) = Constant[0] : -# 1025| v1025_3(void) = Call[operator delete[]] : func:r1025_1, 0:r1025_2 -# 1025| m1025_4(unknown) = ^CallSideEffect : ~m1024_4 -# 1025| m1025_5(unknown) = Chi : total:m1024_4, partial:m1025_4 -# 1026| r1026_1(glval) = FunctionAddress[operator delete[]] : -# 1026| r1026_2(String *) = Constant[0] : -# 1026| v1026_3(void) = Call[operator delete[]] : func:r1026_1, 0:r1026_2 -# 1026| m1026_4(unknown) = ^CallSideEffect : ~m1025_5 -# 1026| m1026_5(unknown) = Chi : total:m1025_5, partial:m1026_4 -# 1027| r1027_1(glval) = FunctionAddress[operator delete[]] : -# 1027| r1027_2(SizedDealloc *) = Constant[0] : -# 1027| v1027_3(void) = Call[operator delete[]] : func:r1027_1, 0:r1027_2 -# 1027| m1027_4(unknown) = ^CallSideEffect : ~m1026_5 -# 1027| m1027_5(unknown) = Chi : total:m1026_5, partial:m1027_4 -# 1028| r1028_1(glval) = FunctionAddress[operator delete[]] : -# 1028| r1028_2(Overaligned *) = Constant[0] : -# 1028| v1028_3(void) = Call[operator delete[]] : func:r1028_1, 0:r1028_2 -# 1028| m1028_4(unknown) = ^CallSideEffect : ~m1027_5 -# 1028| m1028_5(unknown) = Chi : total:m1027_5, partial:m1028_4 -# 1029| r1029_1(glval) = FunctionAddress[operator delete[]] : -# 1029| r1029_2(PolymorphicBase *) = Constant[0] : -# 1029| v1029_3(void) = Call[operator delete[]] : func:r1029_1, 0:r1029_2 -# 1029| m1029_4(unknown) = ^CallSideEffect : ~m1028_5 -# 1029| m1029_5(unknown) = Chi : total:m1028_5, partial:m1029_4 -# 1030| v1030_1(void) = NoOp : -# 1024| v1024_5(void) = ReturnVoid : -# 1024| v1024_6(void) = AliasedUse : ~m1029_5 -# 1024| v1024_7(void) = ExitFunction : +# 1024| v1024_1(void) = EnterFunction : +# 1024| m1024_2(unknown) = AliasedDefinition : +# 1024| m1024_3(unknown) = InitializeNonLocal : +# 1024| m1024_4(unknown) = Chi : total:m1024_2, partial:m1024_3 +# 1025| r1025_1(glval) = FunctionAddress[operator delete[]] : +# 1025| r1025_2(int *) = Constant[0] : +# 1025| v1025_3(void) = Call[operator delete[]] : func:r1025_1, 0:r1025_2 +# 1025| m1025_4(unknown) = ^CallSideEffect : ~m1024_4 +# 1025| m1025_5(unknown) = Chi : total:m1024_4, partial:m1025_4 +# 1026| r1026_1(String *) = Constant[0] : +# 1026| r1026_2(glval) = FunctionAddress[~String] : +# 1026| v1026_3(void) = Call[~String] : func:r1026_2 +# 1026| m1026_4(unknown) = ^CallSideEffect : ~m1025_5 +# 1026| m1026_5(unknown) = Chi : total:m1025_5, partial:m1026_4 +# 1026| v1026_6(void) = ^IndirectReadSideEffect[-1] : &:r1026_1, ~m1026_5 +# 1026| m1026_7(String) = ^IndirectMayWriteSideEffect[-1] : &:r1026_1 +# 1026| m1026_8(unknown) = Chi : total:m1026_5, partial:m1026_7 +# 1026| r1026_9(glval) = FunctionAddress[operator delete[]] : +# 1026| r1026_10(String *) = CopyValue : r1026_1 +# 1026| v1026_11(void) = Call[operator delete[]] : func:r1026_9, 0:r1026_10 +# 1026| m1026_12(unknown) = ^CallSideEffect : ~m1026_8 +# 1026| m1026_13(unknown) = Chi : total:m1026_8, partial:m1026_12 +# 1027| r1027_1(glval) = FunctionAddress[operator delete[]] : +# 1027| r1027_2(SizedDealloc *) = Constant[0] : +# 1027| v1027_3(void) = Call[operator delete[]] : func:r1027_1, 0:r1027_2 +# 1027| m1027_4(unknown) = ^CallSideEffect : ~m1026_13 +# 1027| m1027_5(unknown) = Chi : total:m1026_13, partial:m1027_4 +# 1028| r1028_1(glval) = FunctionAddress[operator delete[]] : +# 1028| r1028_2(Overaligned *) = Constant[0] : +# 1028| v1028_3(void) = Call[operator delete[]] : func:r1028_1, 0:r1028_2 +# 1028| m1028_4(unknown) = ^CallSideEffect : ~m1027_5 +# 1028| m1028_5(unknown) = Chi : total:m1027_5, partial:m1028_4 +# 1029| r1029_1(PolymorphicBase *) = Constant[0] : +# 1029| r1029_2(glval) = FunctionAddress[~PolymorphicBase] : +# 1029| v1029_3(void) = Call[~PolymorphicBase] : func:r1029_2 +# 1029| m1029_4(unknown) = ^CallSideEffect : ~m1028_5 +# 1029| m1029_5(unknown) = Chi : total:m1028_5, partial:m1029_4 +# 1029| v1029_6(void) = ^IndirectReadSideEffect[-1] : &:r1029_1, ~m1029_5 +# 1029| m1029_7(PolymorphicBase) = ^IndirectMayWriteSideEffect[-1] : &:r1029_1 +# 1029| m1029_8(unknown) = Chi : total:m1029_5, partial:m1029_7 +# 1029| r1029_9(glval) = FunctionAddress[operator delete[]] : +# 1029| r1029_10(PolymorphicBase *) = CopyValue : r1029_1 +# 1029| v1029_11(void) = Call[operator delete[]] : func:r1029_9, 0:r1029_10 +# 1029| m1029_12(unknown) = ^CallSideEffect : ~m1029_8 +# 1029| m1029_13(unknown) = Chi : total:m1029_8, partial:m1029_12 +# 1030| v1030_1(void) = NoOp : +# 1024| v1024_5(void) = ReturnVoid : +# 1024| v1024_6(void) = AliasedUse : ~m1029_13 +# 1024| v1024_7(void) = ExitFunction : # 1034| void EmptyStructInit() # 1034| Block 0 @@ -12830,18 +12862,26 @@ ir.cpp: # 2107| m2107_13(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2107_8 # 2107| m2107_14(unknown) = Chi : total:m2107_7, partial:m2107_13 # 2107| m2107_15(Base2 *) = Store[b1] : &:r2107_1, r2107_8 -# 2108| r2108_1(glval) = VirtualDeleteFunctionAddress : -# 2108| r2108_2(glval) = VariableAddress[b1] : -# 2108| r2108_3(Base2 *) = Load[b1] : &:r2108_2, m2107_15 -# 2108| v2108_4(void) = Call[?] : func:r2108_1, 0:r2108_3 +# 2108| r2108_1(glval) = VariableAddress[b1] : +# 2108| r2108_2(Base2 *) = Load[b1] : &:r2108_1, m2107_15 +# 2108| r2108_3(glval) = FunctionAddress[~Base2] : +# 2108| v2108_4(void) = Call[~Base2] : func:r2108_3 # 2108| m2108_5(unknown) = ^CallSideEffect : ~m2107_12 # 2108| m2108_6(unknown) = Chi : total:m2107_12, partial:m2108_5 +# 2108| v2108_7(void) = ^IndirectReadSideEffect[-1] : &:r2108_2, ~m2107_14 +# 2108| m2108_8(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2108_2 +# 2108| m2108_9(unknown) = Chi : total:m2107_14, partial:m2108_8 +# 2108| r2108_10(glval) = VirtualDeleteFunctionAddress : +# 2108| r2108_11(Base2 *) = CopyValue : r2108_1 +# 2108| v2108_12(void) = Call[?] : func:r2108_10, 0:r2108_11 +# 2108| m2108_13(unknown) = ^CallSideEffect : ~m2108_6 +# 2108| m2108_14(unknown) = Chi : total:m2108_6, partial:m2108_13 # 2110| r2110_1(glval) = VariableAddress[b2] : # 2110| r2110_2(glval) = FunctionAddress[operator new] : # 2110| r2110_3(unsigned long) = Constant[16] : # 2110| r2110_4(void *) = Call[operator new] : func:r2110_2, 0:r2110_3 -# 2110| m2110_5(unknown) = ^CallSideEffect : ~m2108_6 -# 2110| m2110_6(unknown) = Chi : total:m2108_6, partial:m2110_5 +# 2110| m2110_5(unknown) = ^CallSideEffect : ~m2108_14 +# 2110| m2110_6(unknown) = Chi : total:m2108_14, partial:m2110_5 # 2110| m2110_7(unknown) = ^InitializeDynamicAllocation : &:r2110_4 # 2110| r2110_8(Derived2 *) = Convert : r2110_4 # 2110| r2110_9(glval) = FunctionAddress[Derived2] : @@ -12852,18 +12892,26 @@ ir.cpp: # 2110| m2110_14(unknown) = Chi : total:m2110_7, partial:m2110_13 # 2110| r2110_15(Base2 *) = ConvertToNonVirtualBase[Derived2 : Base2] : r2110_8 # 2110| m2110_16(Base2 *) = Store[b2] : &:r2110_1, r2110_15 -# 2111| r2111_1(glval) = VirtualDeleteFunctionAddress : -# 2111| r2111_2(glval) = VariableAddress[b2] : -# 2111| r2111_3(Base2 *) = Load[b2] : &:r2111_2, m2110_16 -# 2111| v2111_4(void) = Call[?] : func:r2111_1, 0:r2111_3 +# 2111| r2111_1(glval) = VariableAddress[b2] : +# 2111| r2111_2(Base2 *) = Load[b2] : &:r2111_1, m2110_16 +# 2111| r2111_3(glval) = FunctionAddress[~Base2] : +# 2111| v2111_4(void) = Call[~Base2] : func:r2111_3 # 2111| m2111_5(unknown) = ^CallSideEffect : ~m2110_12 # 2111| m2111_6(unknown) = Chi : total:m2110_12, partial:m2111_5 +# 2111| v2111_7(void) = ^IndirectReadSideEffect[-1] : &:r2111_2, ~m2110_14 +# 2111| m2111_8(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2111_2 +# 2111| m2111_9(unknown) = Chi : total:m2110_14, partial:m2111_8 +# 2111| r2111_10(glval) = VirtualDeleteFunctionAddress : +# 2111| r2111_11(Base2 *) = CopyValue : r2111_1 +# 2111| v2111_12(void) = Call[?] : func:r2111_10, 0:r2111_11 +# 2111| m2111_13(unknown) = ^CallSideEffect : ~m2111_6 +# 2111| m2111_14(unknown) = Chi : total:m2111_6, partial:m2111_13 # 2113| r2113_1(glval) = VariableAddress[d] : # 2113| r2113_2(glval) = FunctionAddress[operator new] : # 2113| r2113_3(unsigned long) = Constant[16] : # 2113| r2113_4(void *) = Call[operator new] : func:r2113_2, 0:r2113_3 -# 2113| m2113_5(unknown) = ^CallSideEffect : ~m2111_6 -# 2113| m2113_6(unknown) = Chi : total:m2111_6, partial:m2113_5 +# 2113| m2113_5(unknown) = ^CallSideEffect : ~m2111_14 +# 2113| m2113_6(unknown) = Chi : total:m2111_14, partial:m2113_5 # 2113| m2113_7(unknown) = ^InitializeDynamicAllocation : &:r2113_4 # 2113| r2113_8(Derived2 *) = Convert : r2113_4 # 2113| r2113_9(glval) = FunctionAddress[Derived2] : @@ -12873,17 +12921,25 @@ ir.cpp: # 2113| m2113_13(Derived2) = ^IndirectMayWriteSideEffect[-1] : &:r2113_8 # 2113| m2113_14(unknown) = Chi : total:m2113_7, partial:m2113_13 # 2113| m2113_15(Derived2 *) = Store[d] : &:r2113_1, r2113_8 -# 2114| r2114_1(glval) = VirtualDeleteFunctionAddress : -# 2114| r2114_2(glval) = VariableAddress[d] : -# 2114| r2114_3(Derived2 *) = Load[d] : &:r2114_2, m2113_15 -# 2114| v2114_4(void) = Call[?] : func:r2114_1, 0:r2114_3 +# 2114| r2114_1(glval) = VariableAddress[d] : +# 2114| r2114_2(Derived2 *) = Load[d] : &:r2114_1, m2113_15 +# 2114| r2114_3(glval) = FunctionAddress[~Derived2] : +# 2114| v2114_4(void) = Call[~Derived2] : func:r2114_3 # 2114| m2114_5(unknown) = ^CallSideEffect : ~m2113_12 # 2114| m2114_6(unknown) = Chi : total:m2113_12, partial:m2114_5 +# 2114| v2114_7(void) = ^IndirectReadSideEffect[-1] : &:r2114_2, ~m2113_14 +# 2114| m2114_8(Derived2) = ^IndirectMayWriteSideEffect[-1] : &:r2114_2 +# 2114| m2114_9(unknown) = Chi : total:m2113_14, partial:m2114_8 +# 2114| r2114_10(glval) = VirtualDeleteFunctionAddress : +# 2114| r2114_11(Derived2 *) = CopyValue : r2114_1 +# 2114| v2114_12(void) = Call[?] : func:r2114_10, 0:r2114_11 +# 2114| m2114_13(unknown) = ^CallSideEffect : ~m2114_6 +# 2114| m2114_14(unknown) = Chi : total:m2114_6, partial:m2114_13 # 2115| r2115_1(glval) = VariableAddress[#return] : # 2115| m2115_2(int) = Uninitialized[#return] : &:r2115_1 # 2105| r2105_5(glval) = VariableAddress[#return] : # 2105| v2105_6(void) = ReturnValue : &:r2105_5, m2115_2 -# 2105| v2105_7(void) = AliasedUse : ~m2114_6 +# 2105| v2105_7(void) = AliasedUse : ~m2114_14 # 2105| v2105_8(void) = ExitFunction : # 2119| void test_constant_folding() diff --git a/cpp/ql/test/library-tests/ir/ir/operand_locations.expected b/cpp/ql/test/library-tests/ir/ir/operand_locations.expected index eaf35e9029ac..80ec181a2194 100644 --- a/cpp/ql/test/library-tests/ir/ir/operand_locations.expected +++ b/cpp/ql/test/library-tests/ir/ir/operand_locations.expected @@ -5654,60 +5654,100 @@ | ir.cpp:1011:12:1011:12 | Unary | r1011_3 | | ir.cpp:1015:6:1015:19 | ChiPartial | partial:m1015_3 | | ir.cpp:1015:6:1015:19 | ChiTotal | total:m1015_2 | -| ir.cpp:1015:6:1015:19 | SideEffect | ~m1020_5 | +| ir.cpp:1015:6:1015:19 | SideEffect | ~m1020_13 | | ir.cpp:1016:3:1016:35 | CallTarget | func:r1016_1 | | ir.cpp:1016:3:1016:35 | ChiPartial | partial:m1016_4 | | ir.cpp:1016:3:1016:35 | ChiTotal | total:m1015_4 | | ir.cpp:1016:3:1016:35 | SideEffect | ~m1015_4 | | ir.cpp:1016:10:1016:35 | Arg(0) | 0:r1016_2 | -| ir.cpp:1017:3:1017:38 | CallTarget | func:r1017_1 | +| ir.cpp:1017:3:1017:38 | CallTarget | func:r1017_2 | +| ir.cpp:1017:3:1017:38 | CallTarget | func:r1017_9 | | ir.cpp:1017:3:1017:38 | ChiPartial | partial:m1017_4 | +| ir.cpp:1017:3:1017:38 | ChiPartial | partial:m1017_12 | | ir.cpp:1017:3:1017:38 | ChiTotal | total:m1016_5 | +| ir.cpp:1017:3:1017:38 | ChiTotal | total:m1017_8 | | ir.cpp:1017:3:1017:38 | SideEffect | ~m1016_5 | -| ir.cpp:1017:10:1017:38 | Arg(0) | 0:r1017_2 | +| ir.cpp:1017:3:1017:38 | SideEffect | ~m1017_8 | +| ir.cpp:1017:10:1017:38 | Address | &:r1017_1 | +| ir.cpp:1017:10:1017:38 | Address | &:r1017_1 | +| ir.cpp:1017:10:1017:38 | Arg(0) | 0:r1017_10 | +| ir.cpp:1017:10:1017:38 | ChiPartial | partial:m1017_7 | +| ir.cpp:1017:10:1017:38 | ChiTotal | total:m1017_5 | +| ir.cpp:1017:10:1017:38 | SideEffect | ~m1017_5 | +| ir.cpp:1017:10:1017:38 | Unary | r1017_1 | | ir.cpp:1018:3:1018:44 | CallTarget | func:r1018_1 | | ir.cpp:1018:3:1018:44 | ChiPartial | partial:m1018_4 | -| ir.cpp:1018:3:1018:44 | ChiTotal | total:m1017_5 | -| ir.cpp:1018:3:1018:44 | SideEffect | ~m1017_5 | +| ir.cpp:1018:3:1018:44 | ChiTotal | total:m1017_13 | +| ir.cpp:1018:3:1018:44 | SideEffect | ~m1017_13 | | ir.cpp:1018:10:1018:44 | Arg(0) | 0:r1018_2 | | ir.cpp:1019:3:1019:43 | CallTarget | func:r1019_1 | | ir.cpp:1019:3:1019:43 | ChiPartial | partial:m1019_4 | | ir.cpp:1019:3:1019:43 | ChiTotal | total:m1018_5 | | ir.cpp:1019:3:1019:43 | SideEffect | ~m1018_5 | | ir.cpp:1019:10:1019:43 | Arg(0) | 0:r1019_2 | -| ir.cpp:1020:3:1020:47 | CallTarget | func:r1020_1 | +| ir.cpp:1020:3:1020:47 | CallTarget | func:r1020_2 | +| ir.cpp:1020:3:1020:47 | CallTarget | func:r1020_9 | | ir.cpp:1020:3:1020:47 | ChiPartial | partial:m1020_4 | +| ir.cpp:1020:3:1020:47 | ChiPartial | partial:m1020_12 | | ir.cpp:1020:3:1020:47 | ChiTotal | total:m1019_5 | +| ir.cpp:1020:3:1020:47 | ChiTotal | total:m1020_8 | | ir.cpp:1020:3:1020:47 | SideEffect | ~m1019_5 | -| ir.cpp:1020:10:1020:47 | Arg(0) | 0:r1020_2 | +| ir.cpp:1020:3:1020:47 | SideEffect | ~m1020_8 | +| ir.cpp:1020:10:1020:47 | Address | &:r1020_1 | +| ir.cpp:1020:10:1020:47 | Address | &:r1020_1 | +| ir.cpp:1020:10:1020:47 | Arg(0) | 0:r1020_10 | +| ir.cpp:1020:10:1020:47 | ChiPartial | partial:m1020_7 | +| ir.cpp:1020:10:1020:47 | ChiTotal | total:m1020_5 | +| ir.cpp:1020:10:1020:47 | SideEffect | ~m1020_5 | +| ir.cpp:1020:10:1020:47 | Unary | r1020_1 | | ir.cpp:1024:6:1024:24 | ChiPartial | partial:m1024_3 | | ir.cpp:1024:6:1024:24 | ChiTotal | total:m1024_2 | -| ir.cpp:1024:6:1024:24 | SideEffect | ~m1029_5 | +| ir.cpp:1024:6:1024:24 | SideEffect | ~m1029_13 | | ir.cpp:1025:3:1025:37 | CallTarget | func:r1025_1 | | ir.cpp:1025:3:1025:37 | ChiPartial | partial:m1025_4 | | ir.cpp:1025:3:1025:37 | ChiTotal | total:m1024_4 | | ir.cpp:1025:3:1025:37 | SideEffect | ~m1024_4 | | ir.cpp:1025:12:1025:37 | Arg(0) | 0:r1025_2 | -| ir.cpp:1026:3:1026:40 | CallTarget | func:r1026_1 | +| ir.cpp:1026:3:1026:40 | CallTarget | func:r1026_2 | +| ir.cpp:1026:3:1026:40 | CallTarget | func:r1026_9 | | ir.cpp:1026:3:1026:40 | ChiPartial | partial:m1026_4 | +| ir.cpp:1026:3:1026:40 | ChiPartial | partial:m1026_12 | | ir.cpp:1026:3:1026:40 | ChiTotal | total:m1025_5 | +| ir.cpp:1026:3:1026:40 | ChiTotal | total:m1026_8 | | ir.cpp:1026:3:1026:40 | SideEffect | ~m1025_5 | -| ir.cpp:1026:12:1026:40 | Arg(0) | 0:r1026_2 | +| ir.cpp:1026:3:1026:40 | SideEffect | ~m1026_8 | +| ir.cpp:1026:12:1026:40 | Address | &:r1026_1 | +| ir.cpp:1026:12:1026:40 | Address | &:r1026_1 | +| ir.cpp:1026:12:1026:40 | Arg(0) | 0:r1026_10 | +| ir.cpp:1026:12:1026:40 | ChiPartial | partial:m1026_7 | +| ir.cpp:1026:12:1026:40 | ChiTotal | total:m1026_5 | +| ir.cpp:1026:12:1026:40 | SideEffect | ~m1026_5 | +| ir.cpp:1026:12:1026:40 | Unary | r1026_1 | | ir.cpp:1027:3:1027:46 | CallTarget | func:r1027_1 | | ir.cpp:1027:3:1027:46 | ChiPartial | partial:m1027_4 | -| ir.cpp:1027:3:1027:46 | ChiTotal | total:m1026_5 | -| ir.cpp:1027:3:1027:46 | SideEffect | ~m1026_5 | +| ir.cpp:1027:3:1027:46 | ChiTotal | total:m1026_13 | +| ir.cpp:1027:3:1027:46 | SideEffect | ~m1026_13 | | ir.cpp:1027:12:1027:46 | Arg(0) | 0:r1027_2 | | ir.cpp:1028:3:1028:45 | CallTarget | func:r1028_1 | | ir.cpp:1028:3:1028:45 | ChiPartial | partial:m1028_4 | | ir.cpp:1028:3:1028:45 | ChiTotal | total:m1027_5 | | ir.cpp:1028:3:1028:45 | SideEffect | ~m1027_5 | | ir.cpp:1028:12:1028:45 | Arg(0) | 0:r1028_2 | -| ir.cpp:1029:3:1029:49 | CallTarget | func:r1029_1 | +| ir.cpp:1029:3:1029:49 | CallTarget | func:r1029_2 | +| ir.cpp:1029:3:1029:49 | CallTarget | func:r1029_9 | | ir.cpp:1029:3:1029:49 | ChiPartial | partial:m1029_4 | +| ir.cpp:1029:3:1029:49 | ChiPartial | partial:m1029_12 | | ir.cpp:1029:3:1029:49 | ChiTotal | total:m1028_5 | +| ir.cpp:1029:3:1029:49 | ChiTotal | total:m1029_8 | | ir.cpp:1029:3:1029:49 | SideEffect | ~m1028_5 | -| ir.cpp:1029:12:1029:49 | Arg(0) | 0:r1029_2 | +| ir.cpp:1029:3:1029:49 | SideEffect | ~m1029_8 | +| ir.cpp:1029:12:1029:49 | Address | &:r1029_1 | +| ir.cpp:1029:12:1029:49 | Address | &:r1029_1 | +| ir.cpp:1029:12:1029:49 | Arg(0) | 0:r1029_10 | +| ir.cpp:1029:12:1029:49 | ChiPartial | partial:m1029_7 | +| ir.cpp:1029:12:1029:49 | ChiTotal | total:m1029_5 | +| ir.cpp:1029:12:1029:49 | SideEffect | ~m1029_5 | +| ir.cpp:1029:12:1029:49 | Unary | r1029_1 | | ir.cpp:1034:6:1034:20 | ChiPartial | partial:m1034_3 | | ir.cpp:1034:6:1034:20 | ChiTotal | total:m1034_2 | | ir.cpp:1034:6:1034:20 | SideEffect | m1034_3 | @@ -10620,7 +10660,7 @@ | ir.cpp:2105:5:2105:18 | ChiPartial | partial:m2105_3 | | ir.cpp:2105:5:2105:18 | ChiTotal | total:m2105_2 | | ir.cpp:2105:5:2105:18 | Load | m2115_2 | -| ir.cpp:2105:5:2105:18 | SideEffect | ~m2114_6 | +| ir.cpp:2105:5:2105:18 | SideEffect | ~m2114_14 | | ir.cpp:2107:12:2107:13 | Address | &:r2107_1 | | ir.cpp:2107:17:2107:27 | Address | &:r2107_4 | | ir.cpp:2107:17:2107:27 | Address | &:r2107_8 | @@ -10638,13 +10678,23 @@ | ir.cpp:2107:17:2107:27 | SideEffect | ~m2107_6 | | ir.cpp:2107:17:2107:27 | StoreValue | r2107_8 | | ir.cpp:2107:17:2107:27 | Unary | r2107_4 | -| ir.cpp:2108:5:2108:13 | CallTarget | func:r2108_1 | +| ir.cpp:2108:5:2108:13 | CallTarget | func:r2108_3 | +| ir.cpp:2108:5:2108:13 | CallTarget | func:r2108_10 | | ir.cpp:2108:5:2108:13 | ChiPartial | partial:m2108_5 | +| ir.cpp:2108:5:2108:13 | ChiPartial | partial:m2108_13 | | ir.cpp:2108:5:2108:13 | ChiTotal | total:m2107_12 | +| ir.cpp:2108:5:2108:13 | ChiTotal | total:m2108_6 | | ir.cpp:2108:5:2108:13 | SideEffect | ~m2107_12 | +| ir.cpp:2108:5:2108:13 | SideEffect | ~m2108_6 | +| ir.cpp:2108:12:2108:13 | Address | &:r2108_1 | | ir.cpp:2108:12:2108:13 | Address | &:r2108_2 | -| ir.cpp:2108:12:2108:13 | Arg(0) | 0:r2108_3 | +| ir.cpp:2108:12:2108:13 | Address | &:r2108_2 | +| ir.cpp:2108:12:2108:13 | Arg(0) | 0:r2108_11 | +| ir.cpp:2108:12:2108:13 | ChiPartial | partial:m2108_8 | +| ir.cpp:2108:12:2108:13 | ChiTotal | total:m2107_14 | | ir.cpp:2108:12:2108:13 | Load | m2107_15 | +| ir.cpp:2108:12:2108:13 | SideEffect | ~m2107_14 | +| ir.cpp:2108:12:2108:13 | Unary | r2108_1 | | ir.cpp:2110:12:2110:13 | Address | &:r2110_1 | | ir.cpp:2110:17:2110:30 | Address | &:r2110_4 | | ir.cpp:2110:17:2110:30 | Address | &:r2110_8 | @@ -10655,21 +10705,31 @@ | ir.cpp:2110:17:2110:30 | ChiPartial | partial:m2110_5 | | ir.cpp:2110:17:2110:30 | ChiPartial | partial:m2110_11 | | ir.cpp:2110:17:2110:30 | ChiPartial | partial:m2110_13 | -| ir.cpp:2110:17:2110:30 | ChiTotal | total:m2108_6 | +| ir.cpp:2110:17:2110:30 | ChiTotal | total:m2108_14 | | ir.cpp:2110:17:2110:30 | ChiTotal | total:m2110_6 | | ir.cpp:2110:17:2110:30 | ChiTotal | total:m2110_7 | -| ir.cpp:2110:17:2110:30 | SideEffect | ~m2108_6 | +| ir.cpp:2110:17:2110:30 | SideEffect | ~m2108_14 | | ir.cpp:2110:17:2110:30 | SideEffect | ~m2110_6 | | ir.cpp:2110:17:2110:30 | StoreValue | r2110_15 | | ir.cpp:2110:17:2110:30 | Unary | r2110_4 | | ir.cpp:2110:17:2110:30 | Unary | r2110_8 | -| ir.cpp:2111:5:2111:13 | CallTarget | func:r2111_1 | +| ir.cpp:2111:5:2111:13 | CallTarget | func:r2111_3 | +| ir.cpp:2111:5:2111:13 | CallTarget | func:r2111_10 | | ir.cpp:2111:5:2111:13 | ChiPartial | partial:m2111_5 | +| ir.cpp:2111:5:2111:13 | ChiPartial | partial:m2111_13 | | ir.cpp:2111:5:2111:13 | ChiTotal | total:m2110_12 | +| ir.cpp:2111:5:2111:13 | ChiTotal | total:m2111_6 | | ir.cpp:2111:5:2111:13 | SideEffect | ~m2110_12 | +| ir.cpp:2111:5:2111:13 | SideEffect | ~m2111_6 | +| ir.cpp:2111:12:2111:13 | Address | &:r2111_1 | +| ir.cpp:2111:12:2111:13 | Address | &:r2111_2 | | ir.cpp:2111:12:2111:13 | Address | &:r2111_2 | -| ir.cpp:2111:12:2111:13 | Arg(0) | 0:r2111_3 | +| ir.cpp:2111:12:2111:13 | Arg(0) | 0:r2111_11 | +| ir.cpp:2111:12:2111:13 | ChiPartial | partial:m2111_8 | +| ir.cpp:2111:12:2111:13 | ChiTotal | total:m2110_14 | | ir.cpp:2111:12:2111:13 | Load | m2110_16 | +| ir.cpp:2111:12:2111:13 | SideEffect | ~m2110_14 | +| ir.cpp:2111:12:2111:13 | Unary | r2111_1 | | ir.cpp:2113:15:2113:15 | Address | &:r2113_1 | | ir.cpp:2113:19:2113:32 | Address | &:r2113_4 | | ir.cpp:2113:19:2113:32 | Address | &:r2113_8 | @@ -10680,20 +10740,30 @@ | ir.cpp:2113:19:2113:32 | ChiPartial | partial:m2113_5 | | ir.cpp:2113:19:2113:32 | ChiPartial | partial:m2113_11 | | ir.cpp:2113:19:2113:32 | ChiPartial | partial:m2113_13 | -| ir.cpp:2113:19:2113:32 | ChiTotal | total:m2111_6 | +| ir.cpp:2113:19:2113:32 | ChiTotal | total:m2111_14 | | ir.cpp:2113:19:2113:32 | ChiTotal | total:m2113_6 | | ir.cpp:2113:19:2113:32 | ChiTotal | total:m2113_7 | -| ir.cpp:2113:19:2113:32 | SideEffect | ~m2111_6 | +| ir.cpp:2113:19:2113:32 | SideEffect | ~m2111_14 | | ir.cpp:2113:19:2113:32 | SideEffect | ~m2113_6 | | ir.cpp:2113:19:2113:32 | StoreValue | r2113_8 | | ir.cpp:2113:19:2113:32 | Unary | r2113_4 | -| ir.cpp:2114:5:2114:12 | CallTarget | func:r2114_1 | +| ir.cpp:2114:5:2114:12 | CallTarget | func:r2114_3 | +| ir.cpp:2114:5:2114:12 | CallTarget | func:r2114_10 | | ir.cpp:2114:5:2114:12 | ChiPartial | partial:m2114_5 | +| ir.cpp:2114:5:2114:12 | ChiPartial | partial:m2114_13 | | ir.cpp:2114:5:2114:12 | ChiTotal | total:m2113_12 | +| ir.cpp:2114:5:2114:12 | ChiTotal | total:m2114_6 | | ir.cpp:2114:5:2114:12 | SideEffect | ~m2113_12 | +| ir.cpp:2114:5:2114:12 | SideEffect | ~m2114_6 | +| ir.cpp:2114:12:2114:12 | Address | &:r2114_1 | +| ir.cpp:2114:12:2114:12 | Address | &:r2114_2 | | ir.cpp:2114:12:2114:12 | Address | &:r2114_2 | -| ir.cpp:2114:12:2114:12 | Arg(0) | 0:r2114_3 | +| ir.cpp:2114:12:2114:12 | Arg(0) | 0:r2114_11 | +| ir.cpp:2114:12:2114:12 | ChiPartial | partial:m2114_8 | +| ir.cpp:2114:12:2114:12 | ChiTotal | total:m2113_14 | | ir.cpp:2114:12:2114:12 | Load | m2113_15 | +| ir.cpp:2114:12:2114:12 | SideEffect | ~m2113_14 | +| ir.cpp:2114:12:2114:12 | Unary | r2114_1 | | ir.cpp:2115:1:2115:1 | Address | &:r2115_1 | | ir.cpp:2119:6:2119:26 | ChiPartial | partial:m2119_3 | | ir.cpp:2119:6:2119:26 | ChiTotal | total:m2119_2 | diff --git a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected index 595eeb47460c..25d6225d77eb 100644 --- a/cpp/ql/test/library-tests/ir/ir/raw_ir.expected +++ b/cpp/ql/test/library-tests/ir/ir/raw_ir.expected @@ -6226,33 +6226,45 @@ ir.cpp: # 1015| void OperatorDelete() # 1015| Block 0 -# 1015| v1015_1(void) = EnterFunction : -# 1015| mu1015_2(unknown) = AliasedDefinition : -# 1015| mu1015_3(unknown) = InitializeNonLocal : -# 1016| r1016_1(glval) = FunctionAddress[operator delete] : -# 1016| r1016_2(int *) = Constant[0] : -# 1016| v1016_3(void) = Call[operator delete] : func:r1016_1, 0:r1016_2 -# 1016| mu1016_4(unknown) = ^CallSideEffect : ~m? -# 1017| r1017_1(glval) = FunctionAddress[operator delete] : -# 1017| r1017_2(String *) = Constant[0] : -# 1017| v1017_3(void) = Call[operator delete] : func:r1017_1, 0:r1017_2 -# 1017| mu1017_4(unknown) = ^CallSideEffect : ~m? -# 1018| r1018_1(glval) = FunctionAddress[operator delete] : -# 1018| r1018_2(SizedDealloc *) = Constant[0] : -# 1018| v1018_3(void) = Call[operator delete] : func:r1018_1, 0:r1018_2 -# 1018| mu1018_4(unknown) = ^CallSideEffect : ~m? -# 1019| r1019_1(glval) = FunctionAddress[operator delete] : -# 1019| r1019_2(Overaligned *) = Constant[0] : -# 1019| v1019_3(void) = Call[operator delete] : func:r1019_1, 0:r1019_2 -# 1019| mu1019_4(unknown) = ^CallSideEffect : ~m? -# 1020| r1020_1(glval) = VirtualDeleteFunctionAddress : -# 1020| r1020_2(PolymorphicBase *) = Constant[0] : -# 1020| v1020_3(void) = Call[?] : func:r1020_1, 0:r1020_2 -# 1020| mu1020_4(unknown) = ^CallSideEffect : ~m? -# 1021| v1021_1(void) = NoOp : -# 1015| v1015_4(void) = ReturnVoid : -# 1015| v1015_5(void) = AliasedUse : ~m? -# 1015| v1015_6(void) = ExitFunction : +# 1015| v1015_1(void) = EnterFunction : +# 1015| mu1015_2(unknown) = AliasedDefinition : +# 1015| mu1015_3(unknown) = InitializeNonLocal : +# 1016| r1016_1(glval) = FunctionAddress[operator delete] : +# 1016| r1016_2(int *) = Constant[0] : +# 1016| v1016_3(void) = Call[operator delete] : func:r1016_1, 0:r1016_2 +# 1016| mu1016_4(unknown) = ^CallSideEffect : ~m? +# 1017| r1017_1(String *) = Constant[0] : +# 1017| r1017_2(glval) = FunctionAddress[~String] : +# 1017| v1017_3(void) = Call[~String] : func:r1017_2 +# 1017| mu1017_4(unknown) = ^CallSideEffect : ~m? +# 1017| v1017_5(void) = ^IndirectReadSideEffect[-1] : &:r1017_1, ~m? +# 1017| mu1017_6(String) = ^IndirectMayWriteSideEffect[-1] : &:r1017_1 +# 1017| r1017_7(glval) = FunctionAddress[operator delete] : +# 1017| r1017_8(String *) = CopyValue : r1017_1 +# 1017| v1017_9(void) = Call[operator delete] : func:r1017_7, 0:r1017_8 +# 1017| mu1017_10(unknown) = ^CallSideEffect : ~m? +# 1018| r1018_1(glval) = FunctionAddress[operator delete] : +# 1018| r1018_2(SizedDealloc *) = Constant[0] : +# 1018| v1018_3(void) = Call[operator delete] : func:r1018_1, 0:r1018_2 +# 1018| mu1018_4(unknown) = ^CallSideEffect : ~m? +# 1019| r1019_1(glval) = FunctionAddress[operator delete] : +# 1019| r1019_2(Overaligned *) = Constant[0] : +# 1019| v1019_3(void) = Call[operator delete] : func:r1019_1, 0:r1019_2 +# 1019| mu1019_4(unknown) = ^CallSideEffect : ~m? +# 1020| r1020_1(PolymorphicBase *) = Constant[0] : +# 1020| r1020_2(glval) = FunctionAddress[~PolymorphicBase] : +# 1020| v1020_3(void) = Call[~PolymorphicBase] : func:r1020_2 +# 1020| mu1020_4(unknown) = ^CallSideEffect : ~m? +# 1020| v1020_5(void) = ^IndirectReadSideEffect[-1] : &:r1020_1, ~m? +# 1020| mu1020_6(PolymorphicBase) = ^IndirectMayWriteSideEffect[-1] : &:r1020_1 +# 1020| r1020_7(glval) = VirtualDeleteFunctionAddress : +# 1020| r1020_8(PolymorphicBase *) = CopyValue : r1020_1 +# 1020| v1020_9(void) = Call[?] : func:r1020_7, 0:r1020_8 +# 1020| mu1020_10(unknown) = ^CallSideEffect : ~m? +# 1021| v1021_1(void) = NoOp : +# 1015| v1015_4(void) = ReturnVoid : +# 1015| v1015_5(void) = AliasedUse : ~m? +# 1015| v1015_6(void) = ExitFunction : # 1024| void OperatorDeleteArray() # 1024| Block 0 @@ -6263,10 +6275,16 @@ ir.cpp: # 1025| r1025_2(int *) = Constant[0] : # 1025| v1025_3(void) = Call[operator delete[]] : func:r1025_1, 0:r1025_2 # 1025| mu1025_4(unknown) = ^CallSideEffect : ~m? -# 1026| r1026_1(glval) = FunctionAddress[operator delete[]] : -# 1026| r1026_2(String *) = Constant[0] : -# 1026| v1026_3(void) = Call[operator delete[]] : func:r1026_1, 0:r1026_2 +# 1026| r1026_1(String *) = Constant[0] : +# 1026| r1026_2(glval) = FunctionAddress[~String] : +# 1026| v1026_3(void) = Call[~String] : func:r1026_2 # 1026| mu1026_4(unknown) = ^CallSideEffect : ~m? +# 1026| v1026_5(void) = ^IndirectReadSideEffect[-1] : &:r1026_1, ~m? +# 1026| mu1026_6(String) = ^IndirectMayWriteSideEffect[-1] : &:r1026_1 +# 1026| r1026_7(glval) = FunctionAddress[operator delete[]] : +# 1026| r1026_8(String *) = CopyValue : r1026_1 +# 1026| v1026_9(void) = Call[operator delete[]] : func:r1026_7, 0:r1026_8 +# 1026| mu1026_10(unknown) = ^CallSideEffect : ~m? # 1027| r1027_1(glval) = FunctionAddress[operator delete[]] : # 1027| r1027_2(SizedDealloc *) = Constant[0] : # 1027| v1027_3(void) = Call[operator delete[]] : func:r1027_1, 0:r1027_2 @@ -6275,10 +6293,16 @@ ir.cpp: # 1028| r1028_2(Overaligned *) = Constant[0] : # 1028| v1028_3(void) = Call[operator delete[]] : func:r1028_1, 0:r1028_2 # 1028| mu1028_4(unknown) = ^CallSideEffect : ~m? -# 1029| r1029_1(glval) = FunctionAddress[operator delete[]] : -# 1029| r1029_2(PolymorphicBase *) = Constant[0] : -# 1029| v1029_3(void) = Call[operator delete[]] : func:r1029_1, 0:r1029_2 +# 1029| r1029_1(PolymorphicBase *) = Constant[0] : +# 1029| r1029_2(glval) = FunctionAddress[~PolymorphicBase] : +# 1029| v1029_3(void) = Call[~PolymorphicBase] : func:r1029_2 # 1029| mu1029_4(unknown) = ^CallSideEffect : ~m? +# 1029| v1029_5(void) = ^IndirectReadSideEffect[-1] : &:r1029_1, ~m? +# 1029| mu1029_6(PolymorphicBase) = ^IndirectMayWriteSideEffect[-1] : &:r1029_1 +# 1029| r1029_7(glval) = FunctionAddress[operator delete[]] : +# 1029| r1029_8(PolymorphicBase *) = CopyValue : r1029_1 +# 1029| v1029_9(void) = Call[operator delete[]] : func:r1029_7, 0:r1029_8 +# 1029| mu1029_10(unknown) = ^CallSideEffect : ~m? # 1030| v1030_1(void) = NoOp : # 1024| v1024_4(void) = ReturnVoid : # 1024| v1024_5(void) = AliasedUse : ~m? @@ -11938,11 +11962,17 @@ ir.cpp: # 2107| mu2107_10(unknown) = ^CallSideEffect : ~m? # 2107| mu2107_11(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2107_7 # 2107| mu2107_12(Base2 *) = Store[b1] : &:r2107_1, r2107_7 -# 2108| r2108_1(glval) = VirtualDeleteFunctionAddress : -# 2108| r2108_2(glval) = VariableAddress[b1] : -# 2108| r2108_3(Base2 *) = Load[b1] : &:r2108_2, ~m? -# 2108| v2108_4(void) = Call[?] : func:r2108_1, 0:r2108_3 +# 2108| r2108_1(glval) = VariableAddress[b1] : +# 2108| r2108_2(Base2 *) = Load[b1] : &:r2108_1, ~m? +# 2108| r2108_3(glval) = FunctionAddress[~Base2] : +# 2108| v2108_4(void) = Call[~Base2] : func:r2108_3 # 2108| mu2108_5(unknown) = ^CallSideEffect : ~m? +# 2108| v2108_6(void) = ^IndirectReadSideEffect[-1] : &:r2108_2, ~m? +# 2108| mu2108_7(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2108_2 +# 2108| r2108_8(glval) = VirtualDeleteFunctionAddress : +# 2108| r2108_9(Base2 *) = CopyValue : r2108_1 +# 2108| v2108_10(void) = Call[?] : func:r2108_8, 0:r2108_9 +# 2108| mu2108_11(unknown) = ^CallSideEffect : ~m? # 2110| r2110_1(glval) = VariableAddress[b2] : # 2110| r2110_2(glval) = FunctionAddress[operator new] : # 2110| r2110_3(unsigned long) = Constant[16] : @@ -11956,11 +11986,17 @@ ir.cpp: # 2110| mu2110_11(Derived2) = ^IndirectMayWriteSideEffect[-1] : &:r2110_7 # 2110| r2110_12(Base2 *) = ConvertToNonVirtualBase[Derived2 : Base2] : r2110_7 # 2110| mu2110_13(Base2 *) = Store[b2] : &:r2110_1, r2110_12 -# 2111| r2111_1(glval) = VirtualDeleteFunctionAddress : -# 2111| r2111_2(glval) = VariableAddress[b2] : -# 2111| r2111_3(Base2 *) = Load[b2] : &:r2111_2, ~m? -# 2111| v2111_4(void) = Call[?] : func:r2111_1, 0:r2111_3 +# 2111| r2111_1(glval) = VariableAddress[b2] : +# 2111| r2111_2(Base2 *) = Load[b2] : &:r2111_1, ~m? +# 2111| r2111_3(glval) = FunctionAddress[~Base2] : +# 2111| v2111_4(void) = Call[~Base2] : func:r2111_3 # 2111| mu2111_5(unknown) = ^CallSideEffect : ~m? +# 2111| v2111_6(void) = ^IndirectReadSideEffect[-1] : &:r2111_2, ~m? +# 2111| mu2111_7(Base2) = ^IndirectMayWriteSideEffect[-1] : &:r2111_2 +# 2111| r2111_8(glval) = VirtualDeleteFunctionAddress : +# 2111| r2111_9(Base2 *) = CopyValue : r2111_1 +# 2111| v2111_10(void) = Call[?] : func:r2111_8, 0:r2111_9 +# 2111| mu2111_11(unknown) = ^CallSideEffect : ~m? # 2113| r2113_1(glval) = VariableAddress[d] : # 2113| r2113_2(glval) = FunctionAddress[operator new] : # 2113| r2113_3(unsigned long) = Constant[16] : @@ -11973,11 +12009,17 @@ ir.cpp: # 2113| mu2113_10(unknown) = ^CallSideEffect : ~m? # 2113| mu2113_11(Derived2) = ^IndirectMayWriteSideEffect[-1] : &:r2113_7 # 2113| mu2113_12(Derived2 *) = Store[d] : &:r2113_1, r2113_7 -# 2114| r2114_1(glval) = VirtualDeleteFunctionAddress : -# 2114| r2114_2(glval) = VariableAddress[d] : -# 2114| r2114_3(Derived2 *) = Load[d] : &:r2114_2, ~m? -# 2114| v2114_4(void) = Call[?] : func:r2114_1, 0:r2114_3 +# 2114| r2114_1(glval) = VariableAddress[d] : +# 2114| r2114_2(Derived2 *) = Load[d] : &:r2114_1, ~m? +# 2114| r2114_3(glval) = FunctionAddress[~Derived2] : +# 2114| v2114_4(void) = Call[~Derived2] : func:r2114_3 # 2114| mu2114_5(unknown) = ^CallSideEffect : ~m? +# 2114| v2114_6(void) = ^IndirectReadSideEffect[-1] : &:r2114_2, ~m? +# 2114| mu2114_7(Derived2) = ^IndirectMayWriteSideEffect[-1] : &:r2114_2 +# 2114| r2114_8(glval) = VirtualDeleteFunctionAddress : +# 2114| r2114_9(Derived2 *) = CopyValue : r2114_1 +# 2114| v2114_10(void) = Call[?] : func:r2114_8, 0:r2114_9 +# 2114| mu2114_11(unknown) = ^CallSideEffect : ~m? # 2115| r2115_1(glval) = VariableAddress[#return] : # 2115| mu2115_2(int) = Uninitialized[#return] : &:r2115_1 # 2105| r2105_4(glval) = VariableAddress[#return] :