C++: Accept test changes after changes in IR generation

This commit is contained in:
Jeroen Ketema
2023-09-25 11:22:21 +02:00
parent 2a64552979
commit a972d0943a
4 changed files with 78 additions and 44 deletions

View File

@@ -36,9 +36,6 @@ edges
| test.cpp:143:18:143:21 | asdf | test.cpp:134:25:134:27 | arr |
| test.cpp:143:18:143:21 | asdf | test.cpp:143:18:143:21 | asdf |
| test.cpp:146:26:146:26 | p indirection | test.cpp:147:4:147:9 | -- ... |
| test.cpp:146:26:146:26 | p indirection | test.cpp:148:6:148:9 | * ... |
| test.cpp:146:26:146:26 | p indirection | test.cpp:149:6:149:9 | * ... |
| test.cpp:146:26:146:26 | p indirection | test.cpp:150:6:150:9 | * ... |
| test.cpp:156:12:156:14 | buf | test.cpp:156:12:156:18 | ... + ... |
| test.cpp:156:12:156:18 | ... + ... | test.cpp:158:17:158:18 | & ... indirection |
| test.cpp:158:17:158:18 | & ... indirection | test.cpp:146:26:146:26 | p indirection |
@@ -126,9 +123,6 @@ nodes
| test.cpp:143:18:143:21 | asdf | semmle.label | asdf |
| test.cpp:146:26:146:26 | p indirection | semmle.label | p indirection |
| test.cpp:147:4:147:9 | -- ... | semmle.label | -- ... |
| test.cpp:148:6:148:9 | * ... | semmle.label | * ... |
| test.cpp:149:6:149:9 | * ... | semmle.label | * ... |
| test.cpp:150:6:150:9 | * ... | semmle.label | * ... |
| test.cpp:156:12:156:14 | buf | semmle.label | buf |
| test.cpp:156:12:156:18 | ... + ... | semmle.label | ... + ... |
| test.cpp:158:17:158:18 | & ... indirection | semmle.label | & ... indirection |
@@ -182,9 +176,6 @@ subpaths
| test.cpp:128:9:128:14 | PointerAdd: access to array | test.cpp:128:9:128:11 | arr | test.cpp:128:9:128:14 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:125:11:125:13 | arr | arr | test.cpp:128:9:128:18 | Store: ... = ... | write |
| test.cpp:136:9:136:16 | PointerAdd: ... += ... | test.cpp:143:18:143:21 | asdf | test.cpp:138:13:138:15 | arr | This pointer arithmetic may have an off-by-2 error allowing it to overrun $@ at this $@. | test.cpp:142:10:142:13 | asdf | asdf | test.cpp:138:12:138:15 | Load: * ... | read |
| test.cpp:156:12:156:18 | PointerAdd: ... + ... | test.cpp:156:12:156:14 | buf | test.cpp:147:4:147:9 | -- ... | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:154:7:154:9 | buf | buf | test.cpp:147:3:147:13 | Store: ... = ... | write |
| test.cpp:156:12:156:18 | PointerAdd: ... + ... | test.cpp:156:12:156:14 | buf | test.cpp:148:6:148:9 | * ... | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:154:7:154:9 | buf | buf | test.cpp:147:3:147:13 | Store: ... = ... | write |
| test.cpp:156:12:156:18 | PointerAdd: ... + ... | test.cpp:156:12:156:14 | buf | test.cpp:149:6:149:9 | * ... | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:154:7:154:9 | buf | buf | test.cpp:148:3:148:13 | Store: ... = ... | write |
| test.cpp:156:12:156:18 | PointerAdd: ... + ... | test.cpp:156:12:156:14 | buf | test.cpp:150:6:150:9 | * ... | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:154:7:154:9 | buf | buf | test.cpp:149:3:149:13 | Store: ... = ... | write |
| test.cpp:221:5:221:11 | PointerAdd: access to array | test.cpp:218:23:218:28 | buffer | test.cpp:221:5:221:11 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:217:19:217:24 | buffer | buffer | test.cpp:221:5:221:15 | Store: ... = ... | write |
| test.cpp:232:5:232:10 | PointerAdd: access to array | test.cpp:229:25:229:29 | array | test.cpp:232:5:232:10 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:228:10:228:14 | array | array | test.cpp:232:5:232:19 | Store: ... = ... | write |
| test.cpp:261:27:261:30 | PointerAdd: access to array | test.cpp:286:19:286:25 | buffer2 | test.cpp:261:27:261:30 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:285:19:285:25 | buffer2 | buffer2 | test.cpp:261:27:261:30 | Load: access to array | read |

