Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b90bc96

Browse files
author
AndreiDiaconu1
committed
Objects tests and fix in PrintIR
Added tests to showcase the instructions generated for object creation and object initialization Updated raw_ir.expected PrintIR now uses the qualified name (with types) when printing the IR for more clarity
1 parent 8661074 commit b90bc96

2 files changed

Lines changed: 124 additions & 70 deletions

File tree

File renamed without changes.

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

Lines changed: 124 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
array.cs:
2-
# 2| one_dim_init_acc
2+
# 2| ArrayTest.one_dim_init_acc()
33
# 2| Block 0
44
# 2| v0_0(Void) = EnterFunction :
55
# 2| mu0_1(Object) = AliasedDefinition :
@@ -45,7 +45,7 @@ array.cs:
4545
# 2| v0_41(Void) = UnmodeledUse : mu*
4646
# 2| v0_42(Void) = ExitFunction :
4747

48-
# 9| twod_and_init_acc
48+
# 9| ArrayTest.twod_and_init_acc()
4949
# 9| Block 0
5050
# 9| v0_0(Void) = EnterFunction :
5151
# 9| mu0_1(Object) = AliasedDefinition :
@@ -136,7 +136,7 @@ array.cs:
136136
# 9| v0_86(Void) = ExitFunction :
137137

138138
func_with_param_call.cs:
139-
# 4| f
139+
# 4| test_call_with_param.f(int, int)
140140
# 4| Block 0
141141
# 4| v0_0(Void) = EnterFunction :
142142
# 4| mu0_1(null) = AliasedDefinition :
@@ -158,7 +158,7 @@ func_with_param_call.cs:
158158
# 4| v0_17(Void) = UnmodeledUse : mu*
159159
# 4| v0_18(Void) = ExitFunction :
160160

161-
# 8| g
161+
# 8| test_call_with_param.g()
162162
# 8| Block 0
163163
# 8| v0_0(Void) = EnterFunction :
164164
# 8| mu0_1(null) = AliasedDefinition :
@@ -176,8 +176,68 @@ func_with_param_call.cs:
176176
# 8| v0_13(Void) = UnmodeledUse : mu*
177177
# 8| v0_14(Void) = ExitFunction :
178178

