Commit Graph

4510 Commits

Author SHA1 Message Date
Dave Bartolomeo
939bfae6e0 Fix formatting 2020-10-18 08:32:08 -04:00
Dave Bartolomeo
eb9cea48b8 Fix modeling of std::set::emplace 2020-10-17 17:00:29 -04:00
Dave Bartolomeo
40cd96eb1d Merge from main 2020-10-17 15:14:26 -04:00
Dave Bartolomeo
4e0afb0dc3 Print targets of Load and Store instructions in IR dump 2020-10-17 15:01:45 -04:00
Dave Bartolomeo
4814dcf145 Print partial flow info in PrintIRLocalFlow.qll 2020-10-17 14:32:31 -04:00
Dave Bartolomeo
a80c6fbf97 C++: Print target variable name for Load and Store, if known
Now that we've started printing the targets of `Call` instructions in the IR dumps, I figured I might as well print the names of the variable being loaded or stored as well. We could potentially extend this to match fields, array elements, etc., but that's quite a bit more work.
2020-10-17 14:21:27 -04:00
Dave Bartolomeo
100f13f202 C++: Annotate IR with partial flow info
I've added one more property to the annotations provided by `PrintIRLocalFlow.qll`: The `pflow` property will now be emitted for any operand or instruction for which `configuration.hasPartialFlow` determines that there is partial flow to that node. This requires that partial flow be enabled via overriding `Configuration::explorationLimit()` in order to display. Otherwise, you'll still just get the local flow info as before.
2020-10-17 13:17:08 -04:00
Dave Bartolomeo
1dae8f62c1 Model copy-ish constructors for std::pair 2020-10-17 11:33:20 -04:00
Dave Bartolomeo
686f5aa8ed Handle parameter indirections in make_shared and make_unique 2020-10-17 08:53:55 -04:00
Dave Bartolomeo
cf19fcf4c0 C++: Improve dataflow model for copy/move constructors 2020-10-16 16:55:59 -04:00
Robert Marsh
4766492e39 C++: respond to PR comments on output iterators 2020-10-16 13:47:20 -07:00
Dave Bartolomeo
9afddf0dad Insert a load of the temporary object for arguments passed by value 2020-10-16 12:56:46 -04:00
Dave Bartolomeo
6a9ecf7ba2 Dump static call target for Call instructions 2020-10-16 12:55:30 -04:00
Dave Bartolomeo
6a6eadcf50 C++: Print static call target for Call instruction in dumps 2020-10-16 11:53:27 -04:00
Vadim Peretokin
8933bbd672 Add modern C++ variant 2020-10-16 17:11:41 +02:00
Anders Schack-Mulligen
b352605d12 Dataflow: Code review fixes. 2020-10-16 13:45:51 +02:00
Anders Schack-Mulligen
664f04020f Revert "Dataflow: Count callables instead of nodes for fieldFlowBranchLimit."
This reverts commit 1501a40de8.
2020-10-16 12:51:50 +02:00
Anders Schack-Mulligen
1501a40de8 Dataflow: Count callables instead of nodes for fieldFlowBranchLimit. 2020-10-16 12:51:17 +02:00
Anders Schack-Mulligen
6aae51fa4f Dataflow: Sync. 2020-10-16 12:51:17 +02:00
Tom Hvitved
5f01fda1ef Data flow: Sync files 2020-10-16 09:05:02 +02:00
Anders Schack-Mulligen
94f110f739 Sync. 2020-10-16 09:05:01 +02:00
Tom Hvitved
d608138c0c Data flow: Sync files 2020-10-16 09:03:13 +02:00
Mathias Vorreiter Pedersen
da9e33a72c Merge pull request #4477 from dbartol/dbartol/PrintIRLocalFlow
C++: Add ability to dump local dataflow info in IR dumps
2020-10-15 17:38:16 +02:00
Dave Bartolomeo
f32a7be874 Fix formatting 2020-10-15 10:16:13 -04:00
Remco Vermeulen
7848c5f54d Fix qldoc for getIncludeText
The '<' was HTML encoded for some reason.
2020-10-15 11:49:18 +02:00
Dave Bartolomeo
dfb687fd47 C++: Add ability to dump local dataflow info in IR dumps
This change adds a new module, `PrintIRLocalFlow.qll`, which can be imported into any query that uses both `PrintIR.qll` and the IR dataflow library. The IR dump printed by `PrintIR.qll` will be annotated with information about how each operand and instruction participates in dataflow.

