CodeQL library for C/C++
codeql/cpp-all 2.1.1 (changelog, source)
Search

Member predicate AccessHolder::canAccessClass

Holds if a base class base of derived is accessible at this (N4140 11.2/4). When this holds, and derived has only one base subobject of type base, code in this can implicitly convert a pointer to derived into a pointer to base. Conversely, if such a conversion is possible then this predicate holds.

For the sake of generality, this predicate also holds whenever base = derived.

This predicate is pragma[inline] because it is infeasible to fully compute it on large code bases: all classes derived can be converted to their public bases base from everywhere (this), so this predicate could yield a number of tuples that is quadratic in the size of the program. To avoid this combinatorial explosion, only use this predicate in a context where this together with base or derived are sufficiently restricted.

predicate canAccessClass(Class base, Class derived)