mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
C++: Allocate an additional indirection for void pointers.
This commit is contained in:
@@ -103,10 +103,18 @@ private class PointerOrArrayOrReferenceType extends Cpp::DerivedType {
|
||||
* (i.e., `countIndirections(e.getUnspecifiedType())`).
|
||||
*/
|
||||
private int countIndirections(Type t) {
|
||||
result = any(Indirection ind | ind.getType() = t).getNumberOfIndirections()
|
||||
or
|
||||
not exists(Indirection ind | ind.getType() = t) and
|
||||
result = 0
|
||||
// We special case void pointers because we don't know how many indirections
|
||||
// they really have. In a Glorious Future we could do a pre-analysis to figure out
|
||||
// which kinds of values flows into the type and use the maximum number of
|
||||
// indirections flowinginto the type.
|
||||
if t instanceof Cpp::VoidPointerType
|
||||
then result = 2
|
||||
else (
|
||||
result = any(Indirection ind | ind.getType() = t).getNumberOfIndirections()
|
||||
or
|
||||
not exists(Indirection ind | ind.getType() = t) and
|
||||
result = 0
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user