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

Skip to content

Commit ec398b2

Browse files
author
Dave Bartolomeo
committed
Merge remote-tracking branch 'upstream/main' into work
2 parents 4237341 + 310975b commit ec398b2

5 files changed

Lines changed: 71 additions & 3 deletions

File tree

cpp/ql/src/semmle/code/cpp/PrintAST.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,18 @@ class CastNode extends ConversionNode {
341341
}
342342
}
343343

344+
/**
345+
* A node representing a `StmtExpr`.
346+
*/
347+
class StmtExprNode extends ExprNode {
348+
override StmtExpr expr;
349+
350+
override ASTNode getChildInternal(int childIndex) {
351+
childIndex = 0 and
352+
result.getAST() = expr.getStmt()
353+
}
354+
}
355+
344356
/**
345357
* A node representing a `DeclarationEntry`.
346358
*/

cpp/ql/test/examples/expressions/PrintAST.expected

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,19 @@ StatementExpr.c:
724724
# 2| getExpr(): [StmtExpr] (statement expression)
725725
# 2| Type = [IntType] int
726726
# 2| ValueCategory = prvalue
727+
# 2| getStmt(): [BlockStmt] { ... }
728+
# 2| getStmt(0): [DeclStmt] declaration
729+
# 2| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
730+
# 2| Type = [IntType] int
731+
# 2| getVariable().getInitializer(): [Initializer] initializer for i
732+
# 2| getExpr(): [Literal] 5
733+
# 2| Type = [IntType] int
734+
# 2| Value = [Literal] 5
735+
# 2| ValueCategory = prvalue
736+
# 2| getStmt(1): [ExprStmt] ExprStmt
737+
# 2| getExpr(): [VariableAccess] i
738+
# 2| Type = [IntType] int
739+
# 2| ValueCategory = prvalue(load)
727740
# 3| getStmt(1): [ReturnStmt] return ...
728741
StaticMemberAccess.cpp:
729742
# 1| [CopyAssignmentOperator] X& X::operator=(X const&)

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

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8263,7 +8263,7 @@ ir.cpp:
82638263
# 997| Type = [FloatType] float
82648264
# 997| Value = [CStyleCast] 1.0
82658265
# 997| ValueCategory = prvalue
8266-
# 1000| [TopLevelFunction] int ExprStmt(int, int, int)
8266+
# 1000| [TopLevelFunction] int StmtExpr(int, int, int)
82678267
# 1000| <params>:
82688268
# 1000| getParameter(0): [Parameter] b
82698269
# 1000| Type = [IntType] int
@@ -8279,10 +8279,53 @@ ir.cpp:
82798279
# 1001| getExpr(): [StmtExpr] (statement expression)
82808280
# 1001| Type = [IntType] int
82818281
# 1001| ValueCategory = prvalue
8282+
# 1001| getStmt(): [BlockStmt] { ... }
8283+
# 1002| getStmt(0): [DeclStmt] declaration
8284+
# 1002| getDeclarationEntry(0): [VariableDeclarationEntry] definition of w
8285+
# 1002| Type = [IntType] int
8286+
# 1003| getStmt(1): [IfStmt] if (...) ...
8287+
# 1003| getCondition(): [VariableAccess] b
8288+
# 1003| Type = [IntType] int
8289+
# 1003| ValueCategory = prvalue(load)
8290+
# 1003| getThen(): [BlockStmt] { ... }
8291+
# 1004| getStmt(0): [ExprStmt] ExprStmt
8292+
# 1004| getExpr(): [AssignExpr] ... = ...
8293+
# 1004| Type = [IntType] int
8294+
# 1004| ValueCategory = lvalue
8295+
# 1004| getLValue(): [VariableAccess] w
8296+
# 1004| Type = [IntType] int
8297+
# 1004| ValueCategory = lvalue
8298+
# 1004| getRValue(): [VariableAccess] y
8299+
# 1004| Type = [IntType] int
8300+
# 1004| ValueCategory = prvalue(load)
8301+
# 1005| getElse(): [BlockStmt] { ... }
8302+
# 1006| getStmt(0): [ExprStmt] ExprStmt
8303+
# 1006| getExpr(): [AssignExpr] ... = ...
8304+
# 1006| Type = [IntType] int
8305+
# 1006| ValueCategory = lvalue
8306+
# 1006| getLValue(): [VariableAccess] w
8307+
# 1006| Type = [IntType] int
8308+
# 1006| ValueCategory = lvalue
8309+
# 1006| getRValue(): [VariableAccess] z
8310+
# 1006| Type = [IntType] int
8311+
# 1006| ValueCategory = prvalue(load)
8312+
# 1003| getCondition().getFullyConverted(): [CStyleCast] (bool)...
8313+
# 1003| Conversion = [BoolConversion] conversion to bool
8314+
# 1003| Type = [BoolType] bool
8315+
# 1003| ValueCategory = prvalue
8316+
# 1008| getStmt(2): [ExprStmt] ExprStmt
8317+
# 1008| getExpr(): [VariableAccess] w
8318+
# 1008| Type = [IntType] int
8319+
# 1008| ValueCategory = prvalue(load)
82828320
# 1011| getStmt(1): [ReturnStmt] return ...
82838321
# 1011| getExpr(): [StmtExpr] (statement expression)
82848322
# 1011| Type = [IntType] int
82858323
# 1011| ValueCategory = prvalue
8324+
# 1011| getStmt(): [BlockStmt] { ... }
8325+
# 1011| getStmt(0): [ExprStmt] ExprStmt
8326+
# 1011| getExpr(): [VariableAccess] x
8327+
# 1011| Type = [IntType] int
8328+
# 1011| ValueCategory = prvalue(load)
82868329
# 1015| [TopLevelFunction] void OperatorDelete()
82878330
# 1015| <params>:
82888331
# 1015| getEntryPoint(): [BlockStmt] { ... }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ int PointerDecay(int a[], int fn(float)) {
997997
return a[0] + fn(1.0);
998998
}
999999

1000-
int ExprStmt(int b, int y, int z) {
1000+
int StmtExpr(int b, int y, int z) {
10011001
int x = ({
10021002
int w;
10031003
if (b) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5540,7 +5540,7 @@ ir.cpp:
55405540
# 996| v996_13(void) = AliasedUse : ~m?
55415541
# 996| v996_14(void) = ExitFunction :
55425542

5543-
# 1000| int ExprStmt(int, int, int)
5543+
# 1000| int StmtExpr(int, int, int)
55445544
# 1000| Block 0
55455545
# 1000| v1000_1(void) = EnterFunction :
55465546
# 1000| mu1000_2(unknown) = AliasedDefinition :

0 commit comments

Comments
 (0)