Skip to content

Commit 45c97b2

Browse files
committed
C++: Rename IR test file and add another C test
1 parent 6f704f0 commit 45c97b2

File tree

4 files changed

+401
-328
lines changed

4 files changed

+401
-328
lines changed

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

Lines changed: 196 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,202 @@ bad_stmts.cpp:
236236
# 8| Type = [ErroneousType] error
237237
# 8| ValueCategory = prvalue(load)
238238
# 9| getStmt(3): [ReturnStmt] return ...
239+
c11.c:
240+
# 1| [TopLevelFunction] void c11_generic_test_with_load(unsigned int, int)
241+
# 1| <params>:
242+
# 1| getParameter(0): [Parameter] x
243+
# 1| Type = [IntType] unsigned int
244+
# 1| getParameter(1): [Parameter] y
245+
# 1| Type = [IntType] int
246+
# 1| getEntryPoint(): [BlockStmt] { ... }
247+
# 2| getStmt(0): [DeclStmt] declaration
248+
# 2| getDeclarationEntry(0): [VariableDeclarationEntry] definition of r
249+
# 2| Type = [IntType] unsigned int
250+
# 3| getStmt(1): [ExprStmt] ExprStmt
251+
# 3| getExpr(): [AssignExpr] ... = ...
252+
# 3| Type = [IntType] unsigned int
253+
# 3| ValueCategory = prvalue
254+
# 3| getLValue(): [VariableAccess] r
255+
# 3| Type = [IntType] unsigned int
256+
# 3| ValueCategory = lvalue
257+
# 3| getRValue(): [AddExpr] ... + ...
258+
# 3| Type = [IntType] unsigned int
259+
# 3| ValueCategory = prvalue
260+
# 3| getLeftOperand(): [VariableAccess] x
261+
# 3| Type = [IntType] unsigned int
262+
# 3| ValueCategory = prvalue(load)
263+
# 3| getRightOperand(): [Literal] 1
264+
# 3| Type = [IntType] int
265+
# 3| Value = [Literal] 1
266+
# 3| ValueCategory = prvalue
267+
# 3| getLeftOperand().getFullyConverted(): [C11GenericExpr] _Generic
268+
# 3| Type = [IntType] unsigned int
269+
# 3| ValueCategory = prvalue(load)
270+
# 3| getControllingExpr(): [VariableAccess] r
271+
# 3| Type = [IntType] unsigned int
272+
# 3| ValueCategory = prvalue(load)
273+
# 3| getAssociationType(0): [TypeName] unsigned int
274+
# 3| Type = [IntType] unsigned int
275+
# 3| ValueCategory = prvalue
276+
# 3| getAssociationExpr(0): [ReuseExpr] reuse of x
277+
# 3| Type = [IntType] unsigned int
278+
# 3| ValueCategory = lvalue
279+
# 3| getAssociationType(1): [TypeName] int
280+
# 3| Type = [IntType] int
281+
# 3| ValueCategory = prvalue
282+
# 3| getAssociationExpr(1): [VariableAccess] y
283+
# 3| Type = [IntType] int
284+
# 3| ValueCategory = lvalue
285+
# 3| getRightOperand().getFullyConverted(): [CStyleCast] (unsigned int)...
286+
# 3| Conversion = [IntegralConversion] integral conversion
287+
# 3| Type = [IntType] unsigned int
288+
# 3| Value = [CStyleCast] 1
289+
# 3| ValueCategory = prvalue
290+
# 4| getStmt(2): [ReturnStmt] return ...
291+
# 12| [TopLevelFunction] char const* c11_generic_test_with_constant_and_macro()
292+
# 12| <params>:
293+
# 13| getEntryPoint(): [BlockStmt] { ... }
294+
# 14| getStmt(0): [DeclStmt] declaration
295+
# 14| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
296+
# 14| Type = [IntType] int
297+
# 16| getStmt(1): [ReturnStmt] return ...
298+
# 16| getExpr(): int
299+
# 16| Type = [ArrayType] char[4]
300+
# 16| Value = [StringLiteral] "int"
301+
# 16| ValueCategory = lvalue
302+
# 16| getExpr().getFullyConverted(): [CStyleCast] (const char *)...
303+
# 16| Conversion = [PointerConversion] pointer conversion
304+
# 16| Type = [PointerType] const char *
305+
# 16| ValueCategory = prvalue
306+
# 16| getExpr(): [ArrayToPointerConversion] array to pointer conversion
307+
# 16| Type = [CharPointerType] char *
308+
# 16| ValueCategory = prvalue
309+
# 16| getExpr(): [C11GenericExpr] _Generic
310+
# 16| Type = [ArrayType] char[4]
311+
# 16| Value = [C11GenericExpr] int
312+
# 16| ValueCategory = lvalue
313+
# 16| getControllingExpr(): [VariableAccess] i
314+
# 16| Type = [IntType] int
315+
# 16| ValueCategory = prvalue(load)
316+
# 16| getAssociationType(0): [TypeName] int
317+
# 16| Type = [IntType] int
318+
# 16| ValueCategory = prvalue
319+
# 16| getAssociationExpr(0): [ReuseExpr] reuse of int
320+
# 16| Type = [ArrayType] char[4]
321+
# 16| ValueCategory = lvalue
322+
# 16| getAssociationType(1): [TypeName] void
323+
# 16| Type = [VoidType] void
324+
# 16| ValueCategory = prvalue
325+
# 16| getAssociationExpr(1): unknown
326+
# 16| Type = [ArrayType] char[8]
327+
# 16| Value = [StringLiteral] "unknown"
328+
# 16| ValueCategory = lvalue
329+
# 16| getControllingExpr().getFullyConverted(): [ParenthesisExpr] (...)
330+
# 16| Type = [IntType] int
331+
# 16| ValueCategory = prvalue(load)
332+
# 19| [TopLevelFunction] char const* c11_generic_test_with_constant_and_no_macro()
333+
# 19| <params>:
334+
# 20| getEntryPoint(): [BlockStmt] { ... }
335+
# 21| getStmt(0): [DeclStmt] declaration
336+
# 21| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
337+
# 21| Type = [IntType] int
338+
# 23| getStmt(1): [ReturnStmt] return ...
339+
# 23| getExpr(): int
340+
# 23| Type = [ArrayType] char[4]
341+
# 23| Value = [StringLiteral] "int"
342+
# 23| ValueCategory = lvalue
343+
# 23| getExpr().getFullyConverted(): [CStyleCast] (const char *)...
344+
# 23| Conversion = [PointerConversion] pointer conversion
345+
# 23| Type = [PointerType] const char *
346+
# 23| ValueCategory = prvalue
347+
# 23| getExpr(): [ArrayToPointerConversion] array to pointer conversion
348+
# 23| Type = [CharPointerType] char *
349+
# 23| ValueCategory = prvalue
350+
# 23| getExpr(): [C11GenericExpr] _Generic
351+
# 23| Type = [ArrayType] char[4]
352+
# 23| Value = [C11GenericExpr] int
353+
# 23| ValueCategory = lvalue
354+
# 23| getControllingExpr(): [VariableAccess] i
355+
# 23| Type = [IntType] int
356+
# 23| ValueCategory = prvalue(load)
357+
# 23| getAssociationType(0): [TypeName] int
358+
# 23| Type = [IntType] int
359+
# 23| ValueCategory = prvalue
360+
# 23| getAssociationExpr(0): [ReuseExpr] reuse of int
361+
# 23| Type = [ArrayType] char[4]
362+
# 23| ValueCategory = lvalue
363+
# 23| getAssociationType(1): [TypeName] void
364+
# 23| Type = [VoidType] void
365+
# 23| ValueCategory = prvalue
366+
# 23| getAssociationExpr(1): unknown
367+
# 23| Type = [ArrayType] char[8]
368+
# 23| Value = [StringLiteral] "unknown"
369+
# 23| ValueCategory = lvalue
370+
# 26| [TopLevelFunction] void c11_generic_test_test_with_cast(int)
371+
# 26| <params>:
372+
# 26| getParameter(0): [Parameter] y
373+
# 26| Type = [IntType] int
374+
# 26| getEntryPoint(): [BlockStmt] { ... }
375+
# 27| getStmt(0): [DeclStmt] declaration
376+
# 27| getDeclarationEntry(0): [VariableDeclarationEntry] definition of r
377+
# 27| Type = [IntType] unsigned int
378+
# 28| getStmt(1): [ExprStmt] ExprStmt
379+
# 28| getExpr(): [AssignExpr] ... = ...
380+
# 28| Type = [IntType] unsigned int
381+
# 28| ValueCategory = prvalue
382+
# 28| getLValue(): [VariableAccess] r
383+
# 28| Type = [IntType] unsigned int
384+
# 28| ValueCategory = lvalue
385+
# 28| getRValue(): [VariableAccess] y
386+
# 28| Type = [IntType] int
387+
# 28| ValueCategory = prvalue(load)
388+
# 28| getRValue().getFullyConverted(): [C11GenericExpr] _Generic
389+
# 28| Type = [IntType] unsigned int
390+
# 28| ValueCategory = prvalue
391+
# 28| getControllingExpr(): [VariableAccess] r
392+
# 28| Type = [IntType] unsigned int
393+
# 28| ValueCategory = prvalue(load)
394+
# 28| getAssociationType(0): [TypeName] unsigned int
395+
# 28| Type = [IntType] unsigned int
396+
# 28| ValueCategory = prvalue
397+
# 28| getAssociationExpr(0): [ReuseExpr] reuse of y
398+
# 28| Type = [IntType] int
399+
# 28| ValueCategory = prvalue
400+
# 28| getAssociationType(1): [TypeName] int
401+
# 28| Type = [IntType] int
402+
# 28| ValueCategory = prvalue
403+
# 28| getAssociationExpr(1): [VariableAccess] y
404+
# 28| Type = [IntType] int
405+
# 28| ValueCategory = lvalue
406+
# 28| getExpr(): [CStyleCast] (unsigned int)...
407+
# 28| Conversion = [IntegralConversion] integral conversion
408+
# 28| Type = [IntType] unsigned int
409+
# 28| ValueCategory = prvalue
410+
# 29| getStmt(2): [ReturnStmt] return ...
411+
# 32| [TopLevelFunction] void static_array_param(int[3])
412+
# 32| <params>:
413+
# 32| getParameter(0): [Parameter] a
414+
# 32| Type = [ArrayType] int[3]
415+
# 32| getEntryPoint(): [BlockStmt] { ... }
416+
# 33| getStmt(0): [ExprStmt] ExprStmt
417+
# 33| getExpr(): [AssignExpr] ... = ...
418+
# 33| Type = [IntType] int
419+
# 33| ValueCategory = prvalue
420+
# 33| getLValue(): [ArrayExpr] access to array
421+
# 33| Type = [IntType] int
422+
# 33| ValueCategory = lvalue
423+
# 33| getArrayBase(): [VariableAccess] a
424+
# 33| Type = [IntPointerType] int *
425+
# 33| ValueCategory = prvalue(load)
426+
# 33| getArrayOffset(): [Literal] 0
427+
# 33| Type = [IntType] int
428+
# 33| Value = [Literal] 0
429+
# 33| ValueCategory = prvalue
430+
# 33| getRValue(): [Literal] 1
431+
# 33| Type = [IntType] int
432+
# 33| Value = [Literal] 1
433+
# 33| ValueCategory = prvalue
434+
# 34| getStmt(1): [ReturnStmt] return ...
239435
clang.cpp:
240436
# 5| [TopLevelFunction] int* globalIntAddress()
241437
# 5| <params>:
@@ -4179,178 +4375,6 @@ destructors_for_temps.cpp:
41794375
# 103| Type = [IntType] int
41804376
# 103| ValueCategory = prvalue
41814377
# 104| getStmt(1): [ReturnStmt] return ...
4182-
generic.c:
4183-
# 1| [TopLevelFunction] void c11_generic_test_with_load(unsigned int, int)
4184-
# 1| <params>:
4185-
# 1| getParameter(0): [Parameter] x
4186-
# 1| Type = [IntType] unsigned int
4187-
# 1| getParameter(1): [Parameter] y
4188-
# 1| Type = [IntType] int
4189-
# 1| getEntryPoint(): [BlockStmt] { ... }
4190-
# 2| getStmt(0): [DeclStmt] declaration
4191-
# 2| getDeclarationEntry(0): [VariableDeclarationEntry] definition of r
4192-
# 2| Type = [IntType] unsigned int
4193-
# 3| getStmt(1): [ExprStmt] ExprStmt
4194-
# 3| getExpr(): [AssignExpr] ... = ...
4195-
# 3| Type = [IntType] unsigned int
4196-
# 3| ValueCategory = prvalue
4197-
# 3| getLValue(): [VariableAccess] r
4198-
# 3| Type = [IntType] unsigned int
4199-
# 3| ValueCategory = lvalue
4200-
# 3| getRValue(): [AddExpr] ... + ...
4201-
# 3| Type = [IntType] unsigned int
4202-
# 3| ValueCategory = prvalue
4203-
# 3| getLeftOperand(): [VariableAccess] x
4204-
# 3| Type = [IntType] unsigned int
4205-
# 3| ValueCategory = prvalue(load)
4206-
# 3| getRightOperand(): [Literal] 1
4207-
# 3| Type = [IntType] int
4208-
# 3| Value = [Literal] 1
4209-
# 3| ValueCategory = prvalue
4210-
# 3| getLeftOperand().getFullyConverted(): [C11GenericExpr] _Generic
4211-
# 3| Type = [IntType] unsigned int
4212-
# 3| ValueCategory = prvalue(load)
4213-
# 3| getControllingExpr(): [VariableAccess] r
4214-
# 3| Type = [IntType] unsigned int
4215-
# 3| ValueCategory = prvalue(load)
4216-
# 3| getAssociationType(0): [TypeName] unsigned int
4217-
# 3| Type = [IntType] unsigned int
4218-
# 3| ValueCategory = prvalue
4219-
# 3| getAssociationExpr(0): [ReuseExpr] reuse of x
4220-
# 3| Type = [IntType] unsigned int
4221-
# 3| ValueCategory = lvalue
4222-
# 3| getAssociationType(1): [TypeName] int
4223-
# 3| Type = [IntType] int
4224-
# 3| ValueCategory = prvalue
4225-
# 3| getAssociationExpr(1): [VariableAccess] y
4226-
# 3| Type = [IntType] int
4227-
# 3| ValueCategory = lvalue
4228-
# 3| getRightOperand().getFullyConverted(): [CStyleCast] (unsigned int)...
4229-
# 3| Conversion = [IntegralConversion] integral conversion
4230-
# 3| Type = [IntType] unsigned int
4231-
# 3| Value = [CStyleCast] 1
4232-
# 3| ValueCategory = prvalue
4233-
# 4| getStmt(2): [ReturnStmt] return ...
4234-
# 12| [TopLevelFunction] char const* c11_generic_test_with_constant_and_macro()
4235-
# 12| <params>:
4236-
# 13| getEntryPoint(): [BlockStmt] { ... }
4237-
# 14| getStmt(0): [DeclStmt] declaration
4238-
# 14| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
4239-
# 14| Type = [IntType] int
4240-
# 16| getStmt(1): [ReturnStmt] return ...
4241-
# 16| getExpr(): int
4242-
# 16| Type = [ArrayType] char[4]
4243-
# 16| Value = [StringLiteral] "int"
4244-
# 16| ValueCategory = lvalue
4245-
# 16| getExpr().getFullyConverted(): [CStyleCast] (const char *)...
4246-
# 16| Conversion = [PointerConversion] pointer conversion
4247-
# 16| Type = [PointerType] const char *
4248-
# 16| ValueCategory = prvalue
4249-
# 16| getExpr(): [ArrayToPointerConversion] array to pointer conversion
4250-
# 16| Type = [CharPointerType] char *
4251-
# 16| ValueCategory = prvalue
4252-
# 16| getExpr(): [C11GenericExpr] _Generic
4253-
# 16| Type = [ArrayType] char[4]
4254-
# 16| Value = [C11GenericExpr] int
4255-
# 16| ValueCategory = lvalue
4256-
# 16| getControllingExpr(): [VariableAccess] i
4257-
# 16| Type = [IntType] int
4258-
# 16| ValueCategory = prvalue(load)
4259-
# 16| getAssociationType(0): [TypeName] int
4260-
# 16| Type = [IntType] int
4261-
# 16| ValueCategory = prvalue
4262-
# 16| getAssociationExpr(0): [ReuseExpr] reuse of int
4263-
# 16| Type = [ArrayType] char[4]
4264-
# 16| ValueCategory = lvalue
4265-
# 16| getAssociationType(1): [TypeName] void
4266-
# 16| Type = [VoidType] void
4267-
# 16| ValueCategory = prvalue
4268-
# 16| getAssociationExpr(1): unknown
4269-
# 16| Type = [ArrayType] char[8]
4270-
# 16| Value = [StringLiteral] "unknown"
4271-
# 16| ValueCategory = lvalue
4272-
# 16| getControllingExpr().getFullyConverted(): [ParenthesisExpr] (...)
4273-
# 16| Type = [IntType] int
4274-
# 16| ValueCategory = prvalue(load)
4275-
# 19| [TopLevelFunction] char const* c11_generic_test_with_constant_and_no_macro()
4276-
# 19| <params>:
4277-
# 20| getEntryPoint(): [BlockStmt] { ... }
4278-
# 21| getStmt(0): [DeclStmt] declaration
4279-
# 21| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
4280-
# 21| Type = [IntType] int
4281-
# 23| getStmt(1): [ReturnStmt] return ...
4282-
# 23| getExpr(): int
4283-
# 23| Type = [ArrayType] char[4]
4284-
# 23| Value = [StringLiteral] "int"
4285-
# 23| ValueCategory = lvalue
4286-
# 23| getExpr().getFullyConverted(): [CStyleCast] (const char *)...
4287-
# 23| Conversion = [PointerConversion] pointer conversion
4288-
# 23| Type = [PointerType] const char *
4289-
# 23| ValueCategory = prvalue
4290-
# 23| getExpr(): [ArrayToPointerConversion] array to pointer conversion
4291-
# 23| Type = [CharPointerType] char *
4292-
# 23| ValueCategory = prvalue
4293-
# 23| getExpr(): [C11GenericExpr] _Generic
4294-
# 23| Type = [ArrayType] char[4]
4295-
# 23| Value = [C11GenericExpr] int
4296-
# 23| ValueCategory = lvalue
4297-
# 23| getControllingExpr(): [VariableAccess] i
4298-
# 23| Type = [IntType] int
4299-
# 23| ValueCategory = prvalue(load)
4300-
# 23| getAssociationType(0): [TypeName] int
4301-
# 23| Type = [IntType] int
4302-
# 23| ValueCategory = prvalue
4303-
# 23| getAssociationExpr(0): [ReuseExpr] reuse of int
4304-
# 23| Type = [ArrayType] char[4]
4305-
# 23| ValueCategory = lvalue
4306-
# 23| getAssociationType(1): [TypeName] void
4307-
# 23| Type = [VoidType] void
4308-
# 23| ValueCategory = prvalue
4309-
# 23| getAssociationExpr(1): unknown
4310-
# 23| Type = [ArrayType] char[8]
4311-
# 23| Value = [StringLiteral] "unknown"
4312-
# 23| ValueCategory = lvalue
4313-
# 26| [TopLevelFunction] void c11_generic_test_test_with_cast(int)
4314-
# 26| <params>:
4315-
# 26| getParameter(0): [Parameter] y
4316-
# 26| Type = [IntType] int
4317-
# 26| getEntryPoint(): [BlockStmt] { ... }
4318-
# 27| getStmt(0): [DeclStmt] declaration
4319-
# 27| getDeclarationEntry(0): [VariableDeclarationEntry] definition of r
4320-
# 27| Type = [IntType] unsigned int
4321-
# 28| getStmt(1): [ExprStmt] ExprStmt
4322-
# 28| getExpr(): [AssignExpr] ... = ...
4323-
# 28| Type = [IntType] unsigned int
4324-
# 28| ValueCategory = prvalue
4325-
# 28| getLValue(): [VariableAccess] r
4326-
# 28| Type = [IntType] unsigned int
4327-
# 28| ValueCategory = lvalue
4328-
# 28| getRValue(): [VariableAccess] y
4329-
# 28| Type = [IntType] int
4330-
# 28| ValueCategory = prvalue(load)
4331-
# 28| getRValue().getFullyConverted(): [C11GenericExpr] _Generic
4332-
# 28| Type = [IntType] unsigned int
4333-
# 28| ValueCategory = prvalue
4334-
# 28| getControllingExpr(): [VariableAccess] r
4335-
# 28| Type = [IntType] unsigned int
4336-
# 28| ValueCategory = prvalue(load)
4337-
# 28| getAssociationType(0): [TypeName] unsigned int
4338-
# 28| Type = [IntType] unsigned int
4339-
# 28| ValueCategory = prvalue
4340-
# 28| getAssociationExpr(0): [ReuseExpr] reuse of y
4341-
# 28| Type = [IntType] int
4342-
# 28| ValueCategory = prvalue
4343-
# 28| getAssociationType(1): [TypeName] int
4344-
# 28| Type = [IntType] int
4345-
# 28| ValueCategory = prvalue
4346-
# 28| getAssociationExpr(1): [VariableAccess] y
4347-
# 28| Type = [IntType] int
4348-
# 28| ValueCategory = lvalue
4349-
# 28| getExpr(): [CStyleCast] (unsigned int)...
4350-
# 28| Conversion = [IntegralConversion] integral conversion
4351-
# 28| Type = [IntType] unsigned int
4352-
# 28| ValueCategory = prvalue
4353-
# 29| getStmt(2): [ReturnStmt] return ...
43544378
ir-not-microsoft.c:
43554379
# 1| [TopLevelFunction] void gnuConditionalOmittedOperand()
43564380
# 1| <params>:

0 commit comments

Comments
 (0)