Skip to content

Commit ebf8161

Browse files
committed
C++: Add block assignment expression to the database schema
These can under some circumstances be generated by the frontend as part of compiler generated copy constructors and assignment operators.
1 parent e1b1657 commit ebf8161

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ funbind(
13021302

13031303
@assign_op_expr = @assign_arith_expr | @assign_bitwise_expr
13041304

1305-
@assign_expr = @assignexpr | @assign_op_expr
1305+
@assign_expr = @assignexpr | @assign_op_expr | @blockassignexpr
13061306

13071307
/*
13081308
case @allocator.form of
@@ -1660,6 +1660,7 @@ case @expr.kind of
16601660
| 332 = @hasuniqueobjectrepresentations
16611661
| 333 = @builtinbitcast
16621662
| 334 = @builtinshuffle
1663+
| 335 = @blockassignexpr
16631664
;
16641665

16651666
@var_args_expr = @vastartexpr

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13985,6 +13985,24 @@ ir.cpp:
1398513985
#-----| Type = [RValueReferenceType] A &&
1398613986
#-----| getEntryPoint(): [BlockStmt] { ... }
1398713987
#-----| getStmt(0): [ExprStmt] ExprStmt
13988+
#-----| getExpr(): (no string representation)
13989+
#-----| Type = [VoidType] void
13990+
#-----| ValueCategory = prvalue
13991+
#-----| getLValue(): [PointerFieldAccess] e
13992+
#-----| Type = [ArrayType] enum <unnamed>[1]
13993+
#-----| ValueCategory = lvalue
13994+
#-----| getQualifier(): [ThisExpr] this
13995+
#-----| Type = [PointerType] A *
13996+
#-----| ValueCategory = prvalue(load)
13997+
#-----| getRValue(): [ReferenceFieldAccess] e
13998+
#-----| Type = [ArrayType] enum <unnamed>[1]
13999+
#-----| ValueCategory = lvalue
14000+
#-----| getQualifier(): [VariableAccess] (unnamed parameter 0)
14001+
#-----| Type = [RValueReferenceType] A &&
14002+
#-----| ValueCategory = prvalue(load)
14003+
#-----| getQualifier().getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
14004+
#-----| Type = [Class] A
14005+
#-----| ValueCategory = lvalue
1398814006
#-----| getStmt(1): [ReturnStmt] return ...
1398914007
#-----| getExpr(): [PointerDereferenceExpr] * ...
1399014008
#-----| Type = [Class] A

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
99
| ../../../include/memory.h:68:25:68:33 | CopyValue: (reference to) | Instruction 'CopyValue: (reference to)' has no successors in function '$@'. | ../../../include/memory.h:67:5:67:5 | void std::unique_ptr<int, std::default_delete<int>>::~unique_ptr() | void std::unique_ptr<int, std::default_delete<int>>::~unique_ptr() |
10+
| file://:0:0:0:0 | FieldAddress: e | Instruction 'FieldAddress: e' has no successors in function '$@'. | ir.cpp:1834:11:1834:11 | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) |
11+
| file://:0:0:0:0 | FieldAddress: e | Instruction 'FieldAddress: e' has no successors in function '$@'. | ir.cpp:1834:11:1834:11 | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) |
1012
| file://:0:0:0:0 | InitializeIndirection: (unnamed parameter 0) | Instruction 'InitializeIndirection: (unnamed parameter 0)' has no successors in function '$@'. | ir.cpp:1834:11:1834:11 | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) | block_assignment::A& block_assignment::A::operator=(block_assignment::A&&) |
1113
ambiguousSuccessors
1214
unexplainedLoop

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9812,18 +9812,29 @@ ir.cpp:
98129812
#-----| mu0_4(unknown) = InitializeIndirection[(unnamed parameter 0)] : &:r0_3
98139813

98149814
#-----| Block 1
9815-
#-----| r0_5(glval<A &>) = VariableAddress[#return] :
9816-
#-----| r0_6(glval<unknown>) = VariableAddress[#this] :
9817-
#-----| r0_7(A *) = Load[#this] : &:r0_6, ~m?
9818-
#-----| r0_8(glval<A>) = CopyValue : r0_7
9819-
#-----| r0_9(A &) = CopyValue : r0_8
9820-
#-----| mu0_10(A &) = Store[#return] : &:r0_5, r0_9
9821-
# 1834| v1834_8(void) = ReturnIndirection[#this] : &:r1834_6, ~m?
9822-
#-----| v0_11(void) = ReturnIndirection[(unnamed parameter 0)] : &:r0_3, ~m?
9823-
# 1834| r1834_9(glval<A &>) = VariableAddress[#return] :
9824-
# 1834| v1834_10(void) = ReturnValue : &:r1834_9, ~m?
9825-
# 1834| v1834_11(void) = AliasedUse : ~m?
9826-
# 1834| v1834_12(void) = ExitFunction :
9815+
#-----| r0_5(glval<unknown>) = VariableAddress[#this] :
9816+
#-----| r0_6(A *) = Load[#this] : &:r0_5, ~m?
9817+
#-----| r0_7(glval<enum <unnamed>[1]>) = FieldAddress[e] : r0_6
9818+
9819+
#-----| Block 2
9820+
#-----| r0_8(glval<A &&>) = VariableAddress[(unnamed parameter 0)] :
9821+
#-----| r0_9(A &&) = Load[(unnamed parameter 0)] : &:r0_8, ~m?
9822+
#-----| r0_10(glval<A>) = CopyValue : r0_9
9823+
#-----| r0_11(glval<enum <unnamed>[1]>) = FieldAddress[e] : r0_10
9824+
9825+
#-----| Block 3
9826+
#-----| r0_12(glval<A &>) = VariableAddress[#return] :
9827+
#-----| r0_13(glval<unknown>) = VariableAddress[#this] :
9828+
#-----| r0_14(A *) = Load[#this] : &:r0_13, ~m?
9829+
#-----| r0_15(glval<A>) = CopyValue : r0_14
9830+
#-----| r0_16(A &) = CopyValue : r0_15
9831+
#-----| mu0_17(A &) = Store[#return] : &:r0_12, r0_16
9832+
# 1834| v1834_8(void) = ReturnIndirection[#this] : &:r1834_6, ~m?
9833+
#-----| v0_18(void) = ReturnIndirection[(unnamed parameter 0)] : &:r0_3, ~m?
9834+
# 1834| r1834_9(glval<A &>) = VariableAddress[#return] :
9835+
# 1834| v1834_10(void) = ReturnValue : &:r1834_9, ~m?
9836+
# 1834| v1834_11(void) = AliasedUse : ~m?
9837+
# 1834| v1834_12(void) = ExitFunction :
98279838

98289839
# 1839| block_assignment::B& block_assignment::B::operator=(block_assignment::B&&)
98299840
# 1839| Block 0

0 commit comments

Comments
 (0)