clang 20.0.0git
Public Member Functions | List of all members
clang::TypeVisitor< ImplClass, RetTy > Class Template Reference

An operation on a type. More...

#include "clang/AST/TypeVisitor.h"

Inheritance diagram for clang::TypeVisitor< ImplClass, RetTy >:
Inheritance graph
[legend]

Public Member Functions

RetTy Visit (const Type *T)
 Performs the operation associated with this visitor object.
 
RetTy VisitType (const Type *)
 Method called if ImpClass doesn't provide specific handler for some type class.
 

Detailed Description

template<typename ImplClass, typename RetTy = void>
class clang::TypeVisitor< ImplClass, RetTy >

An operation on a type.

Template Parameters
ImplClassClass implementing the operation. Must be inherited from TypeVisitor.
RetTyType of result produced by the operation.

The class implements polymorphic operation on an object of type derived from Type. The operation is performed by calling method Visit. It then dispatches the call to function VisitFooType, if actual argument type is FooType.

The class implements static polymorphism using Curiously Recurring Template Pattern. It is designed to be a base class for some concrete class:

class SomeVisitor : public TypeVisitor<SomeVisitor,sometype> { ... };
...
Type *atype = ...
...
SomeVisitor avisitor;
sometype result = avisitor.Visit(atype);
An operation on a type.
Definition: TypeVisitor.h:64

Actual treatment is made by methods of the derived class, TypeVisitor only dispatches call to the appropriate method. If the implementation class ImplClass provides specific action for some type, say ConstantArrayType, it should define method VisitConstantArrayType(const ConstantArrayType*). Otherwise TypeVisitor dispatches call to the method that handles parent type. In this example handlers are tried in the sequence:

The first function of this sequence that is defined will handle object of type ConstantArrayType.

Definition at line 64 of file TypeVisitor.h.

Member Function Documentation

◆ Visit()

template<typename ImplClass , typename RetTy = void>
RetTy clang::TypeVisitor< ImplClass, RetTy >::Visit ( const Type T)
inline

◆ VisitType()

template<typename ImplClass , typename RetTy = void>
RetTy clang::TypeVisitor< ImplClass, RetTy >::VisitType ( const Type )
inline

Method called if ImpClass doesn't provide specific handler for some type class.

Definition at line 87 of file TypeVisitor.h.


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