Commit Graph

1843 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
1f1824cb9b C++: Exclude BlockVar computation for "large" vars 2019-08-12 16:53:48 +02: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
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
8aa24fe5c9 C++: Improve QLDoc on assignmentLikeOperation 2019-08-09 15:06:19 +02: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
Pavel Avgustinov
bb8eb235e0 Handle constructor call qualifiers 2019-08-08 14:05:02 +02:00
Pavel Avgustinov
66164eb06f Propagate data flow through NewExprs 2019-08-08 14:05:02 +02:00
Pavel Avgustinov
623652247d Introduce partial-definition nodes 2019-08-08 14:05:02 +02:00
Pavel Avgustinov
15b56d93bd No implicit instances for constructor call 2019-08-08 14:05:02 +02:00
Pavel Avgustinov
04454ef184 Begin extending dataflow node model for field flow (and other stuff) 2019-08-08 14:05:02 +02:00
Jonas Jensen
3b2ef44195 Merge pull request #1710 from geoffw0/oddsandends
CPP: Delete invalid URL
2019-08-07 15:02:37 +02:00
Geoffrey White
d1093cae2e CPP: Delete invalid URL and strange comment. 2019-08-07 09:25:36 +01:00
yh-semmle
033879f5a6 Merge pull request #1639 from aschackmull/java/in-out-barriers
Java/C++/C# DataFlow: Add support for in/out barriers on sources and sinks.
2019-08-07 01:07:19 -04:00
Jonas Jensen
077f372f98 Merge pull request #1570 from geoffw0/qldoceg
CPP: Add syntax examples to QLDoc in Class.qll.
2019-08-06 21:17:45 +02:00
zlaski-semmle
3ad0bcf3de Merge pull request #1701 from Semmle/geoffw0-patch-1
CPP: QLDoc tidy up Declaration.qll
2019-08-06 11:53:20 -07:00
Nick Rolfe
257daddf3b Merge pull request #1702 from mgrettondann/cpp-add-thread_local-support-external
C++: add thread_local support
2019-08-06 14:51:27 +01:00
Geoffrey White
73736675ce CPP: Bits and bobs. 2019-08-06 13:32:04 +01:00
Geoffrey White
ab823f45fc CPP: class, struct or union where appropriate. 2019-08-06 13:32:04 +01:00
Geoffrey White
8d22eb87f0 CPP: Improvements to qldoc. 2019-08-06 13:29:42 +01:00
Geoffrey White
4dd1267d6d CPP: Bracket consistency. 2019-08-06 13:29:42 +01:00
Geoffrey White
cf1869cfaa CPP: Indentation. 2019-08-06 13:29:42 +01:00
Geoffrey White
0029a33ee6 CPP: Deprecate Interface and remove the test. 2019-08-06 13:29:42 +01:00
Geoffrey White
49f6ac7358 CPP: Clean up Class, ClassDerivation and ClassTemplateSpecialization QLDoc. 2019-08-06 13:29:42 +01:00
Geoffrey White
2b408490a1 CPP: Implement simple changes. 2019-08-06 13:29:42 +01:00
Geoffrey White
99880bc4ea CPP: Add syntax examples for Class.qll. 2019-08-06 13:29:42 +01:00
Jonas Jensen
4dfd4f1dda Merge pull request #1674 from dave-bartolomeo/dave/ExternDecls2
C++: Two IR fixes and a PrintAST workaround
2019-08-06 13:46:04 +02:00
Matthew Gretton-Dann
90cfde53b3 C++: Add thread_local support - typo fix 2019-08-06 12:09:43 +01:00
Matthew Gretton-Dann
0e50a143af C++: Improve ReturnStackAllocatedMemory query
Update the ReturnStackAllocatedMmeory query to not give a false positive
for thread_local variables.
2019-08-06 11:22:32 +01:00
Matthew Gretton-Dann
a733625646 C++: Add Variable.isThreadLocal() 2019-08-06 11:22:26 +01:00
Geoffrey White
de9b936d76 QLDoc tidy up Declaration.qll
Mostly just adding backticks in QLDoc comments.  I'm trying out the edit-in-github workflow @jbj showed me, which seems like it will be a quicker way to do minor changes like these.
2019-08-06 10:54:20 +01:00
Anders Schack-Mulligen
a80cb262fc Java/C++/C#: Elaborate qldoc. 2019-08-05 16:28:25 +02:00
Anders Schack-Mulligen
9ebb83497d Java/C++/C#: Fix small mistake. 2019-08-05 15:34:12 +02:00
Anders Schack-Mulligen
2dc83c539c Java/C++/C#: Sync dataflow. 2019-08-05 12:07:32 +02:00
Anders Schack-Mulligen
d6e1ba6bed CPP: Autoformat cookbook examples. 2019-08-02 15:29:20 +02:00