For each operand and instruction, the following propeties are displayed:
- `flow`: Which local operands/instructions have flow to this node, and which local operands/instruction this node has flow to.
- `source`: `true` if this node is a source
- `sink`: `true` if this node is a sink
- `barrier`: Lists which kinds of barrier this node is. Can be zero or more of `full`, `in`, `out`, and `guard`. If the node is a guard barrier, the IR of the guarding instruction is also printed.

We already had a way to print additional properties for instructions and blocks, but not for operands. I added support for operand properties to `IRPropertyProvider`. These are now printed in a curly-brace-enclosed list immediately after the corresponding operand.

When printing flow, instructions are identified by their result ID (e.g., `m128`). Operands are identified by both the result ID of their instruction and their kind (e.g., `r145.left`). For flow from an operand to its use instruction, it just prints `result` at the operand, and prints only the operand kind on the instruction.

Example output:
```
#  344|     m344_34(vector<int, allocator<int>>)                                               = Chi                             : total:m344_20{flow:def->@, @->result}, partial:m344_33{flow:def->@, @->result}
#  344|         flow = total->@, partial->@, +m344_33->@, @->+r347_3, @->v347_7.side_effect, @->m347_9.total, @->m344_20.1
```
The `+` annotations indicate when the flow came from `isAdditionalFlowStep()`, rather than built-in local flow.
2020-10-14 18:09:54 -04:00
Dave Bartolomeo
794a6729bc C++: Add ability to dump local dataflow info in IR dumps
This change adds a new module, `PrintIRLocalFlow.qll`, which can be imported into any query that uses both `PrintIR.qll` and the IR dataflow library. The IR dump printed by `PrintIR.qll` will be annotated with information about how each operand and instruction participates in dataflow.

For each operand and instruction, the following propeties are displayed:
- `flow`: Which local operands/instructions have flow to this node, and which local operands/instruction this node has flow to.
- `source`: `true` if this node is a source
- `sink`: `true` if this node is a sink
- `barrier`: Lists which kinds of barrier this node is. Can be zero or more of `full`, `in`, `out`, and `guard`. If the node is a guard barrier, the IR of the guarding instruction is also printed.

We already had a way to print additional properties for instructions and blocks, but not for operands. I added support for operand properties to `IRPropertyProvider`. These are now printed in a curly-brace-enclosed list immediately after the corresponding operand.

When printing flow, instructions are identified by their result ID (e.g., `m128`). Operands are identified by both the result ID of their instruction and their kind (e.g., `r145.left`). For flow from an operand to its use instruction, it just prints `result` at the operand, and prints only the operand kind on the instruction.

