clang API Documentation

Public Member Functions
clang::TypeVisitor< ImplClass, RetTy > Class Template Reference

An operation on a type. More...

#include <TypeVisitor.h>

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

List of all members.

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);

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 65 of file TypeVisitor.h.


Member Function Documentation

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 69 of file TypeVisitor.h.

Referenced by clang::ASTImporter::Import().

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.

Reimplemented in clang::ASTNodeImporter.

Definition at line 88 of file TypeVisitor.h.


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