179+
obj_creation.cs:
180+
# 5| ObjCreation.MyClass.MyClass()
181+
# 5| Block 0
182+
# 5| v0_0(Void) = EnterFunction :
183+
# 5| mu0_1(Object) = AliasedDefinition :
184+
# 5| mu0_2(Object) = UnmodeledDefinition :
185+
# 5| r0_3(lval<MyClass>) = InitializeThis :
186+
# 5| v0_4(Void) = NoOp :
187+
# 5| v0_5(Void) = ReturnVoid :
188+
# 5| v0_6(Void) = UnmodeledUse : mu*
189+
# 5| v0_7(Void) = ExitFunction :
190+
191+
# 8| ObjCreation.MyClass.MyClass(int)
192+
# 8| Block 0
193+
# 8| v0_0(Void) = EnterFunction :
194+
# 8| mu0_1(Object) = AliasedDefinition :
195+
# 8| mu0_2(Object) = UnmodeledDefinition :
196+
# 8| r0_3(lval<MyClass>) = InitializeThis :
197+
# 8| r0_4(lval<Int32>) = VariableAddress[_x] :
198+
# 8| mu0_5(Int32) = InitializeParameter[_x] : &:r0_4
199+
# 9| r0_6(lval<Int32>) = VariableAddress[_x] :
200+
# 9| r0_7(Int32) = Load : &:r0_6, ~mu0_2
201+
# 9| r0_8(MyClass) = CopyValue : r0_3
202+
# 9| r0_9(lval<Int32>) = FieldAddress[x] : r0_8
203+
# 9| mu0_10(Int32) = Store : &:r0_9, r0_7
204+
# 8| v0_11(Void) = ReturnVoid :
205+
# 8| v0_12(Void) = UnmodeledUse : mu*
206+
# 8| v0_13(Void) = ExitFunction :
207+
208+
# 13| ObjCreation.Main()
209+
# 13| Block 0
210+
# 13| v0_0(Void) = EnterFunction :
211+
# 13| mu0_1(Object) = AliasedDefinition :
212+
# 13| mu0_2(Object) = UnmodeledDefinition :
213+
# 13| r0_3(lval<ObjCreation>) = InitializeThis :
214+
# 14| r0_4(lval<MyClass>) = VariableAddress[obj] :
215+
# 14| r0_5(MyClass) = NewObj :
216+
# 14| r0_6(lval<MyClass>) = FunctionAddress[MyClass] :
217+
# 14| r0_7(Int32) = Constant[100] :
218+
# 14| r0_8(MyClass) = Call : func:r0_6, this:r0_5, 0:r0_7
219+
# 14| v0_9(Void) = ^CallSideEffect : ~mu0_2
220+
# 14| mu0_10(MyClass) = Store : &:r0_4, r0_5
221+
# 15| r0_11(lval<MyClass>) = VariableAddress[obj_initlist] :
222+
# 15| r0_12(MyClass) = NewObj :
223+
# 15| r0_13(lval<MyClass>) = FunctionAddress[MyClass] :
224+
# 15| r0_14(MyClass) = Call : func:r0_13, this:r0_12
225+
# 15| v0_15(Void) = ^CallSideEffect : ~mu0_2
226+
# 15| r0_16(Int32) = Constant[101] :
227+
# 15| r0_17(lval<Int32>) = FieldAddress[x] : r0_12
228+
# 15| mu0_18(Int32) = Store : &:r0_17, r0_16
229+
# 15| mu0_19(MyClass) = Store : &:r0_11, r0_12
230+
# 16| r0_20(lval<Int32>) = VariableAddress[a] :
231+
# 16| r0_21(lval<MyClass>) = VariableAddress[obj] :
232+
# 16| r0_22(lval<Int32>) = FieldAddress[x] : r0_21
233+
# 16| r0_23(Int32) = Load : &:r0_22, ~mu0_2
234+
# 16| mu0_24(Int32) = Store : &:r0_20, r0_23
235+
# 13| v0_25(Void) = ReturnVoid :
236+
# 13| v0_26(Void) = UnmodeledUse : mu*
237+
# 13| v0_27(Void) = ExitFunction :
238+
179239
simple_call.cs:
180-
# 4| f
240+
# 4| test_simple_call.f()
181241
# 4| Block 0
182242
# 4| v0_0(Void) = EnterFunction :
183243
# 4| mu0_1(null) = AliasedDefinition :
@@ -191,7 +251,7 @@ simple_call.cs:
191251
# 4| v0_9(Void) = UnmodeledUse : mu*
192252
# 4| v0_10(Void) = ExitFunction :
193253

194-
# 8| g
254+
# 8| test_simple_call.g()
195255
# 8| Block 0
196256
# 8| v0_0(Void) = EnterFunction :
197257
# 8| mu0_1(null) = AliasedDefinition :
@@ -208,7 +268,7 @@ simple_call.cs:
208268
# 8| v0_12(Void) = ExitFunction :
209269

210270
simple_function.cs:
211-
# 4| f
271+
# 4| test_simple_function.f()
212272
# 4| Block 0
213273
# 4| v0_0(Void) = EnterFunction :
214274
# 4| mu0_1(null) = AliasedDefinition :
@@ -223,7 +283,7 @@ simple_function.cs:
223283
# 4| v0_10(Void) = ExitFunction :
224284

225285
stmts.cs:
226-
# 4| test_if
286+
# 4| test_stmts.test_if(int)
227287
# 4| Block 0
228288
# 4| v0_0(Void) = EnterFunction :
229289
# 4| mu0_1(Object) = AliasedDefinition :
@@ -257,7 +317,7 @@ stmts.cs:
257317
# 6| mu3_2(Int32) = Store : &:r3_0, r3_1
258318
#-----| Goto -> Block 1
259319