View File

@@ -165,9 +165,9 @@ void test_map()
// array-like access
std::map<char *, char *> m10, m11, m12, m13;
sink(m10["abc"] = "def");
sink(m11["abc"] = source()); // $ ast ir=168:7 ir=168:20
sink(m11["abc"] = source()); // $ ast,ir
sink(m12.at("abc") = "def");
sink(m13.at("abc") = source()); // $ ast ir=170:7 ir=170:23
sink(m13.at("abc") = source()); // $ ast,ir
sink(m10["abc"]);
sink(m11["abc"]); // $ ast,ir
sink(m12["abc"]);
@@ -317,9 +317,9 @@ void test_unordered_map()
// array-like access
std::unordered_map<char *, char *> m10, m11, m12, m13;
sink(m10["abc"] = "def");
sink(m11["abc"] = source()); // $ ast ir=320:7 ir=320:20
sink(m11["abc"] = source()); // $ ast,ir
sink(m12.at("abc") = "def");
sink(m13.at("abc") = source()); // $ ast ir=322:7 ir=322:23
sink(m13.at("abc") = source()); // $ ast,ir
sink(m10["abc"]);
sink(m11["abc"]); // $ ast,ir
sink(m12["abc"]);

View File

@@ -13,8 +13,8 @@ void arithAssignments(int source1, int clean1) {
source1++;
++source1;
source1 += 1;
sink(source1); // $ ast ir=12:13 ir=12:22
sink(++source1); // $ ast ir=12:13 ir=12:22
sink(source1); // $ ast,ir
sink(++source1); // $ ast,ir
}
// --- globals ---

View File

