Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:46

0001 //===--- TypeLocVisitor.h - Visitor for TypeLoc subclasses ------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 //  This file defines the TypeLocVisitor interface.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 #ifndef LLVM_CLANG_AST_TYPELOCVISITOR_H
0013 #define LLVM_CLANG_AST_TYPELOCVISITOR_H
0014 
0015 #include "clang/AST/TypeLoc.h"
0016 #include "llvm/Support/ErrorHandling.h"
0017 
0018 namespace clang {
0019 
0020 #define DISPATCH(CLASSNAME) \
0021   return static_cast<ImplClass*>(this)-> \
0022     Visit##CLASSNAME(TyLoc.castAs<CLASSNAME>())
0023 
0024 template<typename ImplClass, typename RetTy=void>
0025 class TypeLocVisitor {
0026 public:
0027   RetTy Visit(TypeLoc TyLoc) {
0028     switch (TyLoc.getTypeLocClass()) {
0029 #define ABSTRACT_TYPELOC(CLASS, PARENT)
0030 #define TYPELOC(CLASS, PARENT) \
0031     case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
0032 #include "clang/AST/TypeLocNodes.def"
0033     }
0034     llvm_unreachable("unexpected type loc class!");
0035   }
0036 
0037   RetTy Visit(UnqualTypeLoc TyLoc) {
0038     switch (TyLoc.getTypeLocClass()) {
0039 #define ABSTRACT_TYPELOC(CLASS, PARENT)
0040 #define TYPELOC(CLASS, PARENT) \
0041     case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
0042 #include "clang/AST/TypeLocNodes.def"
0043     }
0044     llvm_unreachable("unexpected type loc class!");
0045   }
0046 
0047 #define TYPELOC(CLASS, PARENT)      \
0048   RetTy Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
0049     DISPATCH(PARENT);               \
0050   }
0051 #include "clang/AST/TypeLocNodes.def"
0052 
0053   RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); }
0054 };
0055 
0056 #undef DISPATCH
0057 
0058 }  // end namespace clang
0059 
0060 #endif // LLVM_CLANG_AST_TYPELOCVISITOR_H