Skip to content

Commit c30dffc

Browse files
committed
C++: Add more tests.
1 parent 048afc2 commit c30dffc

File tree

7 files changed

+388
-222
lines changed

7 files changed

+388
-222
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedAssertion.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ abstract private class TranslatedAssertionOperand extends TranslatedElement,
198198
}
199199

200200
/** An operand of an assertion that is a variable access. */
201-
private class TranslatedAssertionVarAccess extends TranslatedAssertionOperand {
201+
class TranslatedAssertionVarAccess extends TranslatedAssertionOperand {
202202
TranslatedAssertionVarAccess() { hasVarAccessMacroArgument(mi, _, index, _) }
203203

204204
Variable getVariable() { hasVarAccessMacroArgument(mi, result, index, _) }

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

Lines changed: 148 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -25492,103 +25492,156 @@ ir.cpp:
2549225492
# 2859| Type = [VoidType] void
2549325493
# 2859| ValueCategory = prvalue
2549425494
# 2860| getStmt(7): [ReturnStmt] return ...
25495-
# 2865| [TopLevelFunction] void complex_assertions(int, bool, int)
25496-
# 2865| <params>:
25497-
# 2865| getParameter(0): [Parameter] x
25498-
# 2865| Type = [IntType] int
25499-
# 2865| getParameter(1): [Parameter] b
25500-
# 2865| Type = [BoolType] bool
25501-
# 2865| getParameter(2): [Parameter] max
25502-
# 2865| Type = [IntType] int
25503-
# 2865| getEntryPoint(): [BlockStmt] { ... }
25504-
# 2866| getStmt(0): [DeclStmt] declaration
25505-
# 2866| getDeclarationEntry(0): [VariableDeclarationEntry] definition of y
25506-
# 2866| Type = [IntType] int
25507-
# 2866| getVariable().getInitializer(): [Initializer] initializer for y
25508-
# 2866| getExpr(): [CommaExpr] ... , ...
25509-
# 2866| Type = [IntType] int
25510-
# 2866| ValueCategory = prvalue(load)
25511-
# 2866| getLeftOperand(): [Literal] 0
25512-
# 2866| Type = [IntType] int
25513-
# 2866| Value = [Literal] 0
25514-
# 2866| ValueCategory = prvalue
25515-
# 2866| getRightOperand(): [VariableAccess] x
25516-
# 2866| Type = [IntType] int
25517-
# 2866| ValueCategory = prvalue(load)
25518-
# 2866| getLeftOperand().getFullyConverted(): [ParenthesisExpr] (...)
25519-
# 2866| Type = [VoidType] void
25520-
# 2866| ValueCategory = prvalue
25521-
# 2866| getExpr(): [CStyleCast] (void)...
25522-
# 2866| Conversion = [VoidConversion] conversion to void
25523-
# 2866| Type = [VoidType] void
25524-
# 2866| ValueCategory = prvalue
25525-
# 2866| getExpr().getFullyConverted(): [ParenthesisExpr] (...)
25526-
# 2866| Type = [IntType] int
25527-
# 2866| ValueCategory = prvalue(load)
25528-
# 2867| getStmt(1): [DeclStmt] declaration
25529-
# 2867| getDeclarationEntry(0): [VariableDeclarationEntry] definition of z
25530-
# 2867| Type = [IntType] int
25531-
# 2867| getVariable().getInitializer(): [Initializer] initializer for z
25532-
# 2867| getExpr(): [ConditionalExpr] ... ? ... : ...
25533-
# 2867| Type = [IntType] int
25534-
# 2867| ValueCategory = prvalue
25535-
# 2867| getCondition(): [VariableAccess] b
25536-
# 2867| Type = [BoolType] bool
25537-
# 2867| ValueCategory = prvalue(load)
25538-
# 2867| getThen(): [CommaExpr] ... , ...
25539-
# 2867| Type = [IntType] int
25540-
# 2867| Value = [CommaExpr] 0
25541-
# 2867| ValueCategory = prvalue
25542-
# 2867| getLeftOperand(): [Literal] 0
25543-
# 2867| Type = [IntType] int
25544-
# 2867| Value = [Literal] 0
25545-
# 2867| ValueCategory = prvalue
25546-
# 2867| getRightOperand(): [Literal] 0
25547-
# 2867| Type = [IntType] int
25548-
# 2867| Value = [Literal] 0
25549-
# 2867| ValueCategory = prvalue
25550-
# 2867| getLeftOperand().getFullyConverted(): [ParenthesisExpr] (...)
25551-
# 2867| Type = [VoidType] void
25552-
# 2867| ValueCategory = prvalue
25553-
# 2867| getExpr(): [CStyleCast] (void)...
25554-
# 2867| Conversion = [VoidConversion] conversion to void
25555-
# 2867| Type = [VoidType] void
25556-
# 2867| ValueCategory = prvalue
25557-
# 2867| getElse(): [Literal] 1
25558-
# 2867| Type = [IntType] int
25559-
# 2867| Value = [Literal] 1
25560-
# 2867| ValueCategory = prvalue
25561-
# 2867| getThen().getFullyConverted(): [ParenthesisExpr] (...)
25562-
# 2867| Type = [IntType] int
25563-
# 2867| Value = [ParenthesisExpr] 0
25564-
# 2867| ValueCategory = prvalue
25565-
# 2869| getStmt(2): [TryStmt] try { ... }
25566-
# 2869| getStmt(): [BlockStmt] { ... }
25567-
# 2870| getStmt(0): [ExprStmt] ExprStmt
25568-
# 2870| getExpr(): [ThrowExpr] throw ...
25569-
# 2870| Type = [IntType] int
25570-
# 2870| ValueCategory = prvalue
25571-
# 2870| getExpr(): [Literal] 41
25572-
# 2870| Type = [IntType] int
25573-
# 2870| Value = [Literal] 41
25574-
# 2870| ValueCategory = prvalue
25575-
# 2871| getChild(1): [Handler] <handler>
25576-
# 2871| getParameter(): [Parameter] c
25577-
# 2871| Type = [IntType] int
25578-
# 2871| getBlock(): [CatchBlock] { ... }
25579-
# 2872| getStmt(0): [ExprStmt] ExprStmt
25580-
# 2872| getExpr(): [Literal] 0
25495+
# 2867| [TopLevelFunction] void (unnamed namespace)::complex_assertions(int, bool, int)
25496+
# 2867| <params>:
25497+
# 2867| getParameter(0): [Parameter] x
25498+
# 2867| Type = [IntType] int
25499+
# 2867| getParameter(1): [Parameter] b
25500+
# 2867| Type = [BoolType] bool
25501+
# 2867| getParameter(2): [Parameter] max
25502+
# 2867| Type = [IntType] int
25503+
# 2867| getEntryPoint(): [BlockStmt] { ... }
25504+
# 2868| getStmt(0): [DeclStmt] declaration
25505+
# 2868| getDeclarationEntry(0): [VariableDeclarationEntry] definition of y
25506+
# 2868| Type = [IntType] int
25507+
# 2868| getVariable().getInitializer(): [Initializer] initializer for y
25508+
# 2868| getExpr(): [CommaExpr] ... , ...
25509+
# 2868| Type = [IntType] int
25510+
# 2868| ValueCategory = prvalue(load)
25511+
# 2868| getLeftOperand(): [Literal] 0
25512+
# 2868| Type = [IntType] int
25513+
# 2868| Value = [Literal] 0
25514+
# 2868| ValueCategory = prvalue
25515+
# 2868| getRightOperand(): [VariableAccess] x
25516+
# 2868| Type = [IntType] int
25517+
# 2868| ValueCategory = prvalue(load)
25518+
# 2868| getLeftOperand().getFullyConverted(): [ParenthesisExpr] (...)
25519+
# 2868| Type = [VoidType] void
25520+
# 2868| ValueCategory = prvalue
25521+
# 2868| getExpr(): [CStyleCast] (void)...
25522+
# 2868| Conversion = [VoidConversion] conversion to void
25523+
# 2868| Type = [VoidType] void
25524+
# 2868| ValueCategory = prvalue
25525+
# 2868| getExpr().getFullyConverted(): [ParenthesisExpr] (...)
25526+
# 2868| Type = [IntType] int
25527+
# 2868| ValueCategory = prvalue(load)
25528+
# 2869| getStmt(1): [DeclStmt] declaration
25529+
# 2869| getDeclarationEntry(0): [VariableDeclarationEntry] definition of z
25530+
# 2869| Type = [IntType] int
25531+
# 2869| getVariable().getInitializer(): [Initializer] initializer for z
25532+
# 2869| getExpr(): [ConditionalExpr] ... ? ... : ...
25533+
# 2869| Type = [IntType] int
25534+
# 2869| ValueCategory = prvalue
25535+
# 2869| getCondition(): [VariableAccess] b
25536+
# 2869| Type = [BoolType] bool
25537+
# 2869| ValueCategory = prvalue(load)
25538+
# 2869| getThen(): [CommaExpr] ... , ...
25539+
# 2869| Type = [IntType] int
25540+
# 2869| Value = [CommaExpr] 0
25541+
# 2869| ValueCategory = prvalue
25542+
# 2869| getLeftOperand(): [Literal] 0
25543+
# 2869| Type = [IntType] int
25544+
# 2869| Value = [Literal] 0
25545+
# 2869| ValueCategory = prvalue
25546+
# 2869| getRightOperand(): [Literal] 0
25547+
# 2869| Type = [IntType] int
25548+
# 2869| Value = [Literal] 0
25549+
# 2869| ValueCategory = prvalue
25550+
# 2869| getLeftOperand().getFullyConverted(): [ParenthesisExpr] (...)
25551+
# 2869| Type = [VoidType] void
25552+
# 2869| ValueCategory = prvalue
25553+
# 2869| getExpr(): [CStyleCast] (void)...
25554+
# 2869| Conversion = [VoidConversion] conversion to void
25555+
# 2869| Type = [VoidType] void
25556+
# 2869| ValueCategory = prvalue
25557+
# 2869| getElse(): [Literal] 1
25558+
# 2869| Type = [IntType] int
25559+
# 2869| Value = [Literal] 1
25560+
# 2869| ValueCategory = prvalue
25561+
# 2869| getThen().getFullyConverted(): [ParenthesisExpr] (...)
25562+
# 2869| Type = [IntType] int
25563+
# 2869| Value = [ParenthesisExpr] 0
25564+
# 2869| ValueCategory = prvalue
25565+
# 2871| getStmt(2): [TryStmt] try { ... }
25566+
# 2871| getStmt(): [BlockStmt] { ... }
25567+
# 2872| getStmt(0): [ExprStmt] ExprStmt
25568+
# 2872| getExpr(): [ThrowExpr] throw ...
25569+
# 2872| Type = [IntType] int
25570+
# 2872| ValueCategory = prvalue
25571+
# 2872| getExpr(): [Literal] 41
2558125572
# 2872| Type = [IntType] int
25582-
# 2872| Value = [Literal] 0
25573+
# 2872| Value = [Literal] 41
2558325574
# 2872| ValueCategory = prvalue
25584-
# 2872| getExpr().getFullyConverted(): [ParenthesisExpr] (...)
25585-
# 2872| Type = [VoidType] void
25586-
# 2872| ValueCategory = prvalue
25587-
# 2872| getExpr(): [CStyleCast] (void)...
25588-
# 2872| Conversion = [VoidConversion] conversion to void
25589-
# 2872| Type = [VoidType] void
25590-
# 2872| ValueCategory = prvalue
25591-
# 2874| getStmt(3): [ReturnStmt] return ...
25575+
# 2873| getChild(1): [Handler] <handler>
25576+
# 2873| getParameter(): [Parameter] c
25577+
# 2873| Type = [IntType] int
25578+
# 2873| getBlock(): [CatchBlock] { ... }
25579+
# 2874| getStmt(0): [ExprStmt] ExprStmt
25580+
# 2874| getExpr(): [Literal] 0
25581+
# 2874| Type = [IntType] int
25582+
# 2874| Value = [Literal] 0
25583+
# 2874| ValueCategory = prvalue
25584+
# 2874| getExpr().getFullyConverted(): [ParenthesisExpr] (...)
25585+
# 2874| Type = [VoidType] void
25586+
# 2874| ValueCategory = prvalue
25587+
# 2874| getExpr(): [CStyleCast] (void)...
25588+
# 2874| Conversion = [VoidConversion] conversion to void
25589+
# 2874| Type = [VoidType] void
25590+
# 2874| ValueCategory = prvalue
25591+
# 2875| getStmt(1): [ExprStmt] ExprStmt
25592+
# 2875| getExpr(): [Literal] 0
25593+
# 2875| Type = [IntType] int
25594+
# 2875| Value = [Literal] 0
25595+
# 2875| ValueCategory = prvalue
25596+
# 2875| getExpr().getFullyConverted(): [ParenthesisExpr] (...)
25597+
# 2875| Type = [VoidType] void
25598+
# 2875| ValueCategory = prvalue
25599+
# 2875| getExpr(): [CStyleCast] (void)...
25600+
# 2875| Conversion = [VoidConversion] conversion to void
25601+
# 2875| Type = [VoidType] void
25602+
# 2875| ValueCategory = prvalue
25603+
# 2878| getStmt(3): [ExprStmt] ExprStmt
25604+
# 2878| getExpr(): [Literal] 0
25605+
# 2878| Type = [IntType] int
25606+
# 2878| Value = [Literal] 0
25607+
# 2878| ValueCategory = prvalue
25608+
# 2878| getExpr().getFullyConverted(): [ParenthesisExpr] (...)
25609+
# 2878| Type = [VoidType] void
25610+
# 2878| ValueCategory = prvalue
25611+
# 2878| getExpr(): [CStyleCast] (void)...
25612+
# 2878| Conversion = [VoidConversion] conversion to void
25613+
# 2878| Type = [VoidType] void
25614+
# 2878| ValueCategory = prvalue
25615+
# 2879| getStmt(4): [DeclStmt] declaration
25616+
# 2879| getDeclarationEntry(0): [VariableDeclarationEntry] definition of shadowed
25617+
# 2879| Type = [IntType] int
25618+
# 2881| getStmt(5): [TryStmt] try { ... }
25619+
# 2881| getStmt(): [BlockStmt] { ... }
25620+
# 2882| getStmt(0): [ExprStmt] ExprStmt
25621+
# 2882| getExpr(): [ThrowExpr] throw ...
25622+
# 2882| Type = [IntType] int
25623+
# 2882| ValueCategory = prvalue
25624+
# 2882| getExpr(): [Literal] 41
25625+
# 2882| Type = [IntType] int
25626+
# 2882| Value = [Literal] 41
25627+
# 2882| ValueCategory = prvalue
25628+
# 2883| getChild(1): [Handler] <handler>
25629+
# 2883| getParameter(): [Parameter] shadowed
25630+
# 2883| Type = [IntType] int
25631+
# 2883| getBlock(): [CatchBlock] { ... }
25632+
# 2884| getStmt(0): [ExprStmt] ExprStmt
25633+
# 2884| getExpr(): [Literal] 0
25634+
# 2884| Type = [IntType] int
25635+
# 2884| Value = [Literal] 0
25636+
# 2884| ValueCategory = prvalue
25637+
# 2884| getExpr().getFullyConverted(): [ParenthesisExpr] (...)
25638+
# 2884| Type = [VoidType] void
25639+
# 2884| ValueCategory = prvalue
25640+
# 2884| getExpr(): [CStyleCast] (void)...
25641+
# 2884| Conversion = [VoidConversion] conversion to void
25642+
# 2884| Type = [VoidType] void
25643+
# 2884| ValueCategory = prvalue
25644+
# 2886| getStmt(6): [ReturnStmt] return ...
2559225645
ir23.cpp:
2559325646
# 1| [TopLevelFunction] bool consteval_1()
2559425647
# 1| <params>:

0 commit comments

Comments
 (0)