Example output:
```
#  344|     m344_34(vector<int, allocator<int>>)                                               = Chi                             : total:m344_20{flow:def->@, @->result}, partial:m344_33{flow:def->@, @->result}
#  344|         flow = total->@, partial->@, +m344_33->@, @->+r347_3, @->v347_7.side_effect, @->m347_9.total, @->m344_20.1
```
The `+` annotations indicate when the flow came from `isAdditionalFlowStep()`, rather than built-in local flow.
2020-10-14 18:02:45 -04:00
Robert Marsh
fbe9bc8587 C++: add comments in new iterator models 2020-10-14 13:13:16 -07:00
Robert Marsh
a1a441d759 C++: output iterator flow through operator= models 2020-10-14 13:06:11 -07:00
Robert Marsh
f3843b8a40 Revert "C++: output iterator flow with user-defined operators"
This reverts commit 28fa26629c.
2020-10-14 13:01:37 -07:00
Geoffrey White
09d4b3eb6d Merge branch 'main' into callderef 2020-10-14 17:41:14 +01:00
Robert Marsh
28fa26629c C++: output iterator flow with user-defined operators 2020-10-13 16:30:47 -07:00
Robert Marsh
6552499545 C++: add model for iter-returning functions 2020-10-13 16:19:15 -07:00
Robert Marsh
108cc9ea47 C++: fix assignment to *iter++ 2020-10-13 16:19:15 -07:00
Ian Lynagh
9238503bc3 C++: Make unnamed parameters follow the "(unnamed ...)" naming 2020-10-14 00:10:56 +01:00
Robert Marsh
b49aa677d0 Merge pull request #4459 from geoffw0/setex
C++: Additional taint flows through std::set
2020-10-13 15:17:54 -04:00
Dave Bartolomeo
fba4313457 Merge remote-tracking branch 'upstream/main' into work 2020-10-13 13:07:28 -04:00
Robert Marsh
3b7cf7fd27 Merge pull request #4439 from geoffw0/mapex
C++: Additional taint flows through std::map
2020-10-12 14:17:17 -04:00
Geoffrey White
6440db786d Merge pull request #4420 from jbj/SimpleRangeAnalysis-widen-Expr
C++: SimpleRangeAnalysis: widen recursive *, +, -
2020-10-12 11:20:09 +01:00
Geoffrey White
4363f08b45 C++: Model std::set::emplace and emplace_hint. 2020-10-12 11:01:09 +01:00
Geoffrey White
5d87117dc7 C++: Model std::set::lower_bound, upper_bound, equal_range. 2020-10-12 10:10:40 +01:00
Jonas Jensen
9b12ceae8d C++: SimpleRangeAnalysis: widen recursive *, +, -
The number of candidate bounds during the main `SimpleRangeAnalysis`
recursion was in principle always exponential in the size of the
program, but in practice it did not get out of hand when only `+` and
`-` operations were supported. Now that `*` is also supported, the range
analysis started timing out on the SinaMostafanejad/OpenRDM project. The
problematic expressions in that project are of the form

    a*x*x*x + b*x*x + c*x + d

where most of the variables involved are recursive definitions and are
therefore likely to have a large number of candidate bounds.

The fix here is to identify those few binary operations that are most
likely to cause an explosion in the number of bounds and apply widening
to them. Previously, widening was only applied at definitions.
2020-10-12 11:09:01 +02:00
Geoffrey White
fc19bba0bd C++: Model std::set::merge and correct test annotations. 2020-10-12 10:01:57 +01:00
Anders Schack-Mulligen
725194a3b8 Merge pull request #4447 from aschackmull/dataflow/postupdate-flow-consistency
Dataflow: Introduce consistency check for flow targeting PostUpdateNodes
2020-10-12 08:56:19 +02:00
Geoffrey White
c63f7cb409 C++: Taint through emplace from qualifier to return value. 2020-10-09 17:41:24 +01:00
Geoffrey White
270517d379 C++: Revise model of emplace and emplace_hint. Note that 2 of the 3 taint regressions we shouldn't be getting because we don't yet do taint through keys. 2020-10-09 17:27:18 +01:00
Geoffrey White
61a78e28ac C++: Fix map::merge. 2020-10-09 14:46:23 +01:00
Anders Schack-Mulligen
1c043447e8 Dataflow: Introduce consistency check for flow targeting PostUpdateNodes. 2020-10-09 14:29:52 +02:00
Jonas Jensen
4c9ffcec27 Merge pull request #4396 from geoffw0/stringsets
C++: Use [, ...] syntax more widely.
2020-10-09 13:30:05 +02:00
Geoffrey White
1f1be3bf9a C++: Block try_emplace arg 0. 2020-10-09 10:04:22 +01:00