Skip to content

Commit 2076c1c

Browse files
committed
C++: Add an copy of a (slightly modified) syntax-zoo test as an IR test.
1 parent 6ba5f3e commit 2076c1c

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,6 +4351,33 @@ generic.c:
43514351
# 28| Type = [IntType] unsigned int
43524352
# 28| ValueCategory = prvalue
43534353
# 29| getStmt(2): [ReturnStmt] return ...
4354+
ir-not-microsoft.c:
4355+
# 1| [TopLevelFunction] void gnuConditionalOmittedOperand()
4356+
# 1| <params>:
4357+
# 1| getEntryPoint(): [BlockStmt] { ... }
4358+
# 2| getStmt(0): [DeclStmt] declaration
4359+
# 2| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
4360+
# 2| Type = [IntType] int
4361+
# 2| getDeclarationEntry(1): [VariableDeclarationEntry] definition of j
4362+
# 2| Type = [IntType] int
4363+
# 3| getStmt(1): [ExprStmt] ExprStmt
4364+
# 3| getExpr(): [AssignExpr] ... = ...
4365+
# 3| Type = [IntType] int
4366+
# 3| ValueCategory = prvalue
4367+
# 3| getLValue(): [VariableAccess] i
4368+
# 3| Type = [IntType] int
4369+
# 3| ValueCategory = lvalue
4370+
# 3| getRValue(): [ConditionalExpr] ... ? ... : ...
4371+
# 3| Type = [IntType] int
4372+
# 3| ValueCategory = prvalue(load)
4373+
# 3| getCondition(): [VariableAccess] j
4374+
# 3| Type = [IntType] int
4375+
# 3| ValueCategory = prvalue(load)
4376+
# 3| getElse(): [Literal] 2
4377+
# 3| Type = [IntType] int
4378+
# 3| Value = [Literal] 2
4379+
# 3| ValueCategory = prvalue
4380+
# 4| getStmt(2): [ReturnStmt] return ...
43544381
ir.c:
43554382
# 5| [TopLevelFunction] int getX(MyCoords*)
43564383
# 5| <params>:

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,47 @@ generic.c:
30323032
# 26| v26_8(void) = AliasedUse : m26_3
30333033
# 26| v26_9(void) = ExitFunction :
30343034

3035+
ir-not-microsoft.c:
3036+
# 1| void gnuConditionalOmittedOperand()
3037+
# 1| Block 0
3038+
# 1| v1_1(void) = EnterFunction :
3039+
# 1| m1_2(unknown) = AliasedDefinition :
3040+
# 1| m1_3(unknown) = InitializeNonLocal :
3041+
# 1| m1_4(unknown) = Chi : total:m1_2, partial:m1_3
3042+
# 2| r2_1(glval<int>) = VariableAddress[i] :
3043+
# 2| m2_2(int) = Uninitialized[i] : &:r2_1
3044+
# 2| r2_3(glval<int>) = VariableAddress[j] :
3045+
# 2| m2_4(int) = Uninitialized[j] : &:r2_3
3046+
# 3| r3_1(glval<int>) = VariableAddress[j] :
3047+
# 3| r3_2(int) = Load[j] : &:r3_1, m2_4
3048+
# 3| r3_3(int) = Constant[0] :
3049+
# 3| r3_4(bool) = CompareNE : r3_2, r3_3
3050+
# 3| v3_5(void) = ConditionalBranch : r3_4
3051+
#-----| False -> Block 3
3052+
#-----| True -> Block 2
3053+
3054+
# 3| Block 1
3055+
# 3| m3_6(int) = Phi : from 2:m3_12, from 3:m3_15
3056+
# 3| r3_7(glval<int>) = VariableAddress[#temp3:9] :
3057+
# 3| r3_8(int) = Load[#temp3:9] : &:r3_7, m3_6
3058+
# 3| r3_9(glval<int>) = VariableAddress[i] :
3059+
# 3| m3_10(int) = Store[i] : &:r3_9, r3_8
3060+
# 4| v4_1(void) = NoOp :
3061+
# 1| v1_5(void) = ReturnVoid :
3062+
# 1| v1_6(void) = AliasedUse : m1_3
3063+
# 1| v1_7(void) = ExitFunction :
3064+
3065+
# 3| Block 2
3066+
# 3| r3_11(glval<int>) = VariableAddress[#temp3:9] :
3067+
# 3| m3_12(int) = Store[#temp3:9] : &:r3_11, r3_2
3068+
#-----| Goto -> Block 1
3069+
3070+
# 3| Block 3
3071+
# 3| r3_13(int) = Constant[2] :
3072+
# 3| r3_14(glval<int>) = VariableAddress[#temp3:9] :
3073+
# 3| m3_15(int) = Store[#temp3:9] : &:r3_14, r3_13
3074+
#-----| Goto -> Block 1
3075+
30353076
ir.c:
30363077
# 7| void MyCoordsTest(int)
30373078
# 7| Block 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void gnuConditionalOmittedOperand() {
2+
int i, j;
3+
i = j ? : 2;
4+
}

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,6 +2808,45 @@ generic.c:
28082808
# 26| v26_7(void) = AliasedUse : ~m?
28092809
# 26| v26_8(void) = ExitFunction :
28102810

