Skip to content

Commit 952dbd6

Browse files
committed
C++: Default to one indirection in the case of self iterators.
1 parent 971456c commit 952dbd6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternalsCommon.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ private int countIndirections(Type t) {
117117
else (
118118
result = any(Indirection ind | ind.getType() = t).getNumberOfIndirections()
119119
or
120+
// If there is an indirection for the type, but we cannot count the number of indirections
121+
// it means we couldn't reach a non-indirection type by stripping off indirections. This
122+
// can occur if an iterator specifies itself as the value type. In this case we default to
123+
// 1 indirection fore the type.
124+
exists(Indirection ind |
125+
ind.getType() = t and
126+
not exists(ind.getNumberOfIndirections()) and
127+
result = 1
128+
)
129+
or
120130
not exists(Indirection ind | ind.getType() = t) and
121131
result = 0
122132
)

0 commit comments

Comments
 (0)