Commit Graph

13097 Commits

Author SHA1 Message Date
Dave Bartolomeo
11818489f5 C++/C#: Use cached to ensure that IR is evaluated in a single stage
Before this change, evaluation of the IR was spread out across about 5 stages. This resulted in a lot of redundant evaluation, especially tuple numbering of large IPA types like `TInstruction`. This change makes two small changes that, when combined, ensure that the IR is evaluated all in one stage:

First, we mark `TInstruction` as `cached`. This collapses all of the work to create instructions, across all three IR phases, into a single phase.

Second, we make the `SSA` module in `SSAConstruction.qll` just contain aliases to `cached` predicates defined in the `Cached` module. This ensures that all of the `Operand`-related SSA computation happens in the same stage as all of the `Instruction`-related SSA computation.
2020-06-05 14:05:25 -04:00
Dave Bartolomeo
cb2370cc7d C++/C#: Fix formatting 2020-06-04 02:36:51 -04:00
Dave Bartolomeo
a409b9d451 Merge remote-tracking branch 'github/master' into github/codeql-c-analysis-team/69_union 2020-06-03 16:10:22 -04:00
Dave Bartolomeo
15f41c0107 C++/C#: Remove dead QL code 2020-06-03 15:42:30 -04:00
yo-h
5cdc29e49a Merge pull request #3607 from aschackmull/java/array-instanceof-typeflow
Java: Add instanceof type bounds for ArrayAccess.
2020-06-03 15:29:37 -04:00
Dave Bartolomeo
bbadf4b4bb C#: Port TInstruction-sharing support from C++
This updates C#'s IR to share `TInstruction` across stages the same way C++ does. The only interesting part is that, since we have not yet ported full alias analysis to C#, I stubbed out the required parts of the aliased SSA interface in `AliasedSSAStub.qll`.
2020-06-03 13:52:19 -04:00
Dave Bartolomeo
e65a5c921e C++: Add missing QLDoc 2020-06-03 13:49:14 -04:00
Dave Bartolomeo
f93c2e4e64 C++: Remove resultType from the IPA constructors for TInstruction
Making these part of the IPA object identity changes the failure mode for cases where we assign multiple result types to an instruction. Previously, we would just have one instruction with two result types, but now we'd have two instructions, which breaks things worse. This change goes back to how things were before, to avoid any new surprises on real-world code with invalid ASTs or IR.
2020-06-03 10:11:27 -04:00
Anders Schack-Mulligen
8d6e39eb18 Java: Add instanceof type bounds for ArrayAccess. 2020-06-03 09:42:37 +02:00
Jonas Jensen
9c50acc0f9 Merge pull request #3602 from MathiasVP/path-problem-for-dataflow-tests
C++: Make path-problem versions of ir-flow.ql and flow.ql
2020-06-02 17:59:26 +02:00
Philip Ginsbach
8b3dd6dec4 Merge pull request #3572 from ginsbach/typeunions
introduce type unions in the handbook
2020-06-02 16:31:36 +01:00
Mathias Vorreiter Pedersen
2a1ba6d592 C++: Share configurations in testcases 2020-06-02 16:50:57 +02:00
Mathias Vorreiter Pedersen
b9af1123d9 C++: Make path-problem versions of ir-flow.ql and flow.ql 2020-06-02 16:28:01 +02:00
semmle-qlci
e7800d4695 Merge pull request #3415 from esbena/js/membershiptest
Approved by asgerf
2020-06-02 11:36:51 +01:00
Calum Grant
b099f13f55 Merge pull request #3514 from hvitved/csharp/remove-more-deprecated
C#: Remove more deprecated classes and predicates
2020-06-02 10:35:14 +01:00
Mathias Vorreiter Pedersen
e17b486195 Merge pull request #3593 from rdmarsh2/rdmarsh/cpp/add-qldoc-2
C++: Add QLDoc for AST classes up to Include.qll
2020-06-02 10:23:23 +02:00
Esben Sparre Andreasen
f9ed64fc45 Merge branch 'master' into js/membershiptest 2020-06-02 08:54:44 +02:00
Robert Marsh
3460b9d550 C++: autoformat 2020-06-01 15:38:06 -07:00
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
Philip Ginsbach
c97055faa9 whitespace in example for type unions fixed
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
2020-06-01 14:27:34 +01:00
semmle-qlci
7265e94028 Merge pull request #3578 from erik-krogh/HtmlGuard
Approved by asgerf
2020-06-01 13:25:02 +01:00
Asger F
712c53afe9 Merge pull request #3579 from erik-krogh/fix-change-note-merge
JS: remove duplicates from change-note
2020-06-01 13:22:23 +01:00
Philip Ginsbach
faf4c16865 Mark the QL code as invalid more explicitly 2020-06-01 12:24:06 +01:00
semmle-qlci
14be4fedf7 Merge pull request #3594 from erik-krogh/CachedExprStringValue
Approved by asgerf
2020-05-30 16:56:40 +01:00
Erik Krogh Kristensen
dfd35aee61 autoformat 2020-05-30 14:50:13 +02:00
Mathias Vorreiter Pedersen
cd574e8569 Merge pull request #3589 from rdmarsh2/ir-placement-new-consistency
C++: fix IR control flow for cast in placement new
2020-05-30 13:27:34 +02:00
Erik Krogh Kristensen
3b4e57ab8d autoformat 2020-05-30 12:45:51 +02:00
Robert Marsh
e17adf14dc C++: autoformat 2020-05-29 16:13:40 -07:00
Robert Marsh
f8b6e07391 C++: Added QLDoc for Element.qll-Include.qll 2020-05-29 16:09:19 -07:00
Robert Marsh
1c20714c62 C++: file QLDoc for AutogeneratedFile-Diagnostics 2020-05-29 14:58:01 -07:00
Jonas Jensen
91da0d5567 Merge pull request #3592 from geoffw0/strlen
CPP: Don't taint the return value of strlen
2020-05-29 19:23:47 +02:00
Robert Marsh
6c9051ae6f C++: accept consistency fixes 2020-05-29 09:49:28 -07:00
Geoffrey White
9ee75aaca1 C++: Change note. 2020-05-29 16:22:42 +01:00
Geoffrey White
f534f09784 C++: Autoformat. 2020-05-29 14:05:08 +01:00
Geoffrey White
19c33ab41c C++: Refine StrLenFunction, including removal of taint flow. 2020-05-29 14:04:27 +01:00
Geoffrey White
705529cdf7 C++: Split StrLenFunction from PureStrFunction (without changes). 2020-05-29 14:04:27 +01:00
Geoffrey White
59cb5f9b1e C++: Remove a special case for strlen in DefaultTaintTracking. 2020-05-29 14:04:26 +01:00
Geoffrey White
408e38a4d4 C++: Clarify which taint tracking libraries should be used somewhat. 2020-05-29 14:04:26 +01:00
Geoffrey White
d77092c931 C++: Add taint tests for strlen. 2020-05-29 13:39:40 +01:00
semmle-qlci
f291749243 Merge pull request #3585 from asger-semmle/js/use-newer-yarn
Approved by erik-krogh
2020-05-29 13:02:20 +01:00
Philip Ginsbach
2d47537f11 Slightly modified version of Henning's suggestion 2020-05-29 12:41:58 +01:00
Erik Krogh Kristensen
f7ad210331 use SSA instead of internal AccessPath API 2020-05-29 13:08:19 +02:00
Erik Krogh Kristensen
05bfba4f99 use getImmediatePredecessor instead of getALocalSource() 2020-05-29 13:01:09 +02:00
Jonas Jensen
453de6bf4e Merge pull request #3583 from MathiasVP/qldoc-for-unix-constants
C++: QLDoc for Constants
2020-05-29 12:27:59 +02:00
Mathias Vorreiter Pedersen
ae4f6edc6a Merge pull request #3204 from jbj/Expr-location-workaround
C++: Move Expr location workaround to Expr.qll
2020-05-29 11:58:50 +02:00
Philip Ginsbach
bb9e800241 remove "experimental syntax" box for type unions 2020-05-29 10:24:42 +01:00
Philip Ginsbach
299d87aa8e better explanation of the purpose of type unions
Co-authored-by: Pavel Avgustinov <54942558+p0@users.noreply.github.com>
2020-05-29 10:22:57 +01:00
Philip Ginsbach
0562b4a2dd restricted _subsets_ of algebraic datatypes
Co-authored-by: Pavel Avgustinov <54942558+p0@users.noreply.github.com>
2020-05-29 10:21:58 +01:00
Asger Feldthaus
f3a08375b4 JS: Use newer yarn.lock format 2020-05-29 09:45:50 +01:00