Skip to content

Commit 1d51b61

Browse files
committed
C++: Update tests for handling op bitwise copy in lambda captures
1 parent dea510a commit 1d51b61

8 files changed

+403
-260
lines changed

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

Lines changed: 55 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12981,12 +12981,12 @@ ir.cpp:
1298112981
# 1688| getInitializer(): [ClassAggregateLiteral] {...}
1298212982
# 1688| Type = [Closure,LocalClass] decltype([...](...){...})
1298312983
# 1688| ValueCategory = prvalue
12984-
# 1688| getFieldExpr(obj1): [Literal] Unknown literal
12985-
# 1688| Type = [SpecifiedType] const CapturedLambdaMyObj
12986-
# 1688| ValueCategory = prvalue
12987-
# 1688| getFieldExpr(obj2): [Literal] Unknown literal
12984+
# 1688| getFieldExpr(obj1): [VariableAccess] obj1
12985+
# 1688| Type = [LValueReferenceType] const CapturedLambdaMyObj &
12986+
# 1688| ValueCategory = prvalue(load)
12987+
# 1688| getFieldExpr(obj2): [VariableAccess] obj2
1298812988
# 1688| Type = [Class] CapturedLambdaMyObj
12989-
# 1688| ValueCategory = prvalue
12989+
# 1688| ValueCategory = prvalue(load)
1299012990
# 1688| getFieldExpr(x): [VariableAccess] x
1299112991
# 1688| Type = [IntType] int
1299212992
# 1688| ValueCategory = prvalue(load)
@@ -12996,6 +12996,9 @@ ir.cpp:
1299612996
# 1688| getFieldExpr(z): [VariableAccess] z
1299712997
# 1688| Type = [RValueReferenceType] int &&
1299812998
# 1688| ValueCategory = prvalue(load)
12999+
#-----| getFieldExpr(obj1).getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
13000+
#-----| Type = [SpecifiedType] const CapturedLambdaMyObj
13001+
#-----| ValueCategory = prvalue(load)
1299913002
# 1690| getFieldExpr(y).getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
1300013003
# 1690| Type = [IntType] int
1300113004
# 1690| ValueCategory = prvalue(load)
@@ -13030,12 +13033,18 @@ ir.cpp:
1303013033
# 1689| getInitializer(): [ClassAggregateLiteral] {...}
1303113034
# 1689| Type = [Closure,LocalClass] decltype([...](...){...})
1303213035
# 1689| ValueCategory = prvalue
13033-
# 1689| getFieldExpr(obj1): [Literal] Unknown literal
13036+
# 1689| getFieldExpr(obj1): [PointerFieldAccess] obj1
1303413037
# 1689| Type = [SpecifiedType] const CapturedLambdaMyObj
13035-
# 1689| ValueCategory = prvalue
13036-
# 1689| getFieldExpr(obj2): [Literal] Unknown literal
13038+
# 1689| ValueCategory = prvalue(load)
13039+
# 1689| getQualifier(): [ThisExpr] this
13040+
# 1689| Type = [PointerType] lambda [] type at line 1689, col. 29 *
13041+
# 1689| ValueCategory = prvalue(load)
13042+
# 1689| getFieldExpr(obj2): [PointerFieldAccess] obj2
1303713043
# 1689| Type = [Class] CapturedLambdaMyObj
13038-
# 1689| ValueCategory = prvalue
13044+
# 1689| ValueCategory = prvalue(load)
13045+
# 1689| getQualifier(): [ThisExpr] this
13046+
# 1689| Type = [PointerType] lambda [] type at line 1689, col. 29 *
13047+
# 1689| ValueCategory = prvalue(load)
1303913048
# 1689| getFieldExpr(x): [PointerFieldAccess] x
1304013049
# 1689| Type = [IntType] int
1304113050
# 1689| ValueCategory = prvalue(load)
@@ -13112,9 +13121,12 @@ ir.cpp:
1311213121
# 1702| getInitializer(): [ClassAggregateLiteral] {...}
1311313122
# 1702| Type = [Closure,LocalClass] decltype([...](...){...})
1311413123
# 1702| ValueCategory = prvalue
13115-
# 1702| getFieldExpr((captured this)): [Literal] Unknown literal
13124+
# 1702| getFieldExpr((captured this)): [PointerDereferenceExpr] * ...
1311613125
# 1702| Type = [SpecifiedType] const TrivialLambdaClass
13117-
# 1702| ValueCategory = prvalue
13126+
# 1702| ValueCategory = prvalue(load)
13127+
# 1702| getOperand(): [ThisExpr] this
13128+
# 1702| Type = [SpecifiedType] const TrivialLambdaClass *const
13129+
# 1702| ValueCategory = prvalue(load)
1311813130
# 1709| getStmt(1): [ReturnStmt] return ...
1311913131
# 1702| [CopyAssignmentOperator] (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)& (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator=((void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26) const&)
1312013132
# 1702| <params>:
@@ -13156,9 +13168,12 @@ ir.cpp:
1315613168
# 1705| getInitializer(): [ClassAggregateLiteral] {...}
1315713169
# 1705| Type = [Closure,LocalClass] decltype([...](...){...})
1315813170
# 1705| ValueCategory = prvalue
13159-
# 1705| getFieldExpr((captured this)): [Literal] Unknown literal
13171+
# 1705| getFieldExpr((captured this)): [PointerFieldAccess] (captured this)
1316013172
# 1705| Type = [SpecifiedType] const TrivialLambdaClass
13161-
# 1705| ValueCategory = prvalue
13173+
# 1705| ValueCategory = prvalue(load)
13174+
# 1705| getQualifier(): [ThisExpr] this
13175+
# 1705| Type = [PointerType] lambda [] type at line 1705, col. 30 *
13176+
# 1705| ValueCategory = prvalue(load)
1316213177
# 1708| getStmt(2): [ReturnStmt] return ...
1316313178
# 1705| [CopyAssignmentOperator] (void (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator()() const)::(lambda [] type at line 1705, col. 30)& (void (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator()() const)::(lambda [] type at line 1705, col. 30)::operator=((void (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator()() const)::(lambda [] type at line 1705, col. 30) const&)
1316413179
# 1705| <params>:
@@ -13234,21 +13249,30 @@ ir.cpp:
1323413249
# 1716| getInitializer(): [ClassAggregateLiteral] {...}
1323513250
# 1716| Type = [Closure,LocalClass] decltype([...](...){...})
1323613251
# 1716| ValueCategory = prvalue
13237-
# 1716| getFieldExpr(p1): [Literal] Unknown literal
13238-
# 1716| Type = [Class] TrivialLambdaClass
13239-
# 1716| ValueCategory = prvalue
13240-
# 1716| getFieldExpr(p2): [Literal] Unknown literal
13252+
# 1716| getFieldExpr(p1): [VariableAccess] p1
1324113253
# 1716| Type = [Class] TrivialLambdaClass
13242-
# 1716| ValueCategory = prvalue
13243-
# 1716| getFieldExpr(p3): [Literal] Unknown literal
13244-
# 1716| Type = [Class] TrivialLambdaClass
13245-
# 1716| ValueCategory = prvalue
13246-
# 1716| getFieldExpr(l1): [Literal] Unknown literal
13247-
# 1716| Type = [SpecifiedType] const TrivialLambdaClass
13248-
# 1716| ValueCategory = prvalue
13249-
# 1716| getFieldExpr(l2): [Literal] Unknown literal
13254+
# 1716| ValueCategory = prvalue(load)
13255+
# 1716| getFieldExpr(p2): [VariableAccess] p2
13256+
# 1716| Type = [LValueReferenceType] TrivialLambdaClass &
13257+
# 1716| ValueCategory = prvalue(load)
13258+
# 1716| getFieldExpr(p3): [VariableAccess] p3
13259+
# 1716| Type = [RValueReferenceType] TrivialLambdaClass &&
13260+
# 1716| ValueCategory = prvalue(load)
13261+
# 1716| getFieldExpr(l1): [VariableAccess] l1
1325013262
# 1716| Type = [SpecifiedType] const TrivialLambdaClass
13251-
# 1716| ValueCategory = prvalue
13263+
# 1716| ValueCategory = prvalue(load)
13264+
# 1716| getFieldExpr(l2): [VariableAccess] l2
13265+
# 1716| Type = [LValueReferenceType] const TrivialLambdaClass &
13266+
# 1716| ValueCategory = prvalue(load)
13267+
#-----| getFieldExpr(p2).getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
13268+
#-----| Type = [Class] TrivialLambdaClass
13269+
#-----| ValueCategory = prvalue(load)
13270+
#-----| getFieldExpr(p3).getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
13271+
#-----| Type = [Class] TrivialLambdaClass
13272+
#-----| ValueCategory = prvalue(load)
13273+
#-----| getFieldExpr(l2).getFullyConverted(): [ReferenceDereferenceExpr] (reference dereference)
13274+
#-----| Type = [SpecifiedType] const TrivialLambdaClass
13275+
#-----| ValueCategory = prvalue(load)
1325213276
# 1719| getStmt(3): [ReturnStmt] return ...
1325313277
# 1716| [CopyAssignmentOperator] (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)& (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator=((void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21) const&)
1325413278
# 1716| <params>:
@@ -13277,9 +13301,12 @@ ir.cpp:
1327713301
# 1717| getInitializer(): [ClassAggregateLiteral] {...}
1327813302
# 1717| Type = [Closure,LocalClass] decltype([...](...){...})
1327913303
# 1717| ValueCategory = prvalue
13280-
# 1717| getFieldExpr(p1): [Literal] Unknown literal
13304+
# 1717| getFieldExpr(p1): [PointerFieldAccess] p1
1328113305
# 1717| Type = [Class] TrivialLambdaClass
13282-
# 1717| ValueCategory = prvalue
13306+
# 1717| ValueCategory = prvalue(load)
13307+
# 1717| getQualifier(): [ThisExpr] this
13308+
# 1717| Type = [PointerType] lambda [] type at line 1717, col. 25 *
13309+
# 1717| ValueCategory = prvalue(load)
1328313310
# 1718| getStmt(1): [ReturnStmt] return ...
1328413311
# 1717| [CopyAssignmentOperator] (void (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator()() const)::(lambda [] type at line 1717, col. 25)& (void (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator()() const)::(lambda [] type at line 1717, col. 25)::operator=((void (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator()() const)::(lambda [] type at line 1717, col. 25) const&)
1328513312
# 1717| <params>:

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9-
| ir.cpp:1688:24:1690:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1683:6:1683:20 | void captured_lambda(int, int&, int&&) | void captured_lambda(int, int&, int&&) |
10-
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
11-
| ir.cpp:1702:25:1708:9 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1701:10:1701:10 | void TrivialLambdaClass::m() const | void TrivialLambdaClass::m() const |
12-
| ir.cpp:1705:29:1707:13 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1702:34:1702:34 | void (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator()() const | void (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator()() const |
13-
| ir.cpp:1716:20:1718:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1712:6:1712:21 | void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&) | void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&) |
14-
| ir.cpp:1717:24:1717:31 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1716:42:1716:42 | void (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator()() const | void (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator()() const |
159
ambiguousSuccessors
1610
unexplainedLoop
1711
unnecessaryPhiInstruction

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ missingOperandType
66
duplicateChiOperand
77
sideEffectWithoutPrimary
88
instructionWithoutSuccessor
9-
| ir.cpp:1688:24:1690:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1683:6:1683:20 | void captured_lambda(int, int&, int&&) | void captured_lambda(int, int&, int&&) |
10-
| ir.cpp:1689:28:1689:54 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1688:46:1688:46 | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const | void (void captured_lambda(int, int&, int&&))::(lambda [] type at line 1688, col. 25)::operator()() const |
11-
| ir.cpp:1702:25:1708:9 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1701:10:1701:10 | void TrivialLambdaClass::m() const | void TrivialLambdaClass::m() const |
12-
| ir.cpp:1705:29:1707:13 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1702:34:1702:34 | void (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator()() const | void (void TrivialLambdaClass::m() const)::(lambda [] type at line 1702, col. 26)::operator()() const |
13-
| ir.cpp:1716:20:1718:5 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1712:6:1712:21 | void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&) | void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&) |
14-
| ir.cpp:1717:24:1717:31 | FieldAddress: {...} | Instruction 'FieldAddress: {...}' has no successors in function '$@'. | ir.cpp:1716:42:1716:42 | void (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator()() const | void (void captured_lambda2(TrivialLambdaClass, TrivialLambdaClass&, TrivialLambdaClass&&))::(lambda [] type at line 1716, col. 21)::operator()() const |
159
ambiguousSuccessors
1610
unexplainedLoop
1711
unnecessaryPhiInstruction

0 commit comments

Comments
 (0)