Commit Graph

2357 Commits

Author SHA1 Message Date
Jonas Jensen
38ec693ead C++: Improved ConstructorCall field flow
This commit changes C++ `ConstructorCall` to behave like
`new`-expressions in Java: they are both `ExprNode`s and
`PostUpdateNodes`, and there's a "pre-update node" (here called
`PreConstructorCallNode`) to play the role of the qualifier argument
when calling a constructor.
2019-08-13 11:05:13 +02:00
Jonas Jensen
18c3bfe596 Merge pull request #1731 from geoffw0/qldoceg5
CPP: Add syntax examples to QLDoc in Initializer.qll, Parameter.qll
2019-08-13 08:52:05 +02:00
Jonas Jensen
1f1824cb9b C++: Exclude BlockVar computation for "large" vars 2019-08-12 16:53:48 +02:00
Geoffrey White
beada95014 CPP: Examples Block.qll. 2019-08-12 15:08:37 +01:00
Dave Bartolomeo
5d6ac2bb74 Merge pull request #1583 from jbj/ir-sanity-qlcfg
C++: Share tests between IR and QL-CFG
2019-08-12 07:04:40 -07:00
Jonas Jensen
3f531380d1 C++: Reduce number of SubBasicBlocks in FlowVar
by cutting basic blocks at the same place for the `x.a` partial
definition in `x.a = ...` as they were already cut for assignment to
`a`.
2019-08-12 15:58:35 +02:00
Dave Bartolomeo
19d2f3a54e Merge pull request #1550 from jbj/array-aggregate-perf
C++ IR: Fix performance of large value-initialized arrays
2019-08-12 06:53:16 -07:00
Geoffrey White
2d2890e401 CPP: Add examples Parameter.qll. 2019-08-12 13:29:07 +01:00
Geoffrey White
ceec0278e5 CPP: Add examples Initializer.qll. 2019-08-12 13:16:34 +01:00
Max Schaefer
eb8087f4ea Java/C++/C#: Provide path-node locations via hasLocationInfo, not getLocation. 2019-08-12 12:52:30 +01:00
Jonas Jensen
0652d2a92b Merge pull request #1705 from geoffw0/qldoceg2
CPP: Add syntax examples to QLDoc in Enum.qll.
2019-08-12 13:39:05 +02:00
Geoffrey White
dc1ec635fb CPP: Undo an accidentally committed change to the test. 2019-08-12 11:17:02 +01:00
Jonas Jensen
5724fb0df0 Merge pull request #1706 from geoffw0/qldoceg3
CPP: Add syntax examples to QLDoc in Struct.qll, Union.qll.
2019-08-12 07:57:40 +02:00
Geoffrey White
208f533245 CPP: Brace placement. 2019-08-09 17:48:57 +01:00
Geoffrey White
11d17b891e CPP: Brace placement. 2019-08-09 17:44:55 +01:00
Geoffrey White
e149b6a332 CPP: Brace placement. 2019-08-09 17:42:02 +01:00
Jonas Jensen
0507d51f0c C++: Prune getAReachedBlockVarSBB using live vars
On a Postgres snapshot, where the `getAReachedBlockVarSBB` predicate
performs badly because of a Yacc-generated 20,000-line parser loop, that
predicate is reduced from 4m22s to 1m32s plus 5.2s for the live
variables analysis.

This change removes 17,142 rows from `BlockVar.getAnAccess` on Postgres.
I sampled some of them, and they were all of the following form:

    while (...) {
      T x;
      f1(&x); // access
      f2(&x); // definition
    }

