Skip to content

Commit a1267d7

Browse files
authored
Merge pull request #16139 from MathiasVP/enable-sound-ir
C++: Enable sound IR
2 parents 4d3d07a + 54957d6 commit a1267d7

File tree

8 files changed

+3317
-3085
lines changed

8 files changed

+3317
-3085
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The alias analysis used internally by various libraries has been improved to answer alias questions more conservatively. As a result, some queries may report fewer false positives.

cpp/ql/lib/semmle/code/cpp/ir/implementation/IRConfiguration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ class IREscapeAnalysisConfiguration extends TIREscapeAnalysisConfiguration {
4141
* Holds if the escape analysis done by SSA construction should be sound. By default, the SSA is
4242
* built assuming that no variable's address ever escapes.
4343
*/
44-
predicate useSoundEscapeAnalysis() { none() }
44+
predicate useSoundEscapeAnalysis() { any() }
4545
}

cpp/ql/test/experimental/library-tests/rangeanalysis/arraylengthanalysis/ArrayLengthAnalysisTest.expected

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
| test.cpp:15:8:15:11 | Load: aptr | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 0 |
2-
| test.cpp:19:8:19:8 | Load: a | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
3-
| test.cpp:21:8:21:8 | Load: a | VNLength(Chi: ptr) | -1 | ZeroOffset | 0 |
4-
| test.cpp:23:8:23:8 | Load: a | VNLength(Chi: ptr) | 1 | ZeroOffset | 0 |
5-
| test.cpp:27:8:27:8 | Load: c | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
6-
| test.cpp:28:8:28:24 | Convert: (unsigned char *)... | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
7-
| test.cpp:30:8:30:8 | Load: v | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
2+
| test.cpp:19:8:19:8 | Load: a | VNLength(Load: count) | 0 | ZeroOffset | 0 |
3+
| test.cpp:21:8:21:8 | Load: a | VNLength(Load: count) | -1 | ZeroOffset | 0 |
4+
| test.cpp:23:8:23:8 | Load: a | VNLength(Load: count) | 1 | ZeroOffset | 0 |
5+
| test.cpp:27:8:27:8 | Load: c | VNLength(Load: count) | 0 | ZeroOffset | 0 |
6+
| test.cpp:28:8:28:24 | Convert: (unsigned char *)... | VNLength(Load: count) | 0 | ZeroOffset | 0 |
7+
| test.cpp:30:8:30:8 | Load: v | VNLength(Load: count) | 0 | ZeroOffset | 0 |
88
| test.cpp:34:8:34:12 | Convert: array to pointer conversion | ZeroLength | 100 | ZeroOffset | 0 |
9-
| test.cpp:37:10:37:10 | Load: b | VNLength(Chi: ptr) | 0 | ZeroOffset | 0 |
9+
| test.cpp:37:10:37:10 | Load: b | VNLength(Load: count) | 0 | ZeroOffset | 0 |
1010
| test.cpp:44:8:44:8 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 2 |
1111
| test.cpp:53:10:53:10 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 2 |
1212
| test.cpp:56:10:56:10 | Load: a | VNLength(InitializeParameter: count) | 0 | ZeroOffset | 3 |

cpp/ql/test/experimental/library-tests/rangeanalysis/signanalysis/SignAnalysis.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
| inline_assembly.c:10:3:10:7 | Store: ... = ... | positive strictlyPositive |
1717
| inline_assembly.c:10:7:10:7 | Constant: (unsigned int)... | positive strictlyPositive |
1818
| inline_assembly.c:12:32:12:32 | Load: y | positive strictlyPositive |
19-
| inline_assembly.c:21:32:21:32 | Load: y | positive strictlyPositive |
19+
| inline_assembly.c:21:29:21:29 | Load: x | positive |
20+
| inline_assembly.c:21:32:21:32 | Load: y | positive |
2021
| minmax.c:16:9:16:10 | Constant: 1 | positive strictlyPositive |
2122
| minmax.c:16:9:16:10 | Store: 1 | positive strictlyPositive |
2223
| minmax.c:16:16:16:17 | Constant: 2 | positive strictlyPositive |

