1 //===--- TypeLocVisitor.h - Visitor for TypeLoc subclasses ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the TypeLocVisitor interface.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_AST_TYPELOCVISITOR_H
14 #define LLVM_CLANG_AST_TYPELOCVISITOR_H
16 #include "clang/AST/TypeLoc.h"
17 #include "clang/AST/TypeVisitor.h"
18 #include "llvm/Support/ErrorHandling.h"
22 #define DISPATCH(CLASSNAME) \
23 return static_cast<ImplClass*>(this)-> \
24 Visit##CLASSNAME(TyLoc.castAs<CLASSNAME>())
26 template<typename ImplClass, typename RetTy=void>
27 class TypeLocVisitor {
29 RetTy Visit(TypeLoc TyLoc) {
30 switch (TyLoc.getTypeLocClass()) {
31 #define ABSTRACT_TYPELOC(CLASS, PARENT)
32 #define TYPELOC(CLASS, PARENT) \
33 case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
34 #include "clang/AST/TypeLocNodes.def"
36 llvm_unreachable("unexpected type loc class!");
39 RetTy Visit(UnqualTypeLoc TyLoc) {
40 switch (TyLoc.getTypeLocClass()) {
41 #define ABSTRACT_TYPELOC(CLASS, PARENT)
42 #define TYPELOC(CLASS, PARENT) \
43 case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
44 #include "clang/AST/TypeLocNodes.def"
46 llvm_unreachable("unexpected type loc class!");
49 #define TYPELOC(CLASS, PARENT) \
50 RetTy Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
53 #include "clang/AST/TypeLocNodes.def"
55 RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); }
60 } // end namespace clang
62 #endif // LLVM_CLANG_AST_TYPELOCVISITOR_H