Skip to content

Commit c6c3206

Browse files
committed
C++: Add example of 'goto' on the same line as the destination label.
1 parent b04c46f commit c6c3206

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13035,6 +13035,23 @@ ir.cpp:
1303513035
# 1689| getEntryPoint(): [BlockStmt] { ... }
1303613036
# 1689| getStmt(0): [EmptyStmt] ;
1303713037
# 1689| getStmt(1): [ReturnStmt] return ...
13038+
# 1693| [TopLevelFunction] int goto_on_same_line()
13039+
# 1693| <params>:
13040+
# 1693| getEntryPoint(): [BlockStmt] { ... }
13041+
# 1694| getStmt(0): [DeclStmt] declaration
13042+
# 1694| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
13043+
# 1694| Type = [IntType] int
13044+
# 1694| getVariable().getInitializer(): [Initializer] initializer for x
13045+
# 1694| getExpr(): [Literal] 42
13046+
# 1694| Type = [IntType] int
13047+
# 1694| Value = [Literal] 42
13048+
# 1694| ValueCategory = prvalue
13049+
# 1695| getStmt(1): [GotoStmt] goto ...
13050+
# 1695| getStmt(2): [LabelStmt] label ...:
13051+
# 1696| getStmt(3): [ReturnStmt] return ...
13052+
# 1696| getExpr(): [VariableAccess] x
13053+
# 1696| Type = [IntType] int
13054+
# 1696| ValueCategory = prvalue(load)
1303813055
perf-regression.cpp:
1303913056
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1304013057
# 4| <params>:

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,4 +1690,10 @@ void captured_lambda(int x, int &y, int &&z)
16901690
};
16911691
}
16921692

1693+
int goto_on_same_line() {
1694+
int x = 42;
1695+
goto next; next:
1696+
return x;
1697+
}
1698+
16931699
// semmle-extractor-options: -std=c++17 --clang

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7527,6 +7527,17 @@
75277527
| ir.cpp:1689:50:1689:50 | Load | m1689_6 |
75287528
| ir.cpp:1689:50:1689:50 | SideEffect | m1689_3 |
75297529
| ir.cpp:1689:50:1689:50 | SideEffect | m1689_8 |
7530+
| ir.cpp:1693:5:1693:21 | Address | &:r1693_5 |
7531+
| ir.cpp:1693:5:1693:21 | ChiPartial | partial:m1693_3 |
7532+
| ir.cpp:1693:5:1693:21 | ChiTotal | total:m1693_2 |
7533+
| ir.cpp:1693:5:1693:21 | Load | m1696_4 |
7534+
| ir.cpp:1693:5:1693:21 | SideEffect | m1693_3 |
7535+
| ir.cpp:1694:7:1694:7 | Address | &:r1694_1 |
7536+
| ir.cpp:1694:10:1694:12 | StoreValue | r1694_2 |
7537+
| ir.cpp:1696:3:1696:11 | Address | &:r1696_1 |
7538+
| ir.cpp:1696:10:1696:10 | Address | &:r1696_2 |
7539+
| ir.cpp:1696:10:1696:10 | Load | m1694_3 |
7540+
| ir.cpp:1696:10:1696:10 | StoreValue | r1696_3 |
75307541
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
75317542
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
75327543
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8842,6 +8842,28 @@ ir.cpp:
88428842
# 1689| v1689_12(void) = AliasedUse : ~m?
88438843
# 1689| v1689_13(void) = ExitFunction :
88448844

8845+
# 1693| int goto_on_same_line()
8846+
# 1693| Block 0
8847+
# 1693| v1693_1(void) = EnterFunction :
8848+
# 1693| mu1693_2(unknown) = AliasedDefinition :
8849+
# 1693| mu1693_3(unknown) = InitializeNonLocal :
8850+
# 1694| r1694_1(glval<int>) = VariableAddress[x] :
8851+
# 1694| r1694_2(int) = Constant[42] :
8852+
# 1694| mu1694_3(int) = Store[x] : &:r1694_1, r1694_2
8853+
# 1695| v1695_1(void) = NoOp :
8854+
#-----| Goto (back edge) -> Block 1
8855+
8856+
# 1695| Block 1
8857+
# 1695| v1695_2(void) = NoOp :
8858+
# 1696| r1696_1(glval<int>) = VariableAddress[#return] :
8859+
# 1696| r1696_2(glval<int>) = VariableAddress[x] :
8860+
# 1696| r1696_3(int) = Load[x] : &:r1696_2, ~m?
8861+
# 1696| mu1696_4(int) = Store[#return] : &:r1696_1, r1696_3
8862+
# 1693| r1693_4(glval<int>) = VariableAddress[#return] :
8863+
# 1693| v1693_5(void) = ReturnValue : &:r1693_4, ~m?
8864+
# 1693| v1693_6(void) = AliasedUse : ~m?
8865+
# 1693| v1693_7(void) = ExitFunction :
8866+
88458867
perf-regression.cpp:
88468868
# 6| void Big::Big()
88478869
# 6| Block 0

0 commit comments

Comments
 (0)