Skip to content

Commit 5c905b7

Browse files
committed
C++: Expose block assignment operations in the QL library
1 parent ebf8161 commit 5c905b7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cpp/ql/lib/semmle/code/cpp/exprs/Assignment.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ class AssignExpr extends Assignment, @assignexpr {
4747
override string toString() { result = "... = ..." }
4848
}
4949

50+
/**
51+
* A compiler generated assignment operation that may occur in a compiler generated
52+
* copy/move constructor or assignment operator, and which functions like `memcpy`
53+
* where the size argument is based on the type of the rvalue of the assignment.
54+
*/
55+
class BlockAssignExpr extends Assignment, @blockassignexpr {
56+
override string getOperator() { result = "=" }
57+
58+
override string getAPrimaryQlClass() { result = "BlockAssignExpr" }
59+
60+
/** Gets a textual representation of this assignment. */
61+
override string toString() { result = "... = ..." }
62+
}
63+
5064
/**
5165
* A non-overloaded binary assignment operation other than `=`.
5266
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13985,7 +13985,7 @@ ir.cpp:
1398513985
#-----| Type = [RValueReferenceType] A &&
1398613986
#-----| getEntryPoint(): [BlockStmt] { ... }
1398713987
#-----| getStmt(0): [ExprStmt] ExprStmt
13988-
#-----| getExpr(): (no string representation)
13988+
#-----| getExpr(): [BlockAssignExpr] ... = ...
1398913989
#-----| Type = [VoidType] void
1399013990
#-----| ValueCategory = prvalue
1399113991
#-----| getLValue(): [PointerFieldAccess] e

0 commit comments

Comments
 (0)