From 34bd3bf4996cf0941e3cdfde07d97f6b3d54070d Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Thu, 30 May 2013 05:04:43 +0000 Subject: [PATCH] Added documentation to TypeVisitor. No code changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182911 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/TypeVisitor.h | 44 ++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/TypeVisitor.h b/include/clang/AST/TypeVisitor.h index 242aa586d5..15dc0cfac0 100644 --- a/include/clang/AST/TypeVisitor.h +++ b/include/clang/AST/TypeVisitor.h @@ -22,9 +22,50 @@ namespace clang { return static_cast(this)-> \ Visit##CLASS(static_cast(T)) +/// \brief An operation on a type. +/// +/// \tparam ImpClass Class implementing the operation. Must be inherited from +/// TypeVisitor. +/// \tparam 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 \c VisitFooType, if actual argument type +/// is \c FooType. +/// +/// The class implements static polymorphism using Curiously Recurring +/// Template Pattern. It is designed to be a base class for some concrete +/// class: +/// +/// \code +/// class SomeVisitor : public TypeVisitorVisitConstantArrayType(const ConstantArrayType*). Otherwise +/// \c TypeVisitor dispatches call to the method that handles parent type. In +/// this example handlers are tried in the sequence: +/// +/// \li ImpClass::VisitConstantArrayType(const ConstantArrayType*) +/// \li ImpClass::VisitArrayType(const ArrayType*) +/// \li ImpClass::VisitType(const Type*) +/// \li TypeVisitor::VisitType(const Type*) +/// +/// The first function of this sequence that is defined will handle object of +/// type \c ConstantArrayType. template class TypeVisitor { public: + + /// \brief Performs the operation associated with this visitor object. RetTy Visit(const Type *T) { // Top switch stmt: dispatch to VisitFooType for each FooType. switch (T->getTypeClass()) { @@ -42,7 +83,8 @@ public: } #include "clang/AST/TypeNodes.def" - // Base case, ignore it. :) + /// \brief Method called if \c ImpClass doesn't provide specific handler + /// for some type class. RetTy VisitType(const Type*) { return RetTy(); } }; -- 2.40.0