clang API Documentation
00001 //===--- TypeLocVisitor.h - Visitor for TypeLoc subclasses ------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the TypeLocVisitor interface. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 #ifndef LLVM_CLANG_AST_TYPELOCVISITOR_H 00014 #define LLVM_CLANG_AST_TYPELOCVISITOR_H 00015 00016 #include "clang/AST/TypeLoc.h" 00017 #include "clang/AST/TypeVisitor.h" 00018 #include "llvm/Support/ErrorHandling.h" 00019 00020 namespace clang { 00021 00022 #define DISPATCH(CLASSNAME) \ 00023 return static_cast<ImplClass*>(this)-> \ 00024 Visit##CLASSNAME(TyLoc.castAs<CLASSNAME>()) 00025 00026 template<typename ImplClass, typename RetTy=void> 00027 class TypeLocVisitor { 00028 public: 00029 RetTy Visit(TypeLoc TyLoc) { 00030 switch (TyLoc.getTypeLocClass()) { 00031 #define ABSTRACT_TYPELOC(CLASS, PARENT) 00032 #define TYPELOC(CLASS, PARENT) \ 00033 case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc); 00034 #include "clang/AST/TypeLocNodes.def" 00035 } 00036 llvm_unreachable("unexpected type loc class!"); 00037 } 00038 00039 RetTy Visit(UnqualTypeLoc TyLoc) { 00040 switch (TyLoc.getTypeLocClass()) { 00041 #define ABSTRACT_TYPELOC(CLASS, PARENT) 00042 #define TYPELOC(CLASS, PARENT) \ 00043 case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc); 00044 #include "clang/AST/TypeLocNodes.def" 00045 } 00046 llvm_unreachable("unexpected type loc class!"); 00047 } 00048 00049 #define TYPELOC(CLASS, PARENT) \ 00050 RetTy Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \ 00051 DISPATCH(PARENT); \ 00052 } 00053 #include "clang/AST/TypeLocNodes.def" 00054 00055 RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); } 00056 }; 00057 00058 #undef DISPATCH 00059 00060 } // end namespace clang 00061 00062 #endif // LLVM_CLANG_AST_TYPELOCVISITOR_H