@@ -765,7 +765,7 @@ ir.c:
# 9| r9_6(glval<int>) = FieldAddress[y] : r9_5
# 9| m9_7(int) = Store[?] : &:r9_6, r9_4
# 9| m9_8((unnamed class/struct/union)) = Chi : total:m8_10, partial:m9_7
# 9| r9_9(int) = CopyValue : r9_4
# 9| r9_9(int) = Load[?] : &:r9_6, m9_7
# 9| r9_10(glval<(unnamed class/struct/union)>) = VariableAddress[coords] :
# 9| r9_11(glval<int>) = FieldAddress[x] : r9_10
# 9| m9_12(int) = Store[?] : &:r9_11, r9_9
@@ -1187,15 +1187,17 @@ ir.cpp:
# 101| r101_3(int) = Constant[1] :
# 101| r101_4(int) = Add : r101_2, r101_3
# 101| m101_5(int) = Store[x] : &:r101_1, r101_4
# 101| r101_6(glval<int>) = VariableAddress[y] :
# 101| m101_7(int) = Store[y] : &:r101_6, r101_4
# 101| r101_6(int) = Load[x] : &:r101_1, m101_5
# 101| r101_7(glval<int>) = VariableAddress[y] :
# 101| m101_8(int) = Store[y] : &:r101_7, r101_6
# 102| r102_1(glval<int>) = VariableAddress[x] :
# 102| r102_2(int) = Load[x] : &:r102_1, m101_5
# 102| r102_3(int) = Constant[1] :
# 102| r102_4(int) = Sub : r102_2, r102_3
# 102| m102_5(int) = Store[x] : &:r102_1, r102_4
# 102| r102_6(glval<int>) = VariableAddress[y] :
# 102| m102_7(int) = Store[y] : &:r102_6, r102_4
# 102| r102_6(int) = Load[x] : &:r102_1, m102_5
# 102| r102_7(glval<int>) = VariableAddress[y] :
# 102| m102_8(int) = Store[y] : &:r102_7, r102_6
# 103| r103_1(glval<int>) = VariableAddress[x] :
# 103| r103_2(int) = Load[x] : &:r103_1, m102_5
# 103| r103_3(int) = Constant[1] :
@@ -1407,15 +1409,17 @@ ir.cpp:
# 147| r147_3(float) = Constant[1.0] :
# 147| r147_4(float) = Add : r147_2, r147_3
# 147| m147_5(float) = Store[x] : &:r147_1, r147_4
# 147| r147_6(glval<float>) = VariableAddress[y] :
# 147| m147_7(float) = Store[y] : &:r147_6, r147_4
# 147| r147_6(float) = Load[x] : &:r147_1, m147_5
# 147| r147_7(glval<float>) = VariableAddress[y] :
# 147| m147_8(float) = Store[y] : &:r147_7, r147_6
# 148| r148_1(glval<float>) = VariableAddress[x] :
# 148| r148_2(float) = Load[x] : &:r148_1, m147_5
# 148| r148_3(float) = Constant[1.0] :
# 148| r148_4(float) = Sub : r148_2, r148_3
# 148| m148_5(float) = Store[x] : &:r148_1, r148_4
# 148| r148_6(glval<float>) = VariableAddress[y] :
# 148| m148_7(float) = Store[y] : &:r148_6, r148_4
# 148| r148_6(float) = Load[x] : &:r148_1, m148_5
# 148| r148_7(glval<float>) = VariableAddress[y] :
# 148| m148_8(float) = Store[y] : &:r148_7, r148_6
# 149| r149_1(glval<float>) = VariableAddress[x] :
# 149| r149_2(float) = Load[x] : &:r149_1, m148_5
# 149| r149_3(float) = Constant[1.0] :
@@ -1723,15 +1727,17 @@ ir.cpp:
# 207| r207_3(int) = Constant[1] :
# 207| r207_4(int *) = PointerAdd[4] : r207_2, r207_3
# 207| m207_5(int *) = Store[p] : &:r207_1, r207_4
# 207| r207_6(glval<int *>) = VariableAddress[q] :
# 207| m207_7(int *) = Store[q] : &:r207_6, r207_4
# 207| r207_6(int *) = Load[p] : &:r207_1, m207_5
# 207| r207_7(glval<int *>) = VariableAddress[q] :
# 207| m207_8(int *) = Store[q] : &:r207_7, r207_6
# 208| r208_1(glval<int *>) = VariableAddress[p] :
# 208| r208_2(int *) = Load[p] : &:r208_1, m207_5
# 208| r208_3(int) = Constant[1] :
# 208| r208_4(int *) = PointerSub[4] : r208_2, r208_3
# 208| m208_5(int *) = Store[p] : &:r208_1, r208_4
# 208| r208_6(glval<int *>) = VariableAddress[q] :
# 208| m208_7(int *) = Store[q] : &:r208_6, r208_4
# 208| r208_6(int *) = Load[p] : &:r208_1, m208_5
# 208| r208_7(glval<int *>) = VariableAddress[q] :
# 208| m208_8(int *) = Store[q] : &:r208_7, r208_6
# 209| r209_1(glval<int *>) = VariableAddress[p] :
# 209| r209_2(int *) = Load[p] : &:r209_1, m208_5
# 209| r209_3(int) = Constant[1] :
@@ -6049,6 +6055,27 @@ ir.cpp:
# 1038| v1038_10(void) = AliasedUse : ~m1038_8
# 1038| v1038_11(void) = ExitFunction :
# 1038| void (lambda [] type at line 1038, col. 12)::(unnamed constructor)((lambda [] type at line 1038, col. 12)&&)
# 1038| Block 0
# 1038| v1038_1(void) = EnterFunction :
# 1038| m1038_2(unknown) = AliasedDefinition :
# 1038| m1038_3(unknown) = InitializeNonLocal :
# 1038| m1038_4(unknown) = Chi : total:m1038_2, partial:m1038_3
# 1038| r1038_5(glval<unknown>) = VariableAddress[#this] :
# 1038| m1038_6(glval<decltype([...](...){...})>) = InitializeParameter[#this] : &:r1038_5
# 1038| r1038_7(glval<decltype([...](...){...})>) = Load[#this] : &:r1038_5, m1038_6
# 1038| m1038_8(decltype([...](...){...})) = InitializeIndirection[#this] : &:r1038_7
#-----| r0_1(glval<lambda [] type at line 1038, col. 12 &&>) = VariableAddress[(unnamed parameter 0)] :
#-----| m0_2(lambda [] type at line 1038, col. 12 &&) = InitializeParameter[(unnamed parameter 0)] : &:r0_1
#-----| r0_3(lambda [] type at line 1038, col. 12 &&) = Load[(unnamed parameter 0)] : &:r0_1, m0_2
#-----| m0_4(unknown) = InitializeIndirection[(unnamed parameter 0)] : &:r0_3
# 1038| v1038_9(void) = NoOp :
# 1038| v1038_10(void) = ReturnIndirection[#this] : &:r1038_7, m1038_8
#-----| v0_5(void) = ReturnIndirection[(unnamed parameter 0)] : &:r0_3, m0_4
# 1038| v1038_11(void) = ReturnVoid :
# 1038| v1038_12(void) = AliasedUse : m1038_3
# 1038| v1038_13(void) = ExitFunction :
# 1038| void (lambda [] type at line 1038, col. 12)::operator()() const
# 1038| Block 0
# 1038| v1038_1(void) = EnterFunction :
@@ -6265,6 +6292,27 @@ ir.cpp:
# 1040| v1040_13(void) = AliasedUse : ~m1055_7
# 1040| v1040_14(void) = ExitFunction :
# 1041| void (void Lambda(int, String const&))::(lambda [] type at line 1041, col. 23)::(unnamed constructor)((void Lambda(int, String const&))::(lambda [] type at line 1041, col. 23)&&)
# 1041| Block 0
# 1041| v1041_1(void) = EnterFunction :
# 1041| m1041_2(unknown) = AliasedDefinition :
# 1041| m1041_3(unknown) = InitializeNonLocal :
# 1041| m1041_4(unknown) = Chi : total:m1041_2, partial:m1041_3
# 1041| r1041_5(glval<unknown>) = VariableAddress[#this] :
# 1041| m1041_6(glval<decltype([...](...){...})>) = InitializeParameter[#this] : &:r1041_5
# 1041| r1041_7(glval<decltype([...](...){...})>) = Load[#this] : &:r1041_5, m1041_6
# 1041| m1041_8(decltype([...](...){...})) = InitializeIndirection[#this] : &:r1041_7
#-----| r0_1(glval<lambda [] type at line 1041, col. 23 &&>) = VariableAddress[(unnamed parameter 0)] :
#-----| m0_2(lambda [] type at line 1041, col. 23 &&) = InitializeParameter[(unnamed parameter 0)] : &:r0_1
#-----| r0_3(lambda [] type at line 1041, col. 23 &&) = Load[(unnamed parameter 0)] : &:r0_1, m0_2
#-----| m0_4(unknown) = InitializeIndirection[(unnamed parameter 0)] : &:r0_3
# 1041| v1041_9(void) = NoOp :
# 1041| v1041_10(void) = ReturnIndirection[#this] : &:r1041_7, m1041_8
#-----| v0_5(void) = ReturnIndirection[(unnamed parameter 0)] : &:r0_3, m0_4
# 1041| v1041_11(void) = ReturnVoid :
# 1041| v1041_12(void) = AliasedUse : m1041_3
# 1041| v1041_13(void) = ExitFunction :
# 1041| char (void Lambda(int, String const&))::(lambda [] type at line 1041, col. 23)::operator()(float) const
# 1041| Block 0
# 1041| v1041_1(void) = EnterFunction :
@@ -8156,7 +8204,6 @@ ir.cpp:
# 1376| m1376_4(unknown) = ^CallSideEffect : ~m1374_11
# 1376| m1376_5(unknown) = Chi : total:m1374_11, partial:m1376_4
# 1376| m1376_6(String) = Store[#temp1376:5] : &:r1376_1, r1376_3
# 1376| r1376_7(String) = Load[#temp1376:5] : &:r1376_1, m1376_6
# 1377| v1377_1(void) = NoOp :
# 1365| v1365_5(void) = ReturnVoid :
# 1365| v1365_6(void) = AliasedUse : ~m1376_5
@@ -8232,7 +8279,6 @@ ir.cpp:
# 1388| m1388_4(unknown) = ^CallSideEffect : ~m1386_10
# 1388| m1388_5(unknown) = Chi : total:m1386_10, partial:m1388_4
# 1388| m1388_6(destructor_only) = Store[#temp1388:5] : &:r1388_1, r1388_3
# 1388| r1388_7(destructor_only) = Load[#temp1388:5] : &:r1388_1, m1388_6
# 1389| v1389_1(void) = NoOp :
# 1379| v1379_5(void) = ReturnVoid :
# 1379| v1379_6(void) = AliasedUse : ~m1388_5
@@ -8327,7 +8373,6 @@ ir.cpp:
# 1399| m1399_4(unknown) = ^CallSideEffect : ~m1398_10
# 1399| m1399_5(unknown) = Chi : total:m1398_10, partial:m1399_4
# 1399| m1399_6(copy_constructor) = Store[#temp1399:5] : &:r1399_1, r1399_3
# 1399| r1399_7(copy_constructor) = Load[#temp1399:5] : &:r1399_1, m1399_6
# 1401| r1401_1(glval<int>) = VariableAddress[y] :
# 1401| r1401_2(glval<copy_constructor>) = VariableAddress[#temp1401:13] :
# 1401| r1401_3(glval<unknown>) = FunctionAddress[returnValue] :
@@ -9841,14 +9886,11 @@ ir.cpp:
# 1713| m1713_2(TrivialLambdaClass) = Uninitialized[l1] : &:r1713_1
# 1714| r1714_1(glval<TrivialLambdaClass &>) = VariableAddress[l2] :
# 1714| r1714_2(glval<TrivialLambdaClass>) = VariableAddress[#temp1714:36] :
# 1714| r1714_3(glval<TrivialLambdaClass>) = VariableAddress[#temp1714:36] :
# 1714| r1714_4(TrivialLambdaClass) = Constant[0] :
# 1714| m1714_5(TrivialLambdaClass) = Store[#temp1714:36] : &:r1714_3, r1714_4
# 1714| r1714_6(TrivialLambdaClass) = Load[#temp1714:36] : &:r1714_3, m1714_5
# 1714| m1714_7(TrivialLambdaClass) = Store[#temp1714:36] : &:r1714_2, r1714_6
# 1714| r1714_8(glval<TrivialLambdaClass>) = Convert : r1714_2
# 1714| r1714_9(TrivialLambdaClass &) = CopyValue : r1714_8
# 1714| m1714_10(TrivialLambdaClass &) = Store[l2] : &:r1714_1, r1714_9
# 1714| r1714_3(TrivialLambdaClass) = Constant[0] :
# 1714| m1714_4(TrivialLambdaClass) = Store[#temp1714:36] : &:r1714_2, r1714_3
# 1714| r1714_5(glval<TrivialLambdaClass>) = Convert : r1714_2
# 1714| r1714_6(TrivialLambdaClass &) = CopyValue : r1714_5
# 1714| m1714_7(TrivialLambdaClass &) = Store[l2] : &:r1714_1, r1714_6
# 1716| r1716_1(glval<decltype([...](...){...})>) = VariableAddress[l_outer1] :
# 1716| r1716_2(glval<decltype([...](...){...})>) = VariableAddress[#temp1716:20] :
# 1716| m1716_3(decltype([...](...){...})) = Uninitialized[#temp1716:20] : &:r1716_2
@@ -9876,8 +9918,8 @@ ir.cpp:
# 1716| m1716_19(decltype([...](...){...})) = Chi : total:m0_6, partial:m1716_18
# 1716| r1716_20(glval<TrivialLambdaClass>) = FieldAddress[l2] : r1716_2
# 1716| r1716_21(glval<TrivialLambdaClass &>) = VariableAddress[l2] :
# 1716| r1716_22(TrivialLambdaClass &) = Load[l2] : &:r1716_21, m1714_10
#-----| r0_7(TrivialLambdaClass) = Load[?] : &:r1716_22, m1714_7
# 1716| r1716_22(TrivialLambdaClass &) = Load[l2] : &:r1716_21, m1714_7
#-----| r0_7(TrivialLambdaClass) = Load[?] : &:r1716_22, m1714_4
#-----| m0_8(TrivialLambdaClass) = Store[?] : &:r1716_20, r0_7
#-----| m0_9(decltype([...](...){...})) = Chi : total:m1716_19, partial:m0_8
# 1716| r1716_23(decltype([...](...){...})) = Load[#temp1716:20] : &:r1716_2, m0_9
@@ -11011,7 +11053,7 @@ ir.cpp:
# 1930| r1930_1(int) = Constant[40] :
# 1930| r1930_2(glval<int>) = VariableAddress[j] :
# 1930| m1930_3(int) = Store[j] : &:r1930_2, r1930_1
# 1930| r1930_4(int) = CopyValue : r1930_1
# 1930| r1930_4(int) = Load[j] : &:r1930_2, m1930_3
# 1930| r1930_5(glval<int>) = VariableAddress[i] :
# 1930| m1930_6(int) = Store[i] : &:r1930_5, r1930_4
# 1931| v1931_1(void) = NoOp :
@@ -11035,8 +11077,9 @@ ir.cpp:
# 1935| r1935_3(int) = Load[j] : &:r1935_2, m1934_5
# 1935| r1935_4(int) = Add : r1935_3, r1935_1
# 1935| m1935_5(int) = Store[j] : &:r1935_2, r1935_4
# 1935| r1935_6(glval<int>) = VariableAddress[i] :
# 1935| m1935_7(int) = Store[i] : &:r1935_6, r1935_4
# 1935| r1935_6(int) = Load[j] : &:r1935_2, m1935_5
# 1935| r1935_7(glval<int>) = VariableAddress[i] :
# 1935| m1935_8(int) = Store[i] : &:r1935_7, r1935_6
# 1936| v1936_1(void) = NoOp :
# 1933| v1933_5(void) = ReturnVoid :
# 1933| v1933_6(void) = AliasedUse : m1933_3