Commit Graph

13928 Commits

Author SHA1 Message Date
Pavel Avgustinov
3bc06627e1 Simplify definitions.qll for C++. 2018-08-14 16:38:56 -07:00
Pavel Avgustinov
382ae85431 Simplify location handling for C++ locations. 2018-08-14 16:38:56 -07:00
Geoffrey White
031964e853 Merge pull request #30 from jbj/incomplete-parity-check-medium
C++: Downgrade cpp/incomplete-parity-check from high to medium precision [CPP-236]
2018-08-14 15:19:02 +01:00
Jonas Jensen
dc22833259 C++: Factor out IRBlock.qll differences
All three `IRBlock.qll` files are now identical again, and they are just
a thin object-oriented layer on top of the three
`IRBlockConstruction.qll` files, two of which are identical.
2018-08-14 14:12:26 +02:00
Jonas Jensen
da02c45102 Merge pull request #36 from rdmarsh2/rdmarsh/cpp/add-security-tags
C++: add security tags to more queries
2018-08-14 12:07:28 +02:00
Jonas Jensen
3e1247257f C++: Move C/C++ suites to ql repo
As the queries live here, it makes sense for the suites to be versioned
together with them. The LGTM suite has already been moved. This commit
moves the actively-maintained non-LGTM suites.
2018-08-14 11:41:31 +02:00
Pavel Avgustinov
64338b0581 Element::getEnclosingElement: Skip macro information.
Previously, we would try to find an element enclosing each macro
access. This is not in general well-defined, especially in the
context of template instantiations -- macros are a lexing-time
concept, and don't map cleanly onto AST elements.
2018-08-13 22:16:49 +01:00
Robert Marsh
9cf599fb59 C++: remove some tags in response to PR comments 2018-08-13 10:25:10 -07:00
Jonas Jensen
d88c9c67f1 C++ IR: Don't repeat a very similar predicate body 2018-08-10 16:05:31 +02:00
Jonas Jensen
a235d7aaff C++ IR: Reuse expensive IRBlock computations
`IRBlock` contains a few expensive predicates, mostly `getInstruction`
and `immediatelyDominates`. These were previously recomputed for each of
the three SSA layers even though they essentially produce the same
result in each layer. The only difference between the three types of
`IRBlock` is the phi nodes.

This commit changes the representation of `IRBlock` for `ssa` and
`aliased_ssa` so they become just wrappers around the `IRBlock` of their
previous layer. Most predicates in later layers are then computed from
the corresponding predicate of the preceding layer.
2018-08-10 16:05:30 +02:00
Jonas Jensen
6ee3def942 C++ IR: Speed up getInstructionOperand
The `SSAConstruction::Cached::getInstructionOperand` predicate took
1m27s on a postgres snapshot before this change and was the slowest
predicate in SSAIR. It now takes 4.5s.

The slowdown was caused by its use of
`getUnmodeledDefinitionInstruction`, which got inlined into a place
where join orderer had little choice but to join the `MkInstruction`
relation with itself, creating a large intermediate relation.

I've added `pragma[noinline]` to `getUnmodeledDefinitionInstruction` and
also to similar predicates that are likely to cause the same problem in
the future.
2018-08-10 16:05:30 +02:00
Jonas Jensen
7b1d1365a9 C++ IR: Fully cache IRBlock and use cached module
Before this PR, the caching and computation of `IRBlock` spanned three
cache stages and was also separate from `SSAConstruction` even though it
shared some computations with it. They are now all cached together, so
the number of stages is reduced by 2 for each layer of IR.

I made the choice of what to cache be similar to what we do for
`PrimitiveBasicBlock` as I've recently benchmarked this and found it to
be a good choice.
2018-08-10 16:05:15 +02:00
semmle-qlci
945413a791 Merge pull request #42 from tibbes/qhelp/fix-links
Approved by jbj, xiemaisi
2018-08-10 13:00:17 +01:00
semmle-qlci
bbee9a860b Merge pull request #38 from jbj/ir-Instruction-hasUse
Approved by dave-bartolomeo
2018-08-10 12:03:26 +01:00
Julian Tibble
98e866e967 C++, JS: fix broken links in query help 2018-08-10 08:40:22 +01:00
Jonas Jensen
c92111d552 C++: Accept test changes: IR sanity query added 2018-08-10 09:04:52 +02:00
Robert Marsh
31819be32d C++: add security tags to some format queries 2018-08-09 13:31:29 -07:00
Jonas Jensen
961a7dcf15 C++ IR: Remove Instruction.hasUse predicate
Now that it's been simplified to be the same as `getOperand`, it doesn't
seem to have a purpose.
2018-08-09 15:36:52 +02:00
Jonas Jensen
8c06a68835 C++ IR: Remove redundant check for same function
The check that an instruction is in the same function as its operands is
hopefully redundant and can be removed. Just to be sure, I've added the
check to a sanity query.

This check turned out to cause bad performance in the alias analysis
because it got inlined into `AliasAnalysis::resultEscapes` and then
pulled out to a loop-invariant predicate that got a bad join order. With
this check removed, the `ssa/AliasAnalysis.qll` file is orders of
magnitude faster.
2018-08-09 15:36:52 +02:00
Jonas Jensen
5c4292932f C++: Move LGTM suites to submodule
This follows what's been done for JavaScript. The `cpp-alerts-lgtm`
suite is now empty and will be auto-generated when building a dist.

This commit has no effect in itself, but these files need to be in place
when the corresponding changes are made in Semmle/code.
2018-08-09 10:35:05 +02:00
Robert Marsh
bf39674761 C++: remove accidental blank line 2018-08-08 14:17:35 -07:00
Robert Marsh
f280de7ae3 C++: add security tags to more queries 2018-08-08 13:55:36 -07:00
Jonas Jensen
dab45c527e C++: cpp/incomplete-parity-check: medium precision
As reported in CPP-236, this query has false positives on signed
integers that cannot be negative. It could possibly be improved with a
local range analysis, but the query would most likely still have so many
false positives that we would have to lower its precision.

Under our current policy, this change will make the query hidden by
default on LGTM.
2018-08-08 10:14:45 +02:00
Jonas Jensen
a201fe688f Merge pull request #22 from rdmarsh2/rdmarsh/cpp/use-in-own-initializer-macro
C++: handle more macros in UseInOwnInitializer
2018-08-07 20:03:01 +02:00
Nick Rolfe
3444fb7b88 C++: remove all uses of deprecated 'extractor_flags' 2018-08-07 09:48:27 +01:00
Robert Marsh
6546b37d5d C++: handle more macros in UseInOwnInitializer 2018-08-06 11:40:35 -07:00
Jonas Jensen
73a40f6ffc C++: Create cpp/ql/test/{.project,.qlpath}
These are adapted from `javascript/ql/test`.
2018-08-06 14:07:22 +02:00
Pavel Avgustinov
b55526aa58 QL code and tests for C#/C++/JavaScript. 2018-08-02 17:53:23 +01:00