clang 18.0.0git
clang::CXXFinalOverriderMap Class Reference

A mapping from each virtual member function to its set of final overriders. More...

#include "clang/AST/CXXInheritance.h"

Inheritance diagram for clang::CXXFinalOverriderMap:
Inheritance graph

Detailed Description

A mapping from each virtual member function to its set of final overriders.

Within a class hierarchy for a given derived class, each virtual member function in that hierarchy has one or more "final overriders" (C++ [class.virtual]p2). A final overrider for a virtual function "f" is the virtual function that will actually be invoked when dispatching a call to "f" through the vtable. Well-formed classes have a single final overrider for each virtual function; in abstract classes, the final overrider for at least one virtual function is a pure virtual function. Due to multiple, virtual inheritance, it is possible for a class to have more than one final overrider. Although this is an error (per C++ [class.virtual]p2), it is not considered an error here: the final overrider map can represent multiple final overriders for a method, and it is up to the client to determine whether they are problem. For example, the following class D has two final overriders for the virtual function A::f(), one in C and one in D:

struct A { virtual void f(); };
struct B : virtual A { virtual void f(); };
struct C : virtual A { virtual void f(); };
struct D : B, C { };
@ C
Languages that the frontend can parse and compile.

This data structure contains a mapping from every virtual function that does not override an existing virtual function and in every subobject where that virtual function occurs to the set of virtual functions that override it. Thus, the same virtual function A::f can actually occur in multiple subobjects of type A due to multiple inheritance, and may be overridden by different virtual functions in each, as in the following example:

struct A { virtual void f(); };
struct B : A { virtual void f(); };
struct C : A { virtual void f(); };
struct D : B, C { };

Unlike in the previous example, where the virtual functions B::f and C::f both overrode A::f in the same subobject of type A, in this example the two virtual functions both override A::f but in different subobjects of type A. This is represented by numbering the subobjects in which the overridden and the overriding virtual member functions are located. Subobject 0 represents the virtual base class subobject of that type, while subobject numbers greater than 0 refer to non-virtual base class subobjects of that type.

Definition at line 357 of file CXXInheritance.h.

The documentation for this class was generated from the following file: