C++: Default to one indirection in the case of self iterators.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-06-20 12:58:11 +01:00
parent 971456c725
commit 952dbd69e9

View File

@@ -117,6 +117,16 @@ private int countIndirections(Type t) {
else ( else (
result = any(Indirection ind | ind.getType() = t).getNumberOfIndirections() result = any(Indirection ind | ind.getType() = t).getNumberOfIndirections()
or or
// If there is an indirection for the type, but we cannot count the number of indirections
// it means we couldn't reach a non-indirection type by stripping off indirections. This
// can occur if an iterator specifies itself as the value type. In this case we default to
// 1 indirection fore the type.
exists(Indirection ind |
ind.getType() = t and
not exists(ind.getNumberOfIndirections()) and
result = 1
)
or
not exists(Indirection ind | ind.getType() = t) and not exists(Indirection ind | ind.getType() = t) and
result = 0 result = 0
) )