cpp/ql/test/library-tests/dataflow/taint-tests/vector.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ void test_vector_output_iterator(int b) {
354354
for(std::vector<int>::iterator it = v4.begin(); it != v4.end(); ++it) {
355355
taint_vector_output_iterator(it);
356356
}
357-
sink(v4); // $ ast,ir
357+
sink(v4); // $ ast MISSING: ir
358358

359359
std::vector<int>::iterator i5 = v5.begin();
360360
*i5 = source();
@@ -389,15 +389,15 @@ void test_vector_output_iterator(int b) {
389389
*i9 = source();
390390
taint_vector_output_iterator(i9);
391391

392-
sink(v9); // $ ast=330:10 ir=330:10 ir SPURIOUS: ast=389:8 ir=389:8
392+
sink(v9); // $ ast=330:10 MISSING: ir SPURIOUS: ast=389:8
393393

394394
std::vector<int>::iterator i10 = v10.begin();
395395
vector_iterator_assign_wrapper(i10, 10);
396396
sink(v10);
397397

398398
std::vector<int>::iterator i11 = v11.begin();
399399
vector_iterator_assign_wrapper(i11, source());
400-
sink(v11); // $ ast,ir
400+
sink(v11); // $ ast MISSING: ir
401401

402402
std::vector<int>::iterator i12 = v12.begin();
403403
*i12++ = 0;

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

Lines changed: 3174 additions & 2958 deletions
Large diffs are not rendered by default.

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ struct S {
99
};
1010

1111
void unique_ptr_init(S s) {
12-
unique_ptr<S> p(new S); //$ussa=dynamic{1}
13-
int i = (*p).x; //$ussa=dynamic{1}[0..4)<int>
14-
*p = s; //$ussa=dynamic{1}[0..4)<S>
12+
unique_ptr<S> p(new S); // MISSING: $ussa=dynamic{1}
13+
int i = (*p).x; //$ MISSING: ussa=dynamic{1}[0..4)<int>
14+
*p = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
1515
unique_ptr<S> q = std::move(p);
16-
*(q.get()) = s; //$ussa=dynamic{1}[0..4)<S>
16+
*(q.get()) = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
1717
shared_ptr<S> t(std::move(q));
18-
t->x = 5; //$ussa=dynamic{1}[0..4)<int>
19-
*t = s; //$ussa=dynamic{1}[0..4)<S>
20-
*(t.get()) = s; //$ussa=dynamic{1}[0..4)<S>
18+
t->x = 5; //$ MISSING: ussa=dynamic{1}[0..4)<int>
19+
*t = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
20+
*(t.get()) = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
2121
}
2222

2323
void shared_ptr_init(S s) {
24-
shared_ptr<S> p(new S); //$ussa=dynamic{1}
25-
int i = (*p).x; //$ussa=dynamic{1}[0..4)<int>
26-
*p = s; //$ussa=dynamic{1}[0..4)<S>
24+
shared_ptr<S> p(new S); //$ MISSING: ussa=dynamic{1}
25+
int i = (*p).x; //$ MISSING: ussa=dynamic{1}[0..4)<int>
26+
*p = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
2727
shared_ptr<S> q = std::move(p);
28-
*(q.get()) = s; //$ussa=dynamic{1}[0..4)<S>
28+
*(q.get()) = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
2929
shared_ptr<S> t(q);
30-
t->x = 5; //$ussa=dynamic{1}[0..4)<int>
31-
*t = s; //$ussa=dynamic{1}[0..4)<S>
32-
*(t.get()) = s; //$ussa=dynamic{1}[0..4)<S>
30+
t->x = 5; //$ MISSING: ussa=dynamic{1}[0..4)<int>
31+
*t = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
32+
*(t.get()) = s; //$ MISSING: ussa=dynamic{1}[0..4)<S>
3333
}

0 commit comments

Comments
 (0)