2811+
ir-not-microsoft.c:
2812+
# 1| void gnuConditionalOmittedOperand()
2813+
# 1| Block 0
2814+
# 1| v1_1(void) = EnterFunction :
2815+
# 1| mu1_2(unknown) = AliasedDefinition :
2816+
# 1| mu1_3(unknown) = InitializeNonLocal :
2817+
# 2| r2_1(glval<int>) = VariableAddress[i] :
2818+
# 2| mu2_2(int) = Uninitialized[i] : &:r2_1
2819+
# 2| r2_3(glval<int>) = VariableAddress[j] :
2820+
# 2| mu2_4(int) = Uninitialized[j] : &:r2_3
2821+
# 3| r3_1(glval<int>) = VariableAddress[j] :
2822+
# 3| r3_2(int) = Load[j] : &:r3_1, ~m?
2823+
# 3| r3_3(int) = Constant[0] :
2824+
# 3| r3_4(bool) = CompareNE : r3_2, r3_3
2825+
# 3| v3_5(void) = ConditionalBranch : r3_4
2826+
#-----| False -> Block 3
2827+
#-----| True -> Block 2
2828+
2829+
# 3| Block 1
2830+
# 3| r3_6(glval<int>) = VariableAddress[#temp3:9] :
2831+
# 3| r3_7(int) = Load[#temp3:9] : &:r3_6, ~m?
2832+
# 3| r3_8(glval<int>) = VariableAddress[i] :
2833+
# 3| mu3_9(int) = Store[i] : &:r3_8, r3_7
2834+
# 4| v4_1(void) = NoOp :
2835+
# 1| v1_4(void) = ReturnVoid :
2836+
# 1| v1_5(void) = AliasedUse : ~m?
2837+
# 1| v1_6(void) = ExitFunction :
2838+
2839+
# 3| Block 2
2840+
# 3| r3_10(glval<int>) = VariableAddress[#temp3:9] :
2841+
# 3| mu3_11(int) = Store[#temp3:9] : &:r3_10, r3_2
2842+
#-----| Goto -> Block 1
2843+
2844+
# 3| Block 3
2845+
# 3| r3_12(int) = Constant[2] :
2846+
# 3| r3_13(glval<int>) = VariableAddress[#temp3:9] :
2847+
# 3| mu3_14(int) = Store[#temp3:9] : &:r3_13, r3_12
2848+
#-----| Goto -> Block 1
2849+
28112850
ir.c:
28122851
# 7| void MyCoordsTest(int)
28132852
# 7| Block 0

0 commit comments

Comments
 (0)