Correctly determine if a member function should be extracted
We need to dial-in the logic in Interface::Build which determines if a member function should be extracted, given the various cases of final, virtual, and access.
Here is something that will almost always work. This does not account for:
- friend declarations, or
- using-declarations (e.g.
using B::f;appearing as apublicmember of a classDderived fromBwhereB::fis aprotectedmember ofB), or public/protecteddata members whose type depends on aprivatemember, orpublic/protectedmember function whose parameters or return type depends on aprivatemember
Given a member M that has access A declared in class C:
- if
Mis not a virtual function:- if
Aispublic, emitM. - if
Aisprivate, do not emitM. - if
Aisprotected, emitMifCis not declaredfinal.
- if
- otherwise, if
Mis a virtual function:- if
Aispublic, emitM. - if
Aisprivate, emitMif:Moverrides a member of a base class ofC, orCis not declaredfinal(note: aprivatevirtual function declaredfinalwill prevent derived classes from overriding the function; sincefinalis only meaningful for member functions of a non-finalclass, it does not require special treatment here).
- if
Aisprotected, emitMif:Cis not declaredfinal, orCis declaredfinalandMoverrides a member of a base class ofC.
- if
The same rules apply for class templates except when C has a dependent base class B. In such cases, we must assume that every non-template non-static member function F overrides a member of B (for the purposes of determining whether to emit the function). Since mrdox only supports valid C++, we can assume that F does not override a function in B if it has a trailing requires-clause, or if the return type of F is a placeholder type (i.e. auto/decltype(auto)) without a trailing-return-type.