Skip to content

Commit dc6fd8f

Browse files
authored
Merge pull request github#13666 from jketema/ir-test
C++: Add IR tests that cause regressions after extractor frontend update
2 parents f714de0 + 7bb77ab commit dc6fd8f

File tree

4 files changed

+252
-0
lines changed

4 files changed

+252
-0
lines changed

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

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14462,6 +14462,106 @@ ir.cpp:
1446214462
# 1911| getExpr(): [VariableAccess] x
1446314463
# 1911| Type = [IntType] int
1446414464
# 1911| ValueCategory = prvalue(load)
14465+
# 1914| [TopLevelFunction] int static_function(int)
14466+
# 1914| <params>:
14467+
# 1914| getParameter(0): [Parameter] x
14468+
# 1914| Type = [IntType] int
14469+
# 1914| getEntryPoint(): [BlockStmt] { ... }
14470+
# 1915| getStmt(0): [ReturnStmt] return ...
14471+
# 1915| getExpr(): [VariableAccess] x
14472+
# 1915| Type = [IntType] int
14473+
# 1915| ValueCategory = prvalue(load)
14474+
# 1918| [TopLevelFunction] void test_static_functions_with_assignments()
14475+
# 1918| <params>:
14476+
# 1918| getEntryPoint(): [BlockStmt] { ... }
14477+
# 1919| getStmt(0): [DeclStmt] declaration
14478+
# 1919| getDeclarationEntry(0): [VariableDeclarationEntry] definition of c
14479+
# 1919| Type = [Class] C
14480+
# 1919| getVariable().getInitializer(): [Initializer] initializer for c
14481+
# 1919| getExpr(): [ConstructorCall] call to C
14482+
# 1919| Type = [VoidType] void
14483+
# 1919| ValueCategory = prvalue
14484+
# 1920| getStmt(1): [DeclStmt] declaration
14485+
# 1920| getDeclarationEntry(0): [VariableDeclarationEntry] definition of x
14486+
# 1920| Type = [IntType] int
14487+
# 1921| getStmt(2): [ExprStmt] ExprStmt
14488+
# 1921| getExpr(): [AssignExpr] ... = ...
14489+
# 1921| Type = [IntType] int
14490+
# 1921| ValueCategory = lvalue
14491+
# 1921| getLValue(): [VariableAccess] x
14492+
# 1921| Type = [IntType] int
14493+
# 1921| ValueCategory = lvalue
14494+
# 1921| getRValue(): [FunctionCall] call to StaticMemberFunction
14495+
# 1921| Type = [IntType] int
14496+
# 1921| ValueCategory = prvalue
14497+
# 1921| getQualifier(): [VariableAccess] c
14498+
# 1921| Type = [Class] C
14499+
# 1921| ValueCategory = lvalue
14500+
# 1921| getArgument(0): [Literal] 10
14501+
# 1921| Type = [IntType] int
14502+
# 1921| Value = [Literal] 10
14503+
# 1921| ValueCategory = prvalue
14504+
# 1922| getStmt(3): [DeclStmt] declaration
14505+
# 1922| getDeclarationEntry(0): [VariableDeclarationEntry] definition of y
14506+
# 1922| Type = [IntType] int
14507+
# 1923| getStmt(4): [ExprStmt] ExprStmt
14508+
# 1923| getExpr(): [AssignExpr] ... = ...
14509+
# 1923| Type = [IntType] int
14510+
# 1923| ValueCategory = lvalue
14511+
# 1923| getLValue(): [VariableAccess] y
14512+
# 1923| Type = [IntType] int
14513+
# 1923| ValueCategory = lvalue
14514+
# 1923| getRValue(): [FunctionCall] call to StaticMemberFunction
14515+
# 1923| Type = [IntType] int
14516+
# 1923| ValueCategory = prvalue
14517+
# 1923| getArgument(0): [Literal] 10
14518+
# 1923| Type = [IntType] int
14519+
# 1923| Value = [Literal] 10
14520+
# 1923| ValueCategory = prvalue
14521+
# 1924| getStmt(5): [DeclStmt] declaration
14522+
# 1924| getDeclarationEntry(0): [VariableDeclarationEntry] definition of z
14523+
# 1924| Type = [IntType] int
14524+
# 1925| getStmt(6): [ExprStmt] ExprStmt
14525+
# 1925| getExpr(): [AssignExpr] ... = ...
14526+
# 1925| Type = [IntType] int
14527+
# 1925| ValueCategory = lvalue
14528+
# 1925| getLValue(): [VariableAccess] z
14529+
# 1925| Type = [IntType] int
14530+
# 1925| ValueCategory = lvalue
14531+
# 1925| getRValue(): [FunctionCall] call to static_function
14532+
# 1925| Type = [IntType] int
14533+
# 1925| ValueCategory = prvalue
14534+
# 1925| getArgument(0): [Literal] 10
14535+
# 1925| Type = [IntType] int
14536+
# 1925| Value = [Literal] 10
14537+
# 1925| ValueCategory = prvalue
14538+
# 1926| getStmt(7): [ReturnStmt] return ...
14539+
# 1928| [TopLevelFunction] void test_double_assign()
14540+
# 1928| <params>:
14541+
# 1928| getEntryPoint(): [BlockStmt] { ... }
14542+
# 1929| getStmt(0): [DeclStmt] declaration
14543+
# 1929| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
14544+
# 1929| Type = [IntType] int
14545+
# 1929| getDeclarationEntry(1): [VariableDeclarationEntry] definition of j
14546+
# 1929| Type = [IntType] int
14547+
# 1930| getStmt(1): [ExprStmt] ExprStmt
14548+
# 1930| getExpr(): [AssignExpr] ... = ...
14549+
# 1930| Type = [IntType] int
14550+
# 1930| ValueCategory = lvalue
14551+
# 1930| getLValue(): [VariableAccess] i
14552+
# 1930| Type = [IntType] int
14553+
# 1930| ValueCategory = lvalue
14554+
# 1930| getRValue(): [AssignExpr] ... = ...
14555+
# 1930| Type = [IntType] int
14556+
# 1930| ValueCategory = prvalue
14557+
# 1930| getLValue(): [VariableAccess] j
14558+
# 1930| Type = [IntType] int
14559+
# 1930| ValueCategory = lvalue
14560+
# 1930| getRValue(): [Literal] 40
14561+
# 1930| Type = [IntType] int
14562+
# 1930| Value = [Literal] 40
14563+
# 1930| ValueCategory = prvalue
14564+
# 1931| getStmt(2): [ReturnStmt] return ...
1446514565
perf-regression.cpp:
1446614566
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
1446714567
# 4| <params>:

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,4 +1911,23 @@ int noreturnTest2(int x) {
19111911
return x;
19121912
}
19131913