Such accesses are ruled out now because we deliberately lose track of
variables when they go out of scope.
2019-08-09 16:06:28 +02:00
Jonas Jensen
b348803a66 Merge pull request #1594 from geoffw0/erafix7
CPP: Add test coverage for LeapYearFieldAccess.isModifiedByArithmeticOperation.
2019-08-09 15:57:35 +02:00
Jonas Jensen
8aa24fe5c9 C++: Improve QLDoc on assignmentLikeOperation 2019-08-09 15:06:19 +02:00
Geoffrey White
67eb37f460 CPP: Update test annotations. 2019-08-09 09:31:47 +01:00
Jonas Jensen
605b56f8ca Merge pull request #1563 from geoffw0/constexprif
CPP: Test cases for EmptyBlock.ql with 'if constexpr'
2019-08-08 20:57:28 +02:00
Geoffrey White
1173daefca CPP: Minor changes. 2019-08-08 17:55:50 +01:00
Geoffrey White
950bc6e3d0 CPP: Brace placement. 2019-08-08 17:51:27 +01:00
Geoffrey White
c406746190 CPP: Brace placement. 2019-08-08 17:16:47 +01:00
Geoffrey White
5bdaefd504 CPP: Brace placement. 2019-08-08 17:13:58 +01:00
Geoffrey White
f0e6730eba Update cpp/ql/src/semmle/code/cpp/Union.qll
Co-Authored-By: Jonas Jensen <jbj@knef.dk>
2019-08-08 17:11:05 +01:00
Geoffrey White
a1cf7b50a9 Update cpp/ql/src/semmle/code/cpp/Struct.qll
Co-Authored-By: Jonas Jensen <jbj@knef.dk>
2019-08-08 17:10:52 +01:00
Geoffrey White
7086004f8a Update cpp/ql/src/semmle/code/cpp/Union.qll
Co-Authored-By: Jonas Jensen <jbj@knef.dk>
2019-08-08 17:06:44 +01:00
Geoffrey White
b3bcc33bce Update cpp/ql/src/semmle/code/cpp/Struct.qll
Co-Authored-By: Jonas Jensen <jbj@knef.dk>
2019-08-08 17:06:17 +01:00
Geoffrey White
82bf631541 CPP: Add test cases. 2019-08-08 15:02:56 +01:00
Geoffrey White
ef37893d15 CPP: Improve the MemberFunctions test. 2019-08-08 15:02:56 +01:00
Geoffrey White
843b85c0e6 CPP: Test PureVirtualFunction. 2019-08-08 15:02:55 +01:00
Geoffrey White
44ea685bf3 CPP: Simplify the VirtualFunctions test. 2019-08-08 15:02:55 +01:00
Geoffrey White
be25338e44 CPP: QLDoc Function.qll. 2019-08-08 15:02:55 +01:00
Jonas Jensen
2c6dbacd2b C++: Tidy up DataFlowUtil.qll 2019-08-08 14:05:03 +02:00
Jonas Jensen
0a13d7a337 C++: PartialDefNode -> PartialDefinitionNode 2019-08-08 14:05:03 +02:00
Jonas Jensen
98d6f3cada C++: Unify partial def and def-by-ref
This removes a lot of flow steps, but it all seems to be flow that was
present twice: both exiting a `PartialDefNode` and a
`DefinitionByReferenceNode`. All `DefinitionByReferenceNode`s are now
`PartialDefNode`s.
2019-08-08 14:05:03 +02:00
Jonas Jensen
5370e7d693 C++: Remove TThisVar
There's no need to model `this` as a variable because it's never
reassigned.
2019-08-08 14:05:03 +02:00
Jonas Jensen
6a3f5efc1b C++: Accept AST field flow test output 2019-08-08 14:05:03 +02:00
Jonas Jensen
861964337c C++: Undo autoformat of FlowVar.qll
The formatting changes were good, but were tangled in with other
changes, making it hard to review this file.
2019-08-08 14:05:03 +02:00
Pavel Avgustinov
79d75d7d18 Add extra test cases 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
835e495e7c Remove unused args 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
b1632587bc Use more meaningful name 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
6d4d131ad4 C++ field flow: Add test.
This is a fairly direct translation of the Java field flow test to
C++. Not all the `// flow` annotations are currently accurate.
2019-08-08 14:05:03 +02:00
Pavel Avgustinov
dccc0f4db1 Add handling of post-constructor-call nodes 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
9e6c240ee2 Override getFunction on PostUpdateNodes 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
abcaeded23 Only split BBs for var-defining partial-defs 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
46e6b587bc Exclude partial defs from ordinary SSA handling 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
5fbe982084 Add missing getType override 2019-08-08 14:05:03 +02:00
Pavel Avgustinov
1b9a2d3d87 Reduce partial definition flow edge redundancy 2019-08-08 14:05:02 +02:00