260-
# 11| test_while
320+
# 11| test_stmts.test_while(int)
261321
# 11| Block 0
262322
# 11| v0_0(Void) = EnterFunction :
263323
# 11| mu0_1(Object) = AliasedDefinition :
@@ -293,7 +353,7 @@ stmts.cs:
293353
# 14| mu3_5(Int32) = Store : &:r3_4, r3_3
294354
#-----| Goto (back edge) -> Block 2
295355

296-
# 18| test_switch
356+
# 18| test_stmts.test_switch(int)
297357
# 18| Block 0
298358
# 18| v0_0(Void) = EnterFunction :
299359
# 18| mu0_1(Object) = AliasedDefinition :
@@ -307,71 +367,64 @@ stmts.cs:
307367
# 20| r0_9(lval<Int32>) = VariableAddress[select] :
308368
# 20| r0_10(Int32) = Constant[0] :
309369
# 20| mu0_11(Int32) = Store : &:r0_9, r0_10
310-
311-
# 34| Block 1
312-
# 34| r1_0(lval<Int32>) = VariableAddress[#return] :
313-
# 34| r1_1(lval<Int32>) = VariableAddress[select] :
314-
# 34| r1_2(Int32) = Load : &:r1_1, ~mu0_2
315-
# 34| mu1_3(Int32) = Store : &:r1_0, r1_2
316-
#-----| Goto -> Block 10
370+
# 22| r0_12(lval<Int32>) = VariableAddress[caseSwitch] :
371+
# 22| r0_13(Int32) = Load : &:r0_12, ~mu0_2
372+
# 22| v0_14(Void) = Switch : r0_13
373+
#-----| Case[-...] -> Block 2
374+
#-----| Case[0] -> Block 3
375+
#-----| Case[1] -> Block 4
376+
#-----| Case[2] -> Block 5
377+
#-----| Default -> Block 6
378+
379+
# 18| Block 1
380+
# 18| r1_0(lval<Int32>) = VariableAddress[#return] :
381+
# 18| v1_1(Void) = ReturnValue : &:r1_0, ~mu0_2
382+
# 18| v1_2(Void) = UnmodeledUse : mu*
383+
# 18| v1_3(Void) = ExitFunction :
317384

318385
# 24| Block 2
319386
# 24| v2_0(Void) = NoOp :
387+
#-----| Goto -> Block 3
320388

321-
# 25| Block 2
322-
# 25| v2_0(Void) = NoOp :
323-
324-
# 26| Block 2
325-
# 26| v2_0(Void) = NoOp :
326-
#-----| Goto -> Block 11
327-
328-
# 27| Block 2
329-
# 27| v2_0(Void) = NoOp :
330-
331-
# 29| Block 2
332-
# 29| v2_0(Void) = NoOp :
333-
#-----| Goto -> Block 11
334-
335-
# 30| Block 2
336-
# 30| v2_0(Void) = NoOp :
389+
# 25| Block 3
390+
# 25| v3_0(Void) = NoOp :
391+
# 26| v3_1(Void) = NoOp :
392+
#-----| Goto -> Block 7
393+
394+
# 27| Block 4
395+
# 27| v4_0(Void) = NoOp :
396+
# 28| r4_1(Int32) = Constant[100] :
397+
# 28| r4_2(lval<Int32>) = VariableAddress[select] :
398+
# 28| mu4_3(Int32) = Store : &:r4_2, r4_1
399+
# 29| v4_4(Void) = NoOp :
400+
#-----| Goto -> Block 7
401+
402+
# 30| Block 5
403+
# 30| v5_0(Void) = NoOp :
404+
# 31| r5_1(Int32) = Constant[101] :
405+
# 31| r5_2(lval<Int32>) = VariableAddress[select] :
406+
# 31| mu5_3(Int32) = Store : &:r5_2, r5_1
407+
# 32| v5_4(Void) = NoOp :
408+
#-----| Goto (back edge) -> Block 6
409+
410+
# 33| Block 6
411+
# 33| v6_0(Void) = NoOp :
412+
# 34| r6_1(lval<Int32>) = VariableAddress[#return] :
413+
# 34| r6_2(lval<Int32>) = VariableAddress[select] :
414+
# 34| r6_3(Int32) = Load : &:r6_2, ~mu0_2
415+
# 34| mu6_4(Int32) = Store : &:r6_1, r6_3
416+
#-----| Goto -> Block 1
337417