1914+
int static_function(int x) {
1915+
return x;
1916+
}
1917+
1918+
void test_static_functions_with_assignments() {
1919+
C c;
1920+
int x;
1921+
x = c.StaticMemberFunction(10);
1922+
int y;
1923+
y = C::StaticMemberFunction(10);
1924+
int z;
1925+
z = static_function(10);
1926+
}
1927+
1928+
void test_double_assign() {
1929+
int i, j;
1930+
i = j = 40;
1931+
}
1932+
19141933
// semmle-extractor-options: -std=c++17 --clang

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8821,6 +8821,62 @@
88218821
| ir.cpp:1911:12:1911:12 | Address | &:r1911_2 |
88228822
| ir.cpp:1911:12:1911:12 | Load | m1907_6 |
88238823
| ir.cpp:1911:12:1911:12 | StoreValue | r1911_3 |
8824+
| ir.cpp:1914:5:1914:19 | Address | &:r1914_7 |
8825+
| ir.cpp:1914:5:1914:19 | ChiPartial | partial:m1914_3 |
8826+
| ir.cpp:1914:5:1914:19 | ChiTotal | total:m1914_2 |
8827+
| ir.cpp:1914:5:1914:19 | Load | m1915_4 |
8828+
| ir.cpp:1914:5:1914:19 | SideEffect | m1914_3 |
8829+
| ir.cpp:1914:25:1914:25 | Address | &:r1914_5 |
8830+
| ir.cpp:1915:5:1915:13 | Address | &:r1915_1 |
8831+
| ir.cpp:1915:12:1915:12 | Address | &:r1915_2 |
8832+
| ir.cpp:1915:12:1915:12 | Load | m1914_6 |
8833+
| ir.cpp:1915:12:1915:12 | StoreValue | r1915_3 |
8834+
| ir.cpp:1918:6:1918:43 | ChiPartial | partial:m1918_3 |
8835+
| ir.cpp:1918:6:1918:43 | ChiTotal | total:m1918_2 |
8836+
| ir.cpp:1918:6:1918:43 | SideEffect | ~m1925_5 |
8837+
| ir.cpp:1919:7:1919:7 | Address | &:r1919_1 |
8838+
| ir.cpp:1919:7:1919:7 | Address | &:r1919_1 |
8839+
| ir.cpp:1919:7:1919:7 | Arg(this) | this:r1919_1 |
8840+
| ir.cpp:1919:7:1919:7 | CallTarget | func:r1919_3 |
8841+
| ir.cpp:1919:7:1919:7 | ChiPartial | partial:m1919_5 |
8842+
| ir.cpp:1919:7:1919:7 | ChiPartial | partial:m1919_7 |
8843+
| ir.cpp:1919:7:1919:7 | ChiTotal | total:m1918_4 |
8844+
| ir.cpp:1919:7:1919:7 | ChiTotal | total:m1919_2 |
8845+
| ir.cpp:1919:7:1919:7 | SideEffect | ~m1918_4 |
8846+
| ir.cpp:1920:9:1920:9 | Address | &:r1920_1 |
8847+
| ir.cpp:1921:5:1921:5 | Address | &:r1921_7 |
8848+
| ir.cpp:1921:11:1921:30 | CallTarget | func:r1921_2 |
8849+
| ir.cpp:1921:11:1921:30 | ChiPartial | partial:m1921_5 |
8850+
| ir.cpp:1921:11:1921:30 | ChiTotal | total:m1919_6 |
8851+
| ir.cpp:1921:11:1921:30 | SideEffect | ~m1919_6 |
8852+
| ir.cpp:1921:11:1921:30 | StoreValue | r1921_4 |
8853+
| ir.cpp:1921:32:1921:33 | Arg(0) | 0:r1921_3 |
8854+
| ir.cpp:1922:9:1922:9 | Address | &:r1922_1 |
8855+
| ir.cpp:1923:5:1923:5 | Address | &:r1923_6 |
8856+
| ir.cpp:1923:9:1923:31 | CallTarget | func:r1923_1 |
8857+
| ir.cpp:1923:9:1923:31 | ChiPartial | partial:m1923_4 |
8858+
| ir.cpp:1923:9:1923:31 | ChiTotal | total:m1921_6 |
8859+
| ir.cpp:1923:9:1923:31 | SideEffect | ~m1921_6 |
8860+
| ir.cpp:1923:9:1923:31 | StoreValue | r1923_3 |
8861+
| ir.cpp:1923:33:1923:34 | Arg(0) | 0:r1923_2 |
8862+
| ir.cpp:1924:9:1924:9 | Address | &:r1924_1 |
8863+
| ir.cpp:1925:5:1925:5 | Address | &:r1925_6 |
8864+
| ir.cpp:1925:9:1925:23 | CallTarget | func:r1925_1 |
8865+
| ir.cpp:1925:9:1925:23 | ChiPartial | partial:m1925_4 |
8866+
| ir.cpp:1925:9:1925:23 | ChiTotal | total:m1923_5 |
8867+
| ir.cpp:1925:9:1925:23 | SideEffect | ~m1923_5 |
8868+
| ir.cpp:1925:9:1925:23 | StoreValue | r1925_3 |
8869+
| ir.cpp:1925:25:1925:26 | Arg(0) | 0:r1925_2 |
8870+
| ir.cpp:1928:6:1928:23 | ChiPartial | partial:m1928_3 |
8871+
| ir.cpp:1928:6:1928:23 | ChiTotal | total:m1928_2 |
8872+
| ir.cpp:1928:6:1928:23 | SideEffect | m1928_3 |
8873+
| ir.cpp:1929:7:1929:7 | Address | &:r1929_1 |
8874+
| ir.cpp:1929:10:1929:10 | Address | &:r1929_3 |
8875+
| ir.cpp:1930:3:1930:3 | Address | &:r1930_5 |
8876+
| ir.cpp:1930:7:1930:7 | Address | &:r1930_2 |
8877+
| ir.cpp:1930:7:1930:12 | StoreValue | r1930_4 |
8878+
| ir.cpp:1930:11:1930:12 | StoreValue | r1930_1 |
8879+
| ir.cpp:1930:11:1930:12 | Unary | r1930_1 |
88248880
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
88258881
| perf-regression.cpp:6:3:6:5 | Address | &:r6_5 |
88268882
| perf-regression.cpp:6:3:6:5 | Address | &:r6_7 |

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10167,6 +10167,83 @@ ir.cpp:
1016710167
# 1907| v1907_9(void) = AliasedUse : ~m?
1016810168
# 1907| v1907_10(void) = ExitFunction :
1016910169

10170+
# 1914| int static_function(int)
10171+
# 1914| Block 0
10172+
# 1914| v1914_1(void) = EnterFunction :
10173+
# 1914| mu1914_2(unknown) = AliasedDefinition :
10174+
# 1914| mu1914_3(unknown) = InitializeNonLocal :
10175+
# 1914| r1914_4(glval<int>) = VariableAddress[x] :
10176+
# 1914| mu1914_5(int) = InitializeParameter[x] : &:r1914_4
10177+
# 1915| r1915_1(glval<int>) = VariableAddress[#return] :
10178+
# 1915| r1915_2(glval<int>) = VariableAddress[x] :
10179+
# 1915| r1915_3(int) = Load[x] : &:r1915_2, ~m?
10180+
# 1915| mu1915_4(int) = Store[#return] : &:r1915_1, r1915_3
10181+
# 1914| r1914_6(glval<int>) = VariableAddress[#return] :
10182+
# 1914| v1914_7(void) = ReturnValue : &:r1914_6, ~m?
10183+
# 1914| v1914_8(void) = AliasedUse : ~m?
10184+
# 1914| v1914_9(void) = ExitFunction :
10185+
10186+
# 1918| void test_static_functions_with_assignments()
10187+
# 1918| Block 0
10188+
# 1918| v1918_1(void) = EnterFunction :
10189+
# 1918| mu1918_2(unknown) = AliasedDefinition :
10190+
# 1918| mu1918_3(unknown) = InitializeNonLocal :
10191+
# 1919| r1919_1(glval<C>) = VariableAddress[c] :
10192+
# 1919| mu1919_2(C) = Uninitialized[c] : &:r1919_1
10193+
# 1919| r1919_3(glval<unknown>) = FunctionAddress[C] :
10194+
# 1919| v1919_4(void) = Call[C] : func:r1919_3, this:r1919_1
10195+
# 1919| mu1919_5(unknown) = ^CallSideEffect : ~m?
10196+
# 1919| mu1919_6(C) = ^IndirectMayWriteSideEffect[-1] : &:r1919_1
10197+
# 1920| r1920_1(glval<int>) = VariableAddress[x] :
10198+
# 1920| mu1920_2(int) = Uninitialized[x] : &:r1920_1
10199+
# 1921| r1921_1(glval<C>) = VariableAddress[c] :
10200+
# 1921| r1921_2(glval<unknown>) = FunctionAddress[StaticMemberFunction] :
10201+
# 1921| r1921_3(int) = Constant[10] :
10202+
# 1921| r1921_4(int) = Call[StaticMemberFunction] : func:r1921_2, 0:r1921_3
10203+
# 1921| mu1921_5(unknown) = ^CallSideEffect : ~m?
10204+
# 1921| r1921_6(glval<int>) = VariableAddress[x] :
10205+
# 1921| mu1921_7(int) = Store[x] : &:r1921_6, r1921_4
10206+
# 1922| r1922_1(glval<int>) = VariableAddress[y] :
10207+
# 1922| mu1922_2(int) = Uninitialized[y] : &:r1922_1
10208+
# 1923| r1923_1(glval<unknown>) = FunctionAddress[StaticMemberFunction] :
10209+
# 1923| r1923_2(int) = Constant[10] :
10210+
# 1923| r1923_3(int) = Call[StaticMemberFunction] : func:r1923_1, 0:r1923_2
10211+
# 1923| mu1923_4(unknown) = ^CallSideEffect : ~m?
10212+
# 1923| r1923_5(glval<int>) = VariableAddress[y] :
10213+
# 1923| mu1923_6(int) = Store[y] : &:r1923_5, r1923_3
10214+
# 1924| r1924_1(glval<int>) = VariableAddress[z] :
10215+
# 1924| mu1924_2(int) = Uninitialized[z] : &:r1924_1
10216+
# 1925| r1925_1(glval<unknown>) = FunctionAddress[static_function] :
10217+
# 1925| r1925_2(int) = Constant[10] :
10218+
# 1925| r1925_3(int) = Call[static_function] : func:r1925_1, 0:r1925_2
10219+
# 1925| mu1925_4(unknown) = ^CallSideEffect : ~m?
10220+
# 1925| r1925_5(glval<int>) = VariableAddress[z] :
10221+
# 1925| mu1925_6(int) = Store[z] : &:r1925_5, r1925_3
10222+
# 1926| v1926_1(void) = NoOp :
10223+
# 1918| v1918_4(void) = ReturnVoid :
10224+
# 1918| v1918_5(void) = AliasedUse : ~m?
10225+
# 1918| v1918_6(void) = ExitFunction :
10226+
10227+
# 1928| void test_double_assign()
10228+
# 1928| Block 0
10229+
# 1928| v1928_1(void) = EnterFunction :
10230+
# 1928| mu1928_2(unknown) = AliasedDefinition :
10231+
# 1928| mu1928_3(unknown) = InitializeNonLocal :
10232+
# 1929| r1929_1(glval<int>) = VariableAddress[i] :
10233+
# 1929| mu1929_2(int) = Uninitialized[i] : &:r1929_1
10234+
# 1929| r1929_3(glval<int>) = VariableAddress[j] :
10235+
# 1929| mu1929_4(int) = Uninitialized[j] : &:r1929_3
10236+
# 1930| r1930_1(int) = Constant[40] :
10237+
# 1930| r1930_2(glval<int>) = VariableAddress[j] :
10238+
# 1930| mu1930_3(int) = Store[j] : &:r1930_2, r1930_1
10239+
# 1930| r1930_4(int) = CopyValue : r1930_1
10240+
# 1930| r1930_5(glval<int>) = VariableAddress[i] :
10241+
# 1930| mu1930_6(int) = Store[i] : &:r1930_5, r1930_4
10242+
# 1931| v1931_1(void) = NoOp :
10243+
# 1928| v1928_4(void) = ReturnVoid :
10244+
# 1928| v1928_5(void) = AliasedUse : ~m?
10245+
# 1928| v1928_6(void) = ExitFunction :
10246+
1017010247
perf-regression.cpp:
1017110248
# 6| void Big::Big()
1017210249
# 6| Block 0

0 commit comments

Comments
 (0)