clang API Documentation
An operation on a type. More...
#include <TypeVisitor.h>
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. |
An operation on a type.
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 65 of file TypeVisitor.h.
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().
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.