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

Member predicate AccessHolder::couldAccessMember

Holds if a hypothetical non-static member of memberClass with access specifier memberAccess is accessible at this when named in a class derived that is derived from or equal to memberClass (N4140 11.2/5 and 11.4).

This predicate determines whether an expression x.m would be allowed in this when x has type derived and m has memberAccess in memberClass. The more general syntax x.N::n, where N may be a base class of derived, is not supported. This should only affect very rare edge cases of 11.4.

This predicate is pragma[inline] because it is infeasible to fully compute it on large code bases: all classes memberClass have their public members accessible 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 and memberClass are sufficiently restricted when memberAccess is public.

predicate couldAccessMember(Class memberClass, AccessSpecifier memberAccess, Class derived)