Commit Graph

101 Commits

Author SHA1 Message Date
Cornelius Riemenschneider
cf8efbb5a0 Add testcase. 2020-02-03 17:23:24 +01:00
Jonas Jensen
4a77f2b53c Merge remote-tracking branch 'upstream/master' into ir-crement-load
Update test output to fix semantic merge conflict.
2020-01-29 15:56:05 +01:00
Jonas Jensen
9a45c5570d C++: Move Load from AssignmentOperation to its LHS
This is analogous to what was done for `CrementOperation`.
2020-01-24 09:09:31 +01:00
Jonas Jensen
c5950d2c9d C++: IR: Result of x in x++ is now the Load
Previously, the `Load` would be associated with the `CrementOperation`
rather than its operand, which gave surprising results when mapping
taint sinks back to `Expr`.

The changes in `raw_ir.expected` are to add `Copy` operations on the
`x++` in code like `y = x++`. This is now needed because the result that
`x++` would otherwise have (the Load) no longer belongs to the `++`
expression. Copies are inserted to ensure that all expressions are
associated with an `Instruction` result.

The changes in `*aliased_ssa_ir.expected` appear to be just wobble.
2020-01-24 09:02:50 +01:00
Jonas Jensen
66914e52c6 C++: accept test changes 2020-01-22 14:08:05 +01:00
Robert Marsh
e209ed961a Merge branch 'master' into rdmarsh/cpp/ir-callee-side-effects 2019-12-17 15:11:02 -08:00
Jonas Jensen
95a333d28c C++: Use StackVariable in SSA libraries
This means we'll no longer get SSA definitions for thread-local
local-scope variables.
2019-11-19 11:30:59 +01:00
Robert Marsh
180a3c9f26 C++: accept test changes 2019-11-15 11:01:18 -08:00
Jonas Jensen
76a3db9eed Merge remote-tracking branch 'upstream/master' into ir-copy-unloaded-result 2019-11-06 15:21:22 +01:00
Jonas Jensen
b6038f3caa C++: Remove best-bound logic from test
This logic, in an improved form, is now part of the library itself.
2019-10-29 11:54:32 +01:00
Jonas Jensen
311963906b C++: Only give the best delta in range analysis
This mirrors Java's 6b85fe087a.
2019-10-29 11:49:49 +01:00
Jonas Jensen
11da4a5328 C++: Accept test results for GVN and sign analysis 2019-10-24 15:17:16 +02:00
Jonas Jensen
b75bf06649 C++: Accept test changes in other IR tests 2019-09-24 13:00:21 +02:00
Jonas Jensen
4ef5c9af62 C++: Autoformat everything
Some files that will change in #1736 have been spared.

    ./build -j4 target/jars/qlformat
    find ql/cpp/ql -name "*.ql"  -print0 | xargs -0 target/jars/qlformat --input
    find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input
    (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll')
    buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
2019-09-09 11:25:53 +02:00
Robert Marsh
4371d02a1f C++: accept SignAnalysis.expected 2019-05-31 13:35:05 -07:00
Geoffrey White
574a1d8501 Merge pull request #1037 from kevinbackhouse/RangeAnalysisAssignAddOverflow
Better overflow detection for AssignAdd/AssignSub
2019-05-29 09:54:06 +01:00
Geoffrey White
170691b467 CPP: Comment as suggested. 2019-05-24 16:16:45 +01:00
Geoffrey White
d2f386ccb7 CPP: Effect of changes on tests. 2019-05-01 15:56:44 +01:00
Geoffrey White
19e6b238b7 CPP: Add test cases. 2019-05-01 15:43:06 +01:00
Geoffrey White
5101a5bc3d Merge pull request #1056 from jbj/SimpleRangeAnalysis-use-after-cast
C++: Fix use-after-cast bug in SimpleRangeAnalysis
2019-04-10 11:04:20 +01:00
Robert Marsh
fd7512c447 C++: accept test change in SignAnalysis 2019-04-08 14:10:37 -04:00
Robert Marsh
46f93ff322 C++: update test expectations 2019-04-04 10:55:27 -07:00
Jonas Jensen
b827e7a1ea C++: Fix use-after-cast bug in SimpleRangeAnalysis
Like everywhere else in the range analysis, operands to comparison
operators must be considered in their fully-converted form.
2019-03-27 10:48:34 +01:00
Jonas Jensen
ad61b4f55e C++: Add test to demonstrate use-after-cast bugs 2019-03-27 10:48:34 +01:00
Dave Bartolomeo
f5121d71bc C++: Fix range analysis for new API 2019-02-12 09:38:11 -08:00
Robert Marsh
9decbd9c9f C++: new irreducible CFG test for range analysis 2019-01-25 13:12:40 -08:00
Jonas Jensen
6d09a9b324 C++: Enable range analysis for irreducible CFGs
This adds one new test result (`i >= 0` on line 130).
2019-01-25 09:31:07 +01:00
Robert Marsh
c455db9e59 C++: update test expectations 2019-01-10 11:24:13 -08:00
Robert Marsh
0040a2d123 C++: respond to further PR comments 2019-01-08 09:34:28 -08:00
Robert Marsh
8c9c316e1b C++: performance and termination fixes 2019-01-08 09:34:27 -08:00
Robert Marsh
567eee1114 C++: allow phi nodes to self-bound 2019-01-08 09:34:27 -08:00
Robert Marsh
b2cd9a29f2 C++: add test for false comparisons 2019-01-08 09:34:26 -08:00
Robert Marsh
2f8ca8802b C++: switch to using ValueNumbers as bounds
This reduces the number of bounds computed, and will simplify use of the
library. The resulting locations in the tests may be slightly strange,
because the example `Instruction` for a `ValueNumber` is the first
appearing in the IR, regardless of source order, and may not be the most
closely related `Instruction` to the bounded value. I think that's worth
doing for the performance and usability benefits.
2019-01-08 09:34:26 -08:00
Robert Marsh
89148a9ec7 C++: respond to further PR comments 2019-01-08 09:34:26 -08:00
Robert Marsh
ae4ffd9166 C++: respond to PR comments, add some TODOs 2019-01-08 09:34:25 -08:00
Robert Marsh
fe32aea31f C++: fix/add comments 2019-01-08 09:34:25 -08:00
Robert Marsh
ed68f9150a C++: Initial implementation of new range analysis 2019-01-08 09:34:23 -08:00
Robert Marsh
a06a20dbab C++: move SimpleRangeAnalysis tests 2019-01-08 09:34:23 -08:00
Ian Lynagh
98e8858dc6 C++: Accept test changes 2019-01-03 21:09:49 +00:00
Robert Marsh
59c0e5d39e C++: update test expectations 2018-12-11 15:07:09 -08:00
Robert Marsh
d9495da225 C++: fix test 2018-11-09 10:15:28 -08:00
Robert Marsh
4fdc992cd9 C++: IRGuards uses Operand; fix CP in SignAnalysis 2018-11-08 14:43:51 -08:00
Robert Marsh
0d9e2098f2 C++: test for bounded bounds in sign analysis 2018-11-08 11:38:34 -08:00
Robert Marsh
1d7e802157 C++: move sign analysis to new Operand type 2018-11-07 16:07:37 -08:00
Robert Marsh
9d2d381e68 C++: test fixes for sign analysis 2018-11-06 12:02:39 -08:00
Robert Marsh
554fea46c7 C++: Sign analysis for casts and unsigned integers 2018-11-06 12:02:38 -08:00
Robert Marsh
d1ae939c9c C++: use guards and operands in sign analysis 2018-11-06 12:02:38 -08:00
Robert Marsh
a3c6b8e575 C++: port sign analysis library from Java 2018-11-06 12:02:38 -08:00
Jonas Jensen
367776511f C++: Don't use dbtypes in ControlFlowNode etc.
Many classes have been declared with `extends @cfgnode` because they
should be implemented internally as a control-flow node but should not
expose the member predicates of `ControlFlowNode` to their users. After
the transition in a1e44041e it became mandatory to convert explicitly
between the `Element`-derived `ControlFlowNode` and the raw dbtype
`@cfgnode`, and that commit inserted numerous such conversions as a
result of having all those classes that did not derive from `Element` in
the standard library.

It was also confusing and error-prone that the libraries implementing
`ControlFlowNode` referred to `ControlFlowNode`. This seemingly cyclic
reference worked out because the libraries did not call the predicates
on `ControlFlowNode` whose implementation they were part of.

Both these problems are now solved by adding a new class
`ControlFlowNodeBase extends Element` that should be used in preference
to `@cfgnode` everywhere. This class is for exactly those use cases
where `@cfgnode` should be seen as an `Element` without having too many
member predicates on it.

The classes that move from extending `@cfgnode` to extending
`ControlFlowNodeBase` are: `BasicBlock`, `AdditionalControlFlowEdge`,
`DefOrUse`, `SsaDefinition`, `SubBasicBlock` and `RangeSsaDefinition`.
These previously had to define their own `toString` rootdef, which
typically had some dummy string as result (like `"BasicBlock"`), but now
their `toString` is part of the `Element` rootdef and should not be
overridden otherwise `Element.toString` will sometimes have multiple
results. Removing these dummy `toString` predicates had some effects on
the tests that are included in this commit.

The `getLocation` family of predicates is affected like `toString`, but
the situation is slightly different. Some of these classes had genuinely
useful alternative definitions of locations. Fortunately, they all used
`hasLocationInfo`, which is preferred over `getLocation` by the QL
engine. Because `Element` does not define `getLocationInfo`, each class
can create its own rootdef of this predicate like before.
2018-08-28 14:27:32 +02:00
Ian Lynagh
a1e44041ec C++: Use mkElement/unresolveElement consistently 2018-08-20 16:12:26 +01:00