Skip to content

Commit af4d2f1

Browse files
committed
C++: Add an IR test.
1 parent 0f09198 commit af4d2f1

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22734,6 +22734,25 @@ ir.cpp:
2273422734
# 2552| Type = [Class] ClassWithDestructor
2273522735
# 2552| ValueCategory = xvalue
2273622736
# 2553| getStmt(1): [ReturnStmt] return ...
22737+
# 2555| [TopLevelFunction] void builtin_bitcast(unsigned long)
22738+
# 2555| <params>:
22739+
# 2555| getParameter(0): [Parameter] ul
22740+
# 2555| Type = [LongType] unsigned long
22741+
# 2555| getEntryPoint(): [BlockStmt] { ... }
22742+
# 2556| getStmt(0): [DeclStmt] declaration
22743+
# 2556| getDeclarationEntry(0): [VariableDeclarationEntry] definition of d
22744+
# 2556| Type = [DoubleType] double
22745+
# 2556| getVariable().getInitializer(): [Initializer] initializer for d
22746+
# 2556| getExpr(): [BuiltInBitCast] __builtin_bit_cast
22747+
# 2556| Type = [DoubleType] double
22748+
# 2556| ValueCategory = prvalue
22749+
# 2556| getChild(0): [TypeName] double
22750+
# 2556| Type = [DoubleType] double
22751+
# 2556| ValueCategory = prvalue
22752+
# 2556| getChild(1): [VariableAccess] ul
22753+
# 2556| Type = [LongType] unsigned long
22754+
# 2556| ValueCategory = prvalue(load)
22755+
# 2557| getStmt(1): [ReturnStmt] return ...
2273722756
perf-regression.cpp:
2273822757
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
2273922758
# 4| <params>:

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18351,6 +18351,22 @@ ir.cpp:
1835118351
# 2550| Block 2
1835218352
# 2550| v2550_10(void) = Unreached :
1835318353

18354+
# 2555| void builtin_bitcast(unsigned long)
18355+
# 2555| Block 0
18356+
# 2555| v2555_1(void) = EnterFunction :
18357+
# 2555| m2555_2(unknown) = AliasedDefinition :
18358+
# 2555| m2555_3(unknown) = InitializeNonLocal :
18359+
# 2555| m2555_4(unknown) = Chi : total:m2555_2, partial:m2555_3
18360+
# 2555| r2555_5(glval<unsigned long>) = VariableAddress[ul] :
18361+
# 2555| m2555_6(unsigned long) = InitializeParameter[ul] : &:r2555_5
18362+
# 2556| r2556_1(glval<double>) = VariableAddress[d] :
18363+
# 2556| r2556_2(double) = BuiltIn[__builtin_bit_cast] :
18364+
# 2556| m2556_3(double) = Store[d] : &:r2556_1, r2556_2
18365+
# 2557| v2557_1(void) = NoOp :
18366+
# 2555| v2555_7(void) = ReturnVoid :
18367+
# 2555| v2555_8(void) = AliasedUse : m2555_3
18368+
# 2555| v2555_9(void) = ExitFunction :
18369+
1835418370
perf-regression.cpp:
1835518371
# 6| void Big::Big()
1835618372
# 6| Block 0

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,4 +2552,8 @@ void constexpr_inconsistency(bool b) {
25522552
;
25532553
}
25542554

2555+
void builtin_bitcast(unsigned long ul) {
2556+
double d = __builtin_bit_cast(double, ul);
2557+
}
2558+
25552559
// semmle-extractor-options: -std=c++20 --clang

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ lostReachability
2121
backEdgeCountMismatch
2222
useNotDominatedByDefinition
2323
| ir.cpp:1535:8:1535:8 | Unary | Operand 'Unary' is not dominated by its definition in function '$@'. | ir.cpp:1535:8:1535:8 | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() | void StructuredBindingDataMemberStruct::StructuredBindingDataMemberStruct() |
24+
| ir.cpp:2556:43:2556:44 | Arg(1) | Operand 'Arg(1)' is not dominated by its definition in function '$@'. | ir.cpp:2555:6:2555:20 | void builtin_bitcast(unsigned long) | void builtin_bitcast(unsigned long) |
2425
| try_except.c:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:6:6:6:6 | void f() | void f() |
2526
| try_except.c:13:13:13:13 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:6:6:6:6 | void f() | void f() |
2627
| try_except.c:39:15:39:15 | Left | Operand 'Left' is not dominated by its definition in function '$@'. | try_except.c:32:6:32:6 | void h(int) | void h(int) |

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16693,6 +16693,29 @@ ir.cpp:
1669316693
# 2550| v2550_7(void) = AliasedUse : ~m?
1669416694
# 2550| v2550_8(void) = ExitFunction :
1669516695

16696+
# 2555| void builtin_bitcast(unsigned long)
16697+
# 2555| Block 0
16698+
# 2555| v2555_1(void) = EnterFunction :
16699+
# 2555| mu2555_2(unknown) = AliasedDefinition :
16700+
# 2555| mu2555_3(unknown) = InitializeNonLocal :
16701+
# 2555| r2555_4(glval<unsigned long>) = VariableAddress[ul] :
16702+
# 2555| mu2555_5(unsigned long) = InitializeParameter[ul] : &:r2555_4
16703+
# 2556| r2556_1(glval<double>) = VariableAddress[d] :
16704+
#-----| Goto -> Block 1
16705+
16706+
# 2556| Block 1
16707+
# 2556| r2556_2(double) = BuiltIn[__builtin_bit_cast] : 1:r2556_5
16708+
# 2556| mu2556_3(double) = Store[d] : &:r2556_1, r2556_2
16709+
# 2557| v2557_1(void) = NoOp :
16710+
# 2555| v2555_6(void) = ReturnVoid :
16711+
# 2555| v2555_7(void) = AliasedUse : ~m?
16712+
# 2555| v2555_8(void) = ExitFunction :
16713+
16714+
# 2556| Block 2
16715+
# 2556| r2556_4(glval<unsigned long>) = VariableAddress[ul] :
16716+
# 2556| r2556_5(unsigned long) = Load[ul] : &:r2556_4, ~m?
16717+
#-----| Goto -> Block 1
16718+
1669616719
perf-regression.cpp:
1669716720
# 6| void Big::Big()
1669816721
# 6| Block 0

0 commit comments

Comments
 (0)