Commit Graph

3543 Commits

Author SHA1 Message Date
Dave Bartolomeo
53d4a8e3b2 C++: Refactor IR construction interface
Now that `TInstruction` is shared between IR stages, several of the per-stage IR construction predicates can now be moved into the `Raw` interface exposed only by the initial construction of IR from the ASTs. This also removed a couple predicates that were not used previously at all.
2020-06-01 11:15:29 -04:00
Dave Bartolomeo
1e863ac40b C++: Share TInstruction across IR stages
Each stage of the IR reuses the majority of the instructions from previous stages. Previously, we've been wrapping each reused old instruction in a branch of the `TInstruction` type for the next stage. This causes use to create roughly three times as many `TInstruction` objects as we actually need.

Now that IPA union types are supported in the compiler, we can share a single `TInstruction` IPA type across stages. We create a single `TInstruction` IPA type, with individual branches of this type for instructions created directly from the AST (`TRawInstruction`) and for instructions added by each stage of SSA construction (`T*PhiInstruction`, `T*ChiInstruction`, `T*UnreachedInstruction`). Each stage then defines a `TStageInstruction` type that is a union of all of the branches that can appear in that particular stage. The public `Instruction` class for each phase extends the `TStageInstruction` type for that stage.

The interface that each stage exposes to the pyrameterized modules in the IR is now split into three pieces:
- The `Raw` module, exposed only by the original IR construction stage. This module identifies which functions have IR, which `TRawInstruction`s exist, and which `IRVariable`s exist.
- The `SSA` module, exposed only by the two SSA construction stages. This identifiers which `Phi`, `Chi`, and `Unreached` instructions exist.
- The global module, exposed by all three stages. This module has all of the predicates whose implementation is different for each stage, like gathering definitions of `MemoryOperand`s.

Similarly, there is now a single `TIRFunction` IPA type that is shared across all three stages. There is a single `IRFunctionBase` class that exposes the stage-indepdendent predicates; the `IRFunction` class for each stage extends `IRFunctionBase`.

Most of the other changes are largely mechanical.
2020-06-01 11:15:29 -04:00
Robert Brignull
6e0552c074 add more code-scanning suites 2020-06-01 11:45:46 +01:00
Robert Marsh
5ee37bcd5a Merge branch 'master' into ir-this-parameter-2
Bring in fix for duplicate virtual variables for parameter indirections
2020-05-29 14:40:45 -07:00
Robert Marsh
f8cfcef9c9 C++/C#: document isThisIndirection and sync files 2020-05-29 09:52:03 -07:00
Dave Bartolomeo
476f27e427 Merge from master 2020-05-28 17:27:08 -04:00
Robert Marsh
0d8472bd9e Merge pull request #3571 from rdmarsh2/ir-this-parameter
Treat `this` as a parameter in IR generation
2020-05-28 14:16:12 -07:00
Calum Grant
2b90b50587 Merge pull request #3528 from hvitved/csharp/cfg/cs6-initializers
C#: Fix CFG for C# 6 initializers
2020-05-28 21:40:52 +01:00
Robert Marsh
693789c2cc Merge branch 'master' into ir-this-parameter
Bring in new tests so their output can be fixed
2020-05-28 08:32:10 -07:00
Dave Bartolomeo
533eeff7e8 C++: Fix MemoryLocation with multiple VirtualVariables
While investigating a bug with `TInstruction` sharing, I discovered that we had a case where alias analysis could create two `VirtualVariable`s for the same `Allocation`. For an indirect parameter allocation, we were using the type of the pointer variable as the type of the indirect allocation, instead of just `Unknown`. If the `IRType` of the pointer variable was the same type as the type of at least one access to the indirect allocation, we'd create both an `EntireAllocationVirtualVariable` and a `VariableVirtualVariable` for the allocation.

