Commit Graph

17 Commits

Author SHA1 Message Date
Cornelius Riemenschneider
3f7d68178c Use stripTopLevelSpecifiers() to get the allocated element type for malloc(). 2020-04-27 12:46:14 +02:00
Cornelius Riemenschneider
92e8604fa1 Provide getAllocatedElementType predicate for AllocationExprs.
This predicate tries to determine the type of the allocated elements of an allocation expression.
2020-04-27 12:41:19 +02:00
Cornelius Riemenschneider
203315ae33 Assign malloc results in test to variables. 2020-04-27 12:40:35 +02:00
Cornelius Riemenschneider
a50d5b7c6a Accept changed test output. 2020-04-27 09:17:16 +02:00
Cornelius Riemenschneider
a33b7f8c99 Make getSizeMult() functional. 2020-04-23 12:15:31 +02:00
Cornelius Riemenschneider
293e6466d4 AllocationExpr.getSizeMult() now analyzes the size expression of function calls.
This yields more precise size information in a lot of the common cases of C allocation code,
as the common pattern malloc(count * sizeof(type)) is now understood.
2020-04-23 02:05:31 +02:00
Cornelius Riemenschneider
247fc42ec5 Add tests that show AllocationExpr.getSizeMult() behaviour. 2020-04-23 02:02:57 +02:00
Geoffrey White
18e60fabaf C++: Model operator delete and operator delete[]. 2020-03-31 12:55:44 +01:00
Geoffrey White
3b12d1adfd C++: Test getPlacementArgument(). 2020-03-31 11:06:21 +01:00
Geoffrey White
254c877d0a C++: Deduplicate AllocationExprs. 2020-03-31 11:05:50 +01:00
Geoffrey White
259f714d91 C++: Model operator new and operator new[]. 2020-03-31 11:02:52 +01:00
Geoffrey White
aa49b35d2c C++: Add an explicit test of DeallocationFunction and DeallocationExpr as well. 2020-03-31 10:37:20 +01:00
Geoffrey White
0cb7d4c82d C++: Add an explicit test of AllocationFunction and AllocationExpr. 2020-03-30 20:28:21 +01:00
Geoffrey White
b634b59b9c C++: Merge the two allocators tests. 2020-03-30 18:52:12 +01:00
Geoffrey White
5014432472 CPP: Tests: Add a test of NewArrayExpr.getAllocatedType() and NewArrayExpr.getExtent(). 2019-11-22 15:16:32 +00:00
Jonas Jensen
75873bb4a6 C++: Detect non-allocating placement new
This adds a `NewOrNewArrayExpr.getPlacementPointer` predicate and uses
it in `Alloc.qll` to detect when a `new`-expression is not an
allocation.

User-defined replacements for `operator new` may not be allocations
either, but the code continues to assume that they are. It's possible
that we want to change this assumption in the future or leave it up to
individual queries to decide on which side to err. It's hard to
statically tell whether `operator new` has been overloaded in a
particular file because it can be overloaded by a definition that is not
in scope but is only linked together with that file.
2018-11-22 11:31:19 +01:00
Pavel Avgustinov
b55526aa58 QL code and tests for C#/C++/JavaScript. 2018-08-02 17:53:23 +01:00