338-
# 32| Block 2
339-
# 32| v2_0(Void) = NoOp :
340-
#-----| Goto (back edge) -> Block 2
418+
# 36| Block 7
419+
# 36| r7_0(Int32) = Constant[1000] :
420+
# 36| r7_1(lval<Int32>) = VariableAddress[select] :
421+
# 36| mu7_2(Int32) = Store : &:r7_1, r7_0
422+
# 37| r7_3(lval<Int32>) = VariableAddress[#return] :
423+
# 37| r7_4(Int32) = Constant[0] :
424+
# 37| mu7_5(Int32) = Store : &:r7_3, r7_4
425+
#-----| Goto -> Block 1
341426

342-
# 33| Block 2
343-
# 33| v2_0(Void) = NoOp :
344-
345-
# 18| Block 10
346-
# 18| r10_0(lval<Int32>) = VariableAddress[#return] :
347-
# 18| v10_1(Void) = ReturnValue : &:r10_0, ~mu0_2
348-
# 18| v10_2(Void) = UnmodeledUse : mu*
349-
# 18| v10_3(Void) = ExitFunction :
350-
351-
# 36| Block 11
352-
# 36| r11_0(Int32) = Constant[1000] :
353-
# 36| r11_1(lval<Int32>) = VariableAddress[select] :
354-
# 36| mu11_2(Int32) = Store : &:r11_1, r11_0
355-
# 37| r11_3(lval<Int32>) = VariableAddress[#return] :
356-
# 37| r11_4(Int32) = Constant[0] :
357-
# 37| mu11_5(Int32) = Store : &:r11_3, r11_4
358-
#-----| Goto -> Block 10
359-
360-
# 22| Block 12
361-
# 22| r12_0(lval<Int32>) = VariableAddress[caseSwitch] :
362-
# 22| r12_1(Int32) = Load : &:r12_0, ~mu0_2
363-
364-
# 28| Block 13
365-
# 28| r13_0(Int32) = Constant[100] :
366-
# 28| r13_1(lval<Int32>) = VariableAddress[select] :
367-
# 28| mu13_2(Int32) = Store : &:r13_1, r13_0
368-
369-
# 31| Block 13
370-
# 31| r13_0(Int32) = Constant[101] :
371-
# 31| r13_1(lval<Int32>) = VariableAddress[select] :
372-
# 31| mu13_2(Int32) = Store : &:r13_1, r13_0
373-
374-
# 40| test_trycatchfinally
427+
# 40| test_stmts.test_trycatchfinally()
375428
# 40| Block 0
376429
# 40| v0_0(Void) = EnterFunction :
377430
# 40| mu0_1(Object) = AliasedDefinition :
@@ -393,6 +446,7 @@ stmts.cs:
393446
# 45| r1_1(lval<Exception>) = FunctionAddress[Exception] :
394447
# 45| r1_2(Exception) = Call : func:r1_1, this:r1_0
395448
# 45| v1_3(Void) = ^CallSideEffect : ~mu0_2
449+
# 45| mu1_4(Exception) = Store : r1_0
396450

397451
# 40| Block 2
398452
# 40| v2_0(Void) = ReturnVoid :
@@ -424,7 +478,7 @@ stmts.cs:
424478
#-----| Goto -> Block 2
425479

426480
variables.cs:
427-
# 4| f
481+
# 4| test_variables.f()
428482
# 4| Block 0
429483
# 4| v0_0(Void) = EnterFunction :
430484
# 4| mu0_1(Object) = AliasedDefinition :

0 commit comments

Comments
 (0)