Commit Graph

834 Commits

Author SHA1 Message Date
Arthur Baars
11396ef7cb Rust: avoid multiple PrimaryQLClass warnings
Fixes things like:
```
multiplePrimaryQlClasses
| x | PathExpr,VariableAccess |
```
2024-10-24 15:13:17 +02:00
Arthur Baars
e1c315b288 Rust: make ImplicitVariableAccess instance of VariableAccess 2024-10-24 15:13:14 +02:00
Arthur Baars
1b7b24ecb8 Rust: add Locatable::hasLocationInfo 2024-10-24 15:11:02 +02:00
Arthur Baars
f213a2d640 Rust: CFG for ImplicitVariableAccess 2024-10-24 15:11:01 +02:00
Arthur Baars
8a5fa9b72f Rust: add ImplicitVariableAccess class 2024-10-24 15:11:00 +02:00
Arthur Baars
8f2c7c1239 Rust: parse formatting templates 2024-10-24 15:10:59 +02:00
Tom Hvitved
09c3ac6f81 Rust: Collapse cached CFG logic into one stage 2024-10-24 14:58:19 +02:00
Tom Hvitved
df19281b9f Rust: Introduce AstNode.getEnclosingCallable 2024-10-23 15:31:07 +02:00
Tom Hvitved
086e0c61fc Merge pull request #17817 from hvitved/rust/cfg-scope-callable
Rust: Use `Callable` to define `CfgScope`
2024-10-23 15:24:13 +02:00
Tom Hvitved
60c205ff37 Merge pull request #17818 from hvitved/rust/summary-stats-perf
Rust: Speedup `SummaryStats.ql`
2024-10-22 10:15:56 +02:00
Arthur Baars
490f81437b Merge pull request #17804 from github/aibaars/local-defs-1
Rust: add ide-contextual-queries/localDefinitions.ql
2024-10-21 15:30:44 +02:00
Tom Hvitved
f72af4f1f3 Rust: Use Callable to define CfgScope 2024-10-21 15:22:04 +02:00
Tom Hvitved
c4c936d6fa Rust: Speedup SummaryStats.ql 2024-10-21 15:21:13 +02:00
Tom Hvitved
e9adbf231f Merge pull request #17816 from hvitved/rust/expr-trees-module
Rust: Move all expression CFG trees inside an `ExprTrees` module
2024-10-21 15:12:51 +02:00
Tom Hvitved
a6a68ef8be Apply suggestions from code review
Co-authored-by: Simon Friis Vindum <paldepind@github.com>
2024-10-21 14:43:22 +02:00
Tom Hvitved
1f5e02f539 Rust: Move all expression CFG trees inside an ExprTrees module 2024-10-21 13:41:11 +02:00
Simon Friis Vindum
85e59c9920 Merge branch 'main' into rust-saa-additions 2024-10-21 13:30:02 +02:00
Tom Hvitved
7e82595cae Rust: Fix bad join
Before
```
Evaluated relational algebra for predicate MatchExprImpl::Impl::MatchExpr.getLastArm/0#dispred#24e5f4cf@9cf607tl with tuple counts:
            660677  ~0%    {4} r1 = SCAN `MatchExprImpl::Impl::MatchExpr.getArm/1#dispred#817de8a3` OUTPUT _, In.0, In.2, In.1
            660677  ~0%    {3}    | REWRITE WITH Tmp.0 := 1, Out.0 := (Tmp.0 + In.3) KEEPING 3
        5342095756  ~0%    {3}    | JOIN WITH `MatchArmList::Generated::MatchArmList.getNumberOfArms/0#dispred#9ad72f08_10#join_rhs` ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Lhs.2
             96597  ~3%    {2}    | JOIN WITH `MatchExpr::Generated::MatchExpr.getMatchArmList/0#dispred#11f1a73e` ON FIRST 2 OUTPUT Lhs.0, Lhs.2
                           return r1
```

After
```
Evaluated relational algebra for predicate MatchExprImpl::Impl::MatchExpr.getLastArm/0#dispred#24e5f4cf@9d7a92pu with tuple counts:
        660677   ~0%    {5} r1 = JOIN `MatchExprImpl::Impl::MatchExpr.getArm/1#344daffc` WITH `MatchExprImpl::Impl::MatchExpr.getNumberOfArms/0#ab0d8732` ON FIRST 1 OUTPUT Lhs.0, Lhs.1, Lhs.2, _, Rhs.1
                        {4}    | REWRITE WITH Tmp.3 := 1, Out.3 := (In.4 - Tmp.3), TEST Out.3 = InOut.1 KEEPING 4
         96597   ~3%    {2}    | SCAN OUTPUT In.0, In.2
                        return r1
```
2024-10-21 11:40:13 +02:00
Simon Friis Vindum
9c172f62a4 Rust: Fix dead end in CFG for match expressions with no arms 2024-10-21 09:59:23 +02:00
Arthur Baars
4a5a48a5b6 Rust: move PrintCfg to ide-contextual-queries 2024-10-18 16:11:18 +02:00
Arthur Baars
c9372b91f8 Rust: move ide-contextual-queries to the library pack 2024-10-18 16:11:17 +02:00
Arthur Baars
53744407ad Rust: add localDefinitions.ql 2024-10-18 16:11:08 +02:00
Simon Friis Vindum
b1e85d1ad8 Rust: Refactor BreakExprTree to use StandardPostOrderTree 2024-10-18 13:30:36 +02:00
Simon Friis Vindum
28f111b7c0 Rust: Remove erroneous CFG edge from return to break 2024-10-18 13:26:11 +02:00
Simon Friis Vindum
6568eb80a2 Rust: Refactor CFG pattern tree implementation 2024-10-18 12:52:56 +02:00
Simon Friis Vindum
7aa28a0449 Rust: Fix multiple CFG successors in range pattern without lower bound 2024-10-18 11:19:21 +02:00
Simon Friis Vindum
272d12fee1 Rust: Step correctly over method arguments
Previously the math was wrong and the first argument (with `i` being `0`) had two edges out of it.
2024-10-18 11:19:07 +02:00
Simon Friis Vindum
b2032fc6fd Rust: Only normal completion of a let statement initializer steps to the pattern 2024-10-17 16:28:57 +02:00
Simon Friis Vindum
e6f1edcbb5 Rust: Conditional completion of match arm expression should now flow to next arm 2024-10-17 16:25:19 +02:00
Simon Friis Vindum
04f2062942 Rust: Label the non-return CFG edge out of question mark as match 2024-10-17 16:22:07 +02:00
Simon Friis Vindum
fd5d6255c1 Rust: Avoid creating CFG scopes for trait signatures without implementations 2024-10-17 16:20:30 +02:00
Simon Friis Vindum
2d1c62b6df Rust: Fix dead end in CFG for empty tuple and struct patterns 2024-10-17 10:40:34 +02:00
Geoffrey White
7d62cdad71 Merge pull request #17774 from geoffw0/astcount
Rust: Count number of AST inconsistencies
2024-10-16 14:17:39 +01:00
Simon Friis Vindum
76e1885355 Rust: Make mutable variables that are only borrowed immutably amenable for SSA 2024-10-16 15:07:46 +02:00
Simon Friis Vindum
577afc3fd5 Rust: Support capture of mutable variables in SSA 2024-10-16 14:57:46 +02:00
Geoffrey White
f9eca42ded Merge pull request #17763 from geoffw0/cfgcount3
Rust: Count number of CFG inconsistencies
2024-10-15 15:43:39 +01:00
Geoffrey White
e01ecd1b79 Rust: Calculate a total of AST inconsistencies. 2024-10-15 14:19:42 +01:00
Geoffrey White
2d019eb00e Rust: Add QLDoc to the AST consistency rules and make their output more consistent. 2024-10-15 14:19:40 +01:00
Geoffrey White
414fcf836e Rust: Move the AST consistency logic to a .qll. 2024-10-15 14:19:38 +01:00
Geoffrey White
79c5adfc9a Rust: Use correct versions of the consistency predicates. 2024-10-15 14:10:51 +01:00
Paolo Tranquilli
248eb7f00c Merge branch 'main' into rust/callable-base 2024-10-15 11:03:11 +02:00
Arthur Baars
508e8157b3 Merge pull request #17746 from github/aibaars/macro-pat-irrefutable
Rust: add MacroPat to isExhaustiveMatch
2024-10-15 10:45:06 +02:00
Simon Friis Vindum
cc1e33fb64 Merge pull request #17713 from hvitved/rust/ssa
Rust: Initial SSA implementation
2024-10-15 09:59:48 +02:00
Arthur Baars
ae7afa7aff Update rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll
Co-authored-by: Simon Friis Vindum <simonfv@gmail.com>
2024-10-14 15:20:43 +02:00
Arthur Baars
493a68a232 Rust: add MacroPat to isExhaustiveMatch 2024-10-14 13:55:59 +02:00
Simon Friis Vindum
22261c1480 Rust: Rename isIrrefutablePattern to isExhaustiveMatch 2024-10-14 13:43:57 +02:00
Simon Friis Vindum
e83f1d17bf Rust: Simplify return implementation in CFG 2024-10-14 11:40:35 +02:00
Simon Friis Vindum
8e4e663739 Rust: Handle question mark operator in CFG 2024-10-14 11:38:35 +02:00
Simon Friis Vindum
2f07f1c730 Rust: Abnormal completion in scrutinee does not continue to match arms 2024-10-14 11:32:22 +02:00
Tom Hvitved
6290be2922 Rust: Initial SSA implementation 2024-10-11 19:39:28 +02:00