I added a new consistency test to guard against this in the future. This also turned out to be the root cause of the one existing known consistency failure in the IR tests.
2020-05-27 14:06:59 -04:00
Tom Hvitved
1c5da67cd8 C#: Fix performance issue in unification library 2020-05-27 15:26:03 +02:00
Robert Marsh
43520b8f9b C++/C#: Fix copy/pasted qldoc 2020-05-26 09:47:30 -07:00
Jonas Jensen
5deeda0337 Merge pull request #3387 from geoffw0/tostringperf
C++: Eliminate recursion from toString().
2020-05-26 13:24:43 +02:00
Calum Grant
f0499451d3 Merge pull request #3513 from hvitved/csharp/deprecate-override
C#: Remove two deprecated predicates
2020-05-26 12:22:41 +01:00
Jonas Jensen
3d58e6f7af Merge pull request #3515 from hvitved/dataflow/remove-deprecated
Data flow: Remove deprecated predicates
2020-05-25 15:08:28 +02:00
Robert Marsh
1fa1bd5e36 C#: fix compilation error in IR 2020-05-22 16:08:11 -07:00
Robert Marsh
8a53dc882d C++: treat this as a parameter in IR 2020-05-22 15:35:34 -07:00
Tom Hvitved
7a54a90e61 C#: Fix CFG for C# 6 initializers 2020-05-20 12:01:22 +02:00
Tom Hvitved
97080731ad Merge pull request #3486 from h3ku/master
CSHARP: Add experimental query for tainted WebClient
2020-05-20 08:17:05 +02:00
Hector Cuesta
66d77a43bd Fix typo in comment and TaintTrackingConfiguration name 2020-05-19 15:15:03 +01:00
Hector Cuesta
e18d8c5234 Remove duplicated CWE in security tag 2020-05-19 15:12:43 +01:00
Hector Cuesta
7d1ef92fbf Remove unnecessary CWE reference. 2020-05-19 15:09:17 +01:00
Tom Hvitved
431403f5db Data flow: Remove deprecated predicates 2020-05-19 15:42:59 +02:00
Tom Hvitved
2519e8a5f1 C#: Remove more deprecated classes and predicates 2020-05-19 15:39:17 +02:00
Tom Hvitved
9db8b993a9 C#: Remove two deprecated predicates 2020-05-19 15:32:29 +02:00
Dave Bartolomeo
01c2f0ce01 C++/C#: Fix formatting 2020-05-18 18:02:00 -04:00
Dave Bartolomeo
42c659b8f2 C++/C#: Remove UnmodeledDefinition instruction 2020-05-18 15:08:50 -04:00
Dave Bartolomeo
35868d4e5b C++/C#: Change dump of unmodeled use to m?
This is kind of inconsequential on its own, but will make the test diffs easier to understand once the next commit removes `UnmodeledDefinition`.
2020-05-18 10:47:43 -04:00
Mathias Vorreiter Pedersen
a42d80aa14 Merge pull request #3481 from dbartol/github/codeql-c-analysis-team/69
C++/C#: Allow memory operands to lack a definition
2020-05-16 11:53:00 +02:00
Dave Bartolomeo
96c87b309b C++/C#: Use unique to get a better join order
The previous changes made the optimizer choose a bad join order for the RHS of the antijoin in `addressOperandAllocationAndOffset`. Once again, `unique` to the rescue.
2020-05-15 17:36:43 -04:00
Hector Cuesta
16e39414bc Reword of help file 2020-05-15 18:14:52 +01:00
Hector Cuesta
ef53e443b7 Fix typo in comment 2020-05-15 17:17:42 +01:00
Hector Cuesta
a022086498 Add experimental query for Tainted WebClient 2020-05-15 16:30:10 +01:00
Tom Hvitved
cd9538d0d9 Merge remote-tracking branch 'upstream/master' into dataflow/precise-field-types 2020-05-15 15:24:05 +02:00
Calum Grant
5787871734 Merge pull request #3351 from hvitved/csharp/unification-nested-types
C#: Teach unification library about nested types
2020-05-15 14:11:00 +01:00
Calum Grant
cc844648ff Merge pull request #3365 from hvitved/csharp/format-queries-path-problem
C#: Convert `string.format()` queries to path queries
2020-05-15 14:08:54 +01:00
Dave Bartolomeo
89ec60c948 C++/C#: Add missing QLDoc 2020-05-15 09:01:16 -04:00
Dave Bartolomeo
bcddaf4c29 C++/C#: Fix formatting 2020-05-15 08:56:32 -04:00
Tom Hvitved
01102b309b C#: Rename predicates 2020-05-15 09:06:12 +02:00
Dave Bartolomeo
4614372873 C++/C#: Add QLDoc 2020-05-14 17:49:23 -04:00
Dave Bartolomeo
6c12b59f0f C++/C#: Allow non-Phi memory operands to have no definition 2020-05-14 17:22:23 -04:00
Dave Bartolomeo
9de597db25 C++: Refactor Operand to prepare for cross-phase IPA sharing 2020-05-14 10:29:08 -04:00
Tom Hvitved
aa83cc1472 Data flow: Sync files 2020-05-14 15:58:50 +02:00
Tom Hvitved
a0d100485b Data flow: Rename Content variables from f to c 2020-05-14 15:58:50 +02:00
Tom Hvitved
f1cd53507d Data flow: Track precise types during field flow 2020-05-14 15:58:50 +02:00
Dave Bartolomeo
5d3f25211d C++/C#: Remove UnmodeledUse instruction 2020-05-13 01:06:40 -04:00
Dave Bartolomeo
7f2c6dd9f9 C++/C#: Remove UnmodeledUseOperand 2020-05-13 01:05:27 -04:00
jcreedcmu
3c233c762c Merge pull request #3431 from jcreedcmu/jcreed/jump-to-def-langs
Java, Javascript, Csharp: Add jump-to-definition queries
2020-05-12 10:54:11 -04:00
Tom Hvitved
d0c607c83f Address review comments 2020-05-12 16:13:02 +02:00
Jason Reed
569083d6d1 Csharp: Make Use class public, since definitions query needs it 2020-05-12 08:52:02 -04:00