clang  10.0.0svn
TypeLocVisitor.h
Go to the documentation of this file.
1 //===--- TypeLocVisitor.h - Visitor for TypeLoc subclasses ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the TypeLocVisitor interface.
10 //
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_CLANG_AST_TYPELOCVISITOR_H
13 #define LLVM_CLANG_AST_TYPELOCVISITOR_H
14 
15 #include "clang/AST/TypeLoc.h"
16 #include "clang/AST/TypeVisitor.h"
17 #include "llvm/Support/ErrorHandling.h"
18 
19 namespace clang {
20 
21 #define DISPATCH(CLASSNAME) \
22  return static_cast<ImplClass*>(this)-> \
23  Visit##CLASSNAME(TyLoc.castAs<CLASSNAME>())
24 
25 template<typename ImplClass, typename RetTy=void>
27 public:
28  RetTy Visit(TypeLoc TyLoc) {
29  switch (TyLoc.getTypeLocClass()) {
30 #define ABSTRACT_TYPELOC(CLASS, PARENT)
31 #define TYPELOC(CLASS, PARENT) \
32  case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
33 #include "clang/AST/TypeLocNodes.def"
34  }
35  llvm_unreachable("unexpected type loc class!");
36  }
37 
38  RetTy Visit(UnqualTypeLoc TyLoc) {
39  switch (TyLoc.getTypeLocClass()) {
40 #define ABSTRACT_TYPELOC(CLASS, PARENT)
41 #define TYPELOC(CLASS, PARENT) \
42  case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
43 #include "clang/AST/TypeLocNodes.def"
44  }
45  llvm_unreachable("unexpected type loc class!");
46  }
47 
48 #define TYPELOC(CLASS, PARENT) \
49  RetTy Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
50  DISPATCH(PARENT); \
51  }
52 #include "clang/AST/TypeLocNodes.def"
53 
54  RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); }
55 };
56 
57 #undef DISPATCH
58 
59 } // end namespace clang
60 
61 #endif // LLVM_CLANG_AST_TYPELOCVISITOR_H
RetTy Visit(TypeLoc TyLoc)
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:256
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
Wrapper of type source information for a type with no direct qualifiers.
Definition: TypeLoc.h:247
Defines the clang::TypeLoc interface and its subclasses.
Dataflow Directional Tag Classes.
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:113
RetTy Visit(UnqualTypeLoc TyLoc)
RetTy VisitTypeLoc(TypeLoc TyLoc)