clang 10.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 >:
[legend]

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

## Detailed Description

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

An operation on a type.

Template Parameters

  ImplClass | Class implementing the operation. Must be inherited from TypeVisitor.
  RetTy | Type 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);

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:

- `ImplClass::VisitConstantArrayType(const ConstantArrayType*)`
- `ImplClass::VisitArrayType(const ArrayType*)`
- `ImplClass::VisitType(const Type*)`
- `TypeVisitor::VisitType(const Type*)`

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

Performs the operation associated with this visitor object.

Definition at line 68 of file TypeVisitor.h.

Referenced by clang::ASTImporter::Import(), clang::ASTImporter::ImportImpl(), clang::ASTNodeTraverser< ASTDumper, TextNodeDumper >::Visit(), and clang::TextNodeDumper::Visit().

## ◆ 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:

- include/clang/AST/TypeVisitor.h