clang 20.0.0git
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 "llvm/Support/ErrorHandling.h"
17
18namespace clang {
19
20#define DISPATCH(CLASSNAME) \
21 return static_cast<ImplClass*>(this)-> \
22 Visit##CLASSNAME(TyLoc.castAs<CLASSNAME>())
23
24template<typename ImplClass, typename RetTy=void>
26public:
27 RetTy Visit(TypeLoc TyLoc) {
28 switch (TyLoc.getTypeLocClass()) {
29#define ABSTRACT_TYPELOC(CLASS, PARENT)
30#define TYPELOC(CLASS, PARENT) \
31 case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
32#include "clang/AST/TypeLocNodes.def"
33 }
34 llvm_unreachable("unexpected type loc class!");
35 }
36
37 RetTy Visit(UnqualTypeLoc TyLoc) {
38 switch (TyLoc.getTypeLocClass()) {
39#define ABSTRACT_TYPELOC(CLASS, PARENT)
40#define TYPELOC(CLASS, PARENT) \
41 case TypeLoc::CLASS: DISPATCH(CLASS##TypeLoc);
42#include "clang/AST/TypeLocNodes.def"
43 }
44 llvm_unreachable("unexpected type loc class!");
45 }
46
47#define TYPELOC(CLASS, PARENT) \
48 RetTy Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc) { \
49 DISPATCH(PARENT); \
50 }
51#include "clang/AST/TypeLocNodes.def"
52
53 RetTy VisitTypeLoc(TypeLoc TyLoc) { return RetTy(); }
54};
55
56#undef DISPATCH
57
58} // end namespace clang
59
60#endif // LLVM_CLANG_AST_TYPELOCVISITOR_H
Defines the clang::TypeLoc interface and its subclasses.
RetTy Visit(UnqualTypeLoc TyLoc)
RetTy Visit(TypeLoc TyLoc)
RetTy VisitTypeLoc(TypeLoc TyLoc)
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:59
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:116
Wrapper of type source information for a type with no direct qualifiers.
Definition: TypeLoc.h:263
TypeLocClass getTypeLocClass() const
Definition: TypeLoc.h:272
The JSON file list parser is used to communicate